|
1 |
import argparse
|
|
2 |
from io import BytesIO
|
|
3 |
import re
|
|
4 |
|
1 |
5 |
import pytest
|
2 |
6 |
from httmock import urlmatch, HTTMock, response, remember_called
|
3 |
7 |
|
... | ... | |
6 |
10 |
from django.core.files import File
|
7 |
11 |
from django.core.cache import cache
|
8 |
12 |
from django.utils import six
|
9 |
|
from io import BytesIO
|
10 |
13 |
|
11 |
14 |
from utils import make_resource
|
12 |
15 |
|
... | ... | |
14 |
17 |
collect_ignore = ['wcs/']
|
15 |
18 |
|
16 |
19 |
|
|
20 |
def pytest_addoption(parser):
|
|
21 |
def key_value_option(string):
|
|
22 |
if not re.match(r'\w+=.*', string):
|
|
23 |
raise argparse.ArgumentTypeError('invalid key=value option')
|
|
24 |
return string.split('=', 1)
|
|
25 |
|
|
26 |
class KeyValueOption(argparse.Action):
|
|
27 |
def __call__(self, parser, namespace, values, option_string=None):
|
|
28 |
key, value = values
|
|
29 |
d = getattr(namespace, self.dest)
|
|
30 |
d[key] = value
|
|
31 |
|
|
32 |
parser.addoption('--connector-params', action=KeyValueOption, type=key_value_option, default={})
|
|
33 |
|
|
34 |
|
|
35 |
@pytest.fixture
|
|
36 |
def connector_params(pytestconfig):
|
|
37 |
return pytestconfig.getoption('connector_params').copy()
|
|
38 |
|
|
39 |
|
17 |
40 |
@pytest.fixture(autouse=True)
|
18 |
41 |
def media(settings, tmpdir):
|
19 |
42 |
settings.MEDIA_ROOT = str(tmpdir.mkdir('media'))
|
... | ... | |
194 |
217 |
yield
|
195 |
218 |
finally:
|
196 |
219 |
InMemoryCache._cache = {}
|
|
220 |
|
|
221 |
|
|
222 |
@pytest.fixture
|
|
223 |
def rsa13(db):
|
|
224 |
return utils.make_resource(
|
|
225 |
RSA13Resource,
|
|
226 |
title='Test',
|
|
227 |
slug='test',
|
|
228 |
description='Test',
|
|
229 |
webservice_base_url='https://rsa-cd13.com',
|
|
230 |
basic_auth_username='username',
|
|
231 |
basic_auth_password='password',
|
|
232 |
)
|
197 |
|
-
|