0004-tests-stop-running-most-tests-with-pickle-storage-67.patch
tests/admin_pages/test_card.py | ||
---|---|---|
36 | 36 |
return pub_fixture(sql_mode=True) |
37 | 37 | |
38 | 38 | |
39 |
@pytest.fixture |
|
40 |
def nosql_pub(request, emails): |
|
41 |
return pub_fixture() |
|
42 | ||
43 | ||
44 | 39 |
def teardown_module(module): |
45 | 40 |
clean_temporary_pub() |
46 | 41 | |
... | ... | |
160 | 155 |
carddata.remove_self() # don't keep leftovers |
161 | 156 | |
162 | 157 | |
163 |
def test_cards_delete_nosql(nosql_pub): |
|
164 |
pub = nosql_pub |
|
165 |
create_superuser(pub) |
|
166 | ||
167 |
CardDef.wipe() |
|
168 |
carddef = CardDef() |
|
169 |
carddef.name = 'card title' |
|
170 |
carddef.fields = [] |
|
171 |
carddef.store() |
|
172 | ||
173 |
carddata = carddef.data_class()() |
|
174 |
carddata.just_created() |
|
175 |
carddata.data = {} |
|
176 |
carddata.store() |
|
177 | ||
178 |
app = login(get_app(pub)) |
|
179 |
resp = app.get('http://example.net/backoffice/cards/1/') |
|
180 |
resp = resp.click('Delete') |
|
181 |
assert 'Deletion is not possible as there are cards.' not in resp |
|
182 |
assert 'delete-button' in resp.text |
|
183 | ||
184 | ||
185 | 158 |
def test_cards_in_use_delete(pub): |
186 | 159 |
CardDef.wipe() |
187 | 160 |
carddef = CardDef() |
tests/admin_pages/test_datasource.py | ||
---|---|---|
38 | 38 |
return pub_fixture(sql_mode=True) |
39 | 39 | |
40 | 40 | |
41 |
@pytest.fixture |
|
42 |
def nosql_pub(request, emails): |
|
43 |
return pub_fixture() |
|
44 | ||
45 | ||
46 | 41 |
def teardown_module(module): |
47 | 42 |
clean_temporary_pub() |
48 | 43 | |
... | ... | |
145 | 140 |
) |
146 | 141 | |
147 | 142 | |
148 |
def test_data_sources_users_no_sql(nosql_pub): |
|
149 |
pub = nosql_pub |
|
150 |
create_superuser(pub) |
|
151 |
NamedDataSource.wipe() |
|
152 | ||
153 |
app = login(get_app(pub)) |
|
154 |
resp = app.get('/backoffice/settings/data-sources/') |
|
155 | ||
156 |
assert 'Users Data Sources' not in resp |
|
157 |
assert 'new-users' not in resp |
|
158 | ||
159 | ||
160 | 143 |
def test_data_sources_users(pub): |
161 | 144 |
create_superuser(pub) |
162 | 145 |
NamedDataSource.wipe() |
tests/admin_pages/test_form.py | ||
---|---|---|
1 | 1 |
import io |
2 | 2 |
import os |
3 | 3 |
import re |
4 |
import tarfile |
|
5 | 4 |
import time |
6 | 5 |
import xml.etree.ElementTree as ET |
7 | 6 |
from unittest import mock |
... | ... | |
41 | 40 |
return pub_fixture(sql_mode=True) |
42 | 41 | |
43 | 42 | |
44 |
@pytest.fixture |
|
45 |
def nosql_pub(request, emails): |
|
46 |
return pub_fixture() |
|
47 | ||
48 | ||
49 | 43 |
def teardown_module(module): |
50 | 44 |
clean_temporary_pub() |
51 | 45 | |
... | ... | |
790 | 784 |
_test_form_workflow_remapping(pub) |
791 | 785 | |
792 | 786 | |
793 |
def test_form_workflow_remapping_nosql(nosql_pub): |
|
794 |
_test_form_workflow_remapping(nosql_pub) |
|
795 | ||
796 | ||
797 | 787 |
def test_form_submitter_roles(pub): |
798 | 788 |
create_superuser(pub) |
799 | 789 |
create_role(pub) |
... | ... | |
1212 | 1202 |
assert 'Deletion is not possible' not in resp |
1213 | 1203 | |
1214 | 1204 | |
1215 |
def test_form_delete_with_data_nosql(nosql_pub): |
|
1216 |
pub = nosql_pub |
|
1217 |
create_superuser(pub) |
|
1218 |
create_role(pub) |
|
1219 | ||
1220 |
FormDef.wipe() |
|
1221 |
formdef = FormDef() |
|
1222 |
formdef.name = 'form title' |
|
1223 |
formdef.fields = [] |
|
1224 |
formdef.store() |
|
1225 | ||
1226 |
formdata = formdef.data_class()() |
|
1227 |
formdata.just_created() |
|
1228 |
formdata.store() |
|
1229 | ||
1230 |
app = login(get_app(pub)) |
|
1231 | ||
1232 |
resp = app.get('/backoffice/forms/%s/' % formdef.id) |
|
1233 |
resp = resp.click(href='delete') |
|
1234 |
assert 'Deletion is not possible' not in resp |
|
1235 | ||
1236 | ||
1237 | 1205 |
def test_form_duplicate(pub): |
1238 | 1206 |
create_superuser(pub) |
1239 | 1207 |
create_role(pub) |
... | ... | |
2963 | 2931 |
assert 'backoffice/management/form-title/' in resp |
2964 | 2932 | |
2965 | 2933 | |
2966 |
def test_form_archive(nosql_pub): |
|
2967 |
# this doesn't exist in SQL |
|
2968 |
pub = nosql_pub |
|
2969 |
create_superuser(pub) |
|
2970 |
create_role(pub) |
|
2971 | ||
2972 |
FormDef.wipe() |
|
2973 |
formdef = FormDef() |
|
2974 |
formdef.name = 'form title' |
|
2975 |
formdef.fields = [] |
|
2976 |
formdef.store() |
|
2977 | ||
2978 |
data_class = formdef.data_class() |
|
2979 |
data_class.wipe() |
|
2980 |
for i in range(10): |
|
2981 |
formdata = data_class() |
|
2982 |
formdata.just_created() |
|
2983 |
if i < 3: |
|
2984 |
formdata.status = 'wf-new' |
|
2985 |
else: |
|
2986 |
formdata.status = 'wf-rejected' |
|
2987 |
formdata.store() |
|
2988 | ||
2989 |
app = login(get_app(pub)) |
|
2990 |
resp = app.get('/backoffice/forms/1/') |
|
2991 |
resp = resp.click(href='archive') |
|
2992 |
resp = resp.form.submit('cancel') |
|
2993 |
assert data_class.count() == 10 |
|
2994 |
assert resp.location == 'http://example.net/backoffice/forms/1/' |
|
2995 | ||
2996 |
resp = app.get('/backoffice/forms/1/') |
|
2997 |
resp = resp.click(href='archive') |
|
2998 |
resp = resp.form.submit('submit') |
|
2999 |
assert resp.content_type == 'application/x-wcs-archive' |
|
3000 |
with tarfile.open(fileobj=io.BytesIO(resp.body)) as tf: |
|
3001 |
assert 'formdef' in [x.name for x in tf.getmembers()] |
|
3002 |
assert len(tf.getmembers()) == 8 # 7 formdata + 1 formdef |
|
3003 | ||
3004 |
# second archive, it shouldn't get anything (but the formdef) |
|
3005 |
resp = app.get('/backoffice/forms/1/') |
|
3006 |
resp = resp.click(href='archive') |
|
3007 |
resp = resp.form.submit('submit') |
|
3008 |
assert resp.content_type == 'application/x-wcs-archive' |
|
3009 |
with tarfile.open(fileobj=io.BytesIO(resp.body)) as tf: |
|
3010 |
assert 'formdef' in [x.name for x in tf.getmembers()] |
|
3011 |
assert len(tf.getmembers()) == 1 # 0 formdata + 1 formdef |
|
3012 | ||
3013 | ||
3014 | 2934 |
def test_form_overwrite(pub): |
3015 | 2935 |
create_superuser(pub) |
3016 | 2936 |
create_role(pub) |
tests/api/test_access.py | ||
---|---|---|
18 | 18 |
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login |
19 | 19 | |
20 | 20 | |
21 |
def pytest_generate_tests(metafunc): |
|
22 |
if 'pub' in metafunc.fixturenames: |
|
23 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
24 | ||
25 | ||
26 | 21 |
@pytest.fixture |
27 | 22 |
def pub(request, emails): |
28 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
23 |
pub = create_temporary_pub(sql_mode=True)
|
|
29 | 24 | |
30 | 25 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
31 | 26 |
pub.set_app_dir(req) |
tests/api/test_all.py | ||
---|---|---|
14 | 14 |
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app |
15 | 15 | |
16 | 16 | |
17 |
def pytest_generate_tests(metafunc): |
|
18 |
if 'pub' in metafunc.fixturenames: |
|
19 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
20 | ||
21 | ||
22 | 17 |
@pytest.fixture |
23 | 18 |
def pub(request, emails): |
24 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
19 |
pub = create_temporary_pub(sql_mode=True)
|
|
25 | 20 | |
26 | 21 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
27 | 22 |
pub.set_app_dir(req) |
tests/api/test_carddef.py | ||
---|---|---|
27 | 27 |
from .utils import sign_uri |
28 | 28 | |
29 | 29 | |
30 |
def pytest_generate_tests(metafunc): |
|
31 |
if 'pub' in metafunc.fixturenames: |
|
32 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
33 | ||
34 | ||
35 | 30 |
@pytest.fixture |
36 | 31 |
def pub(request, emails): |
37 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
32 |
pub = create_temporary_pub(sql_mode=True)
|
|
38 | 33 | |
39 | 34 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
40 | 35 |
pub.set_app_dir(req) |
tests/api/test_category.py | ||
---|---|---|
11 | 11 |
from .utils import sign_uri |
12 | 12 | |
13 | 13 | |
14 |
def pytest_generate_tests(metafunc): |
|
15 |
if 'pub' in metafunc.fixturenames: |
|
16 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
17 | ||
18 | ||
19 | 14 |
@pytest.fixture |
20 | 15 |
def pub(request, emails): |
21 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
16 |
pub = create_temporary_pub(sql_mode=True)
|
|
22 | 17 | |
23 | 18 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
24 | 19 |
pub.set_app_dir(req) |
tests/api/test_custom_view.py | ||
---|---|---|
16 | 16 |
from .utils import sign_uri |
17 | 17 | |
18 | 18 | |
19 |
def pytest_generate_tests(metafunc): |
|
20 |
if 'pub' in metafunc.fixturenames: |
|
21 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
22 | ||
23 | ||
24 | 19 |
@pytest.fixture |
25 | 20 |
def pub(request, emails): |
26 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
21 |
pub = create_temporary_pub(sql_mode=True)
|
|
27 | 22 | |
28 | 23 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
29 | 24 |
pub.set_app_dir(req) |
tests/api/test_formdata.py | ||
---|---|---|
29 | 29 |
from .utils import sign_uri |
30 | 30 | |
31 | 31 | |
32 |
def pytest_generate_tests(metafunc): |
|
33 |
if 'pub' in metafunc.fixturenames: |
|
34 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
35 | ||
36 | ||
37 | 32 |
@pytest.fixture |
38 | 33 |
def pub(request, emails): |
39 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
34 |
pub = create_temporary_pub(sql_mode=True)
|
|
40 | 35 | |
41 | 36 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
42 | 37 |
pub.set_app_dir(req) |
tests/api/test_formdef.py | ||
---|---|---|
26 | 26 |
from .utils import sign_uri |
27 | 27 | |
28 | 28 | |
29 |
def pytest_generate_tests(metafunc): |
|
30 |
if 'pub' in metafunc.fixturenames: |
|
31 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
32 | ||
33 | ||
34 | 29 |
@pytest.fixture |
35 | 30 |
def pub(request, emails): |
36 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
31 |
pub = create_temporary_pub(sql_mode=True)
|
|
37 | 32 | |
38 | 33 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
39 | 34 |
pub.set_app_dir(req) |
tests/api/test_statistics.py | ||
---|---|---|
97 | 97 |
assert resp.json['data'][0]['url'] == 'http://example.net/api/statistics/forms/count/' |
98 | 98 | |
99 | 99 | |
100 |
def test_statistics_index_no_sql(pub): |
|
101 |
pub.is_using_postgresql = lambda: False |
|
102 |
assert get_app(pub).get(sign_uri('/api/statistics/')).json == {'data': [], 'err': 0} |
|
103 | ||
104 | ||
105 | 100 |
def test_statistics_index_categories(pub): |
106 | 101 |
Category(name='Category A').store() |
107 | 102 |
Category(name='Category B').store() |
tests/api/test_user.py | ||
---|---|---|
19 | 19 |
from .utils import sign_uri |
20 | 20 | |
21 | 21 | |
22 |
def pytest_generate_tests(metafunc): |
|
23 |
if 'pub' in metafunc.fixturenames: |
|
24 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
25 | ||
26 | ||
27 | 22 |
@pytest.fixture |
28 | 23 |
def pub(request, emails): |
29 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
24 |
pub = create_temporary_pub(sql_mode=True)
|
|
30 | 25 | |
31 | 26 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
32 | 27 |
pub.set_app_dir(req) |
tests/api/test_workflow.py | ||
---|---|---|
16 | 16 |
from .utils import sign_uri |
17 | 17 | |
18 | 18 | |
19 |
def pytest_generate_tests(metafunc): |
|
20 |
if 'pub' in metafunc.fixturenames: |
|
21 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
22 | ||
23 | ||
24 | 19 |
@pytest.fixture |
25 | 20 |
def pub(request, emails): |
26 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
21 |
pub = create_temporary_pub(sql_mode=True)
|
|
27 | 22 | |
28 | 23 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
29 | 24 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_all.py | ||
---|---|---|
29 | 29 |
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login |
30 | 30 | |
31 | 31 | |
32 |
def pytest_generate_tests(metafunc): |
|
33 |
if 'pub' in metafunc.fixturenames: |
|
34 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
35 | ||
36 | ||
37 | 32 |
@pytest.fixture |
38 | 33 |
def pub(request, emails): |
39 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
34 |
pub = create_temporary_pub(sql_mode=True)
|
|
40 | 35 | |
41 | 36 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
42 | 37 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_carddata.py | ||
---|---|---|
17 | 17 |
from .test_all import create_superuser, create_user |
18 | 18 | |
19 | 19 | |
20 |
def pytest_generate_tests(metafunc): |
|
21 |
if 'pub' in metafunc.fixturenames: |
|
22 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
23 | ||
24 | ||
25 | 20 |
@pytest.fixture |
26 | 21 |
def pub(request, emails): |
27 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
22 |
pub = create_temporary_pub(sql_mode=True)
|
|
28 | 23 | |
29 | 24 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
30 | 25 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_columns.py | ||
---|---|---|
16 | 16 |
from .test_all import create_superuser |
17 | 17 | |
18 | 18 | |
19 |
def pytest_generate_tests(metafunc): |
|
20 |
if 'pub' in metafunc.fixturenames: |
|
21 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
22 | ||
23 | ||
24 | 19 |
@pytest.fixture |
25 | 20 |
def pub(request, emails): |
26 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
21 |
pub = create_temporary_pub(sql_mode=True)
|
|
27 | 22 | |
28 | 23 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
29 | 24 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_custom_view.py | ||
---|---|---|
14 | 14 |
from .test_all import create_superuser, create_user |
15 | 15 | |
16 | 16 | |
17 |
def pytest_generate_tests(metafunc): |
|
18 |
if 'pub' in metafunc.fixturenames: |
|
19 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
20 | ||
21 | ||
22 | 17 |
@pytest.fixture |
23 | 18 |
def pub(request, emails): |
24 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
19 |
pub = create_temporary_pub(sql_mode=True)
|
|
25 | 20 | |
26 | 21 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
27 | 22 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_export.py | ||
---|---|---|
19 | 19 |
from .test_all import create_superuser |
20 | 20 | |
21 | 21 | |
22 |
def pytest_generate_tests(metafunc): |
|
23 |
if 'pub' in metafunc.fixturenames: |
|
24 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
25 | ||
26 | ||
27 | 22 |
@pytest.fixture |
28 | 23 |
def pub(request, emails): |
29 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
24 |
pub = create_temporary_pub(sql_mode=True)
|
|
30 | 25 | |
31 | 26 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
32 | 27 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_filters.py | ||
---|---|---|
16 | 16 |
from .test_all import create_environment, create_superuser |
17 | 17 | |
18 | 18 | |
19 |
def pytest_generate_tests(metafunc): |
|
20 |
if 'pub' in metafunc.fixturenames: |
|
21 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
22 | ||
23 | ||
24 | 19 |
@pytest.fixture |
25 | 20 |
def pub(request, emails): |
26 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
21 |
pub = create_temporary_pub(sql_mode=True)
|
|
27 | 22 | |
28 | 23 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
29 | 24 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_form_inspect.py | ||
---|---|---|
18 | 18 |
from .test_all import create_user |
19 | 19 | |
20 | 20 | |
21 |
def pytest_generate_tests(metafunc): |
|
22 |
if 'pub' in metafunc.fixturenames: |
|
23 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
24 | ||
25 | ||
26 | 21 |
@pytest.fixture |
27 | 22 |
def pub(request, emails): |
28 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
23 |
pub = create_temporary_pub(sql_mode=True)
|
|
29 | 24 | |
30 | 25 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
31 | 26 |
pub.cfg['identification'] = {'methods': ['password']} |
tests/backoffice_pages/test_statistics.py | ||
---|---|---|
10 | 10 |
from .test_all import create_environment, create_superuser, create_user |
11 | 11 | |
12 | 12 | |
13 |
def pytest_generate_tests(metafunc): |
|
14 |
if 'pub' in metafunc.fixturenames: |
|
15 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
16 | ||
17 | ||
18 | 13 |
@pytest.fixture |
19 | 14 |
def pub(request, emails): |
20 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
15 |
pub = create_temporary_pub(sql_mode=True)
|
|
21 | 16 | |
22 | 17 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
23 | 18 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_submission.py | ||
---|---|---|
17 | 17 |
from .test_all import create_superuser, create_user |
18 | 18 | |
19 | 19 | |
20 |
def pytest_generate_tests(metafunc): |
|
21 |
if 'pub' in metafunc.fixturenames: |
|
22 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
23 | ||
24 | ||
25 | 20 |
@pytest.fixture |
26 | 21 |
def pub(request, emails): |
27 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
22 |
pub = create_temporary_pub(sql_mode=True)
|
|
28 | 23 | |
29 | 24 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
30 | 25 |
pub.set_app_dir(req) |
tests/backoffice_pages/test_workflow_inspect.py | ||
---|---|---|
14 | 14 |
from .test_all import create_superuser |
15 | 15 | |
16 | 16 | |
17 |
def pytest_generate_tests(metafunc): |
|
18 |
if 'pub' in metafunc.fixturenames: |
|
19 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
20 | ||
21 | ||
22 | 17 |
@pytest.fixture |
23 | 18 |
def pub(request, emails): |
24 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
19 |
pub = create_temporary_pub(sql_mode=True)
|
|
25 | 20 | |
26 | 21 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
27 | 22 |
pub.cfg['identification'] = {'methods': ['password']} |
tests/form_pages/test_all.py | ||
---|---|---|
62 | 62 | |
63 | 63 |
def pytest_generate_tests(metafunc): |
64 | 64 |
if 'pub' in metafunc.fixturenames: |
65 |
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
|
65 |
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
|
66 | 66 | |
67 | 67 | |
68 | 68 |
def pub_fixture(**kwargs): |
... | ... | |
80 | 80 | |
81 | 81 |
@pytest.fixture |
82 | 82 |
def pub(request, emails): |
83 |
return pub_fixture(sql_mode=(request.param == 'sql'), lazy_mode=bool('lazy' in request.param))
|
|
83 |
return pub_fixture(sql_mode=bool('sql' in request.param), lazy_mode=bool('lazy' in request.param))
|
|
84 | 84 | |
85 | 85 | |
86 | 86 |
@pytest.fixture |
tests/form_pages/test_block.py | ||
---|---|---|
19 | 19 | |
20 | 20 |
def pytest_generate_tests(metafunc): |
21 | 21 |
if 'pub' in metafunc.fixturenames: |
22 |
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
|
22 |
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
|
23 | 23 | |
24 | 24 | |
25 | 25 |
@pytest.fixture |
tests/form_pages/test_computed_field.py | ||
---|---|---|
15 | 15 |
from .test_all import create_user |
16 | 16 | |
17 | 17 | |
18 |
def pytest_generate_tests(metafunc): |
|
19 |
if 'pub' in metafunc.fixturenames: |
|
20 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
21 | ||
22 | ||
23 | 18 |
@pytest.fixture |
24 | 19 |
def pub(request, emails): |
25 |
pub = create_temporary_pub( |
|
26 |
sql_mode=bool('sql' in request.param), |
|
27 |
lazy_mode=bool('lazy' in request.param), |
|
28 |
) |
|
20 |
pub = create_temporary_pub(sql_mode=True) |
|
29 | 21 |
pub.cfg['identification'] = {'methods': ['password']} |
30 | 22 |
pub.cfg['language'] = {'language': 'en'} |
31 | 23 |
pub.write_cfg() |
tests/form_pages/test_file_field.py | ||
---|---|---|
22 | 22 | |
23 | 23 |
def pytest_generate_tests(metafunc): |
24 | 24 |
if 'pub' in metafunc.fixturenames: |
25 |
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
|
25 |
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
|
26 | 26 | |
27 | 27 | |
28 | 28 |
@pytest.fixture |
tests/form_pages/test_formdata.py | ||
---|---|---|
29 | 29 | |
30 | 30 |
def pytest_generate_tests(metafunc): |
31 | 31 |
if 'pub' in metafunc.fixturenames: |
32 |
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
|
32 |
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
|
33 | 33 | |
34 | 34 | |
35 | 35 |
@pytest.fixture |
tests/form_pages/test_live.py | ||
---|---|---|
21 | 21 | |
22 | 22 |
def pytest_generate_tests(metafunc): |
23 | 23 |
if 'pub' in metafunc.fixturenames: |
24 |
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
|
24 |
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
|
25 | 25 | |
26 | 26 | |
27 | 27 |
@pytest.fixture |
tests/test_auth_pages.py | ||
---|---|---|
9 | 9 | |
10 | 10 |
@pytest.fixture |
11 | 11 |
def pub(): |
12 |
pub = create_temporary_pub(sql_mode=False)
|
|
12 |
pub = create_temporary_pub(sql_mode=True)
|
|
13 | 13 |
pub.cfg['identification'] = {'methods': ['password']} |
14 | 14 |
pub.cfg['language'] = {'language': 'en'} |
15 | 15 |
pub.write_cfg() |
tests/test_carddef.py | ||
---|---|---|
15 | 15 |
from .utilities import clean_temporary_pub, create_temporary_pub |
16 | 16 | |
17 | 17 | |
18 |
def pytest_generate_tests(metafunc): |
|
19 |
if 'pub' in metafunc.fixturenames: |
|
20 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
21 | ||
22 | ||
23 | 18 |
@pytest.fixture |
24 | 19 |
def pub(request): |
25 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
20 |
pub = create_temporary_pub(sql_mode=True)
|
|
26 | 21 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
27 | 22 |
pub.set_app_dir(req) |
28 | 23 |
pub.cfg['language'] = {'language': 'en'} |
tests/test_categories.py | ||
---|---|---|
16 | 16 | |
17 | 17 |
global pub |
18 | 18 | |
19 |
pub = create_temporary_pub() |
|
19 |
pub = create_temporary_pub(sql_mode=True)
|
|
20 | 20 | |
21 | 21 | |
22 | 22 |
def teardown_module(module): |
... | ... | |
87 | 87 |
def test_xml_export(category_class): |
88 | 88 |
category_class.wipe() |
89 | 89 |
test = category_class() |
90 |
test.id = 1 |
|
91 | 90 |
test.name = 'Test' |
92 | 91 |
test.description = 'Hello world' |
93 | 92 |
test.store() |
94 |
test = category_class.get(1)
|
|
93 |
test = category_class.get(test.id)
|
|
95 | 94 | |
96 | 95 |
assert b'<name>Test</name>' in test.export_to_xml_string(include_id=True) |
97 | 96 |
assert b' id="1"' in test.export_to_xml_string(include_id=True) |
... | ... | |
136 | 135 |
def test_get_by_urlname(category_class): |
137 | 136 |
category_class.wipe() |
138 | 137 |
test = category_class() |
139 |
test.id = 1 |
|
140 | 138 |
test.name = 'Test' |
141 | 139 |
test.description = 'Hello world' |
142 | 140 |
test.store() |
143 |
test = category_class.get(1)
|
|
141 |
test = category_class.get(test.id)
|
|
144 | 142 |
test2 = category_class.get_by_urlname('test') |
145 | 143 |
assert test.id == test2.id |
146 | 144 | |
... | ... | |
149 | 147 |
def test_has_urlname(category_class): |
150 | 148 |
category_class.wipe() |
151 | 149 |
test = category_class() |
152 |
test.id = 1 |
|
153 | 150 |
test.name = 'Test' |
154 | 151 |
test.description = 'Hello world' |
155 | 152 |
test.store() |
156 |
test = category_class.get(1)
|
|
153 |
test = category_class.get(test.id)
|
|
157 | 154 | |
158 | 155 |
assert category_class.has_urlname('test') |
159 | 156 |
assert not category_class.has_urlname('foobar') |
... | ... | |
163 | 160 |
def test_remove_self(category_class): |
164 | 161 |
category_class.wipe() |
165 | 162 |
test = category_class() |
166 |
test.id = 1 |
|
167 | 163 |
test.name = 'Test' |
168 | 164 |
test.description = 'Hello world' |
169 | 165 |
test.store() |
170 |
test = category_class.get(1)
|
|
166 |
test = category_class.get(test.id)
|
|
171 | 167 |
test.remove_self() |
172 | 168 | |
173 | 169 |
with pytest.raises(KeyError): |
174 |
category_class.get(1) |
|
170 |
category_class.get(test.id) |
tests/test_ctl.py | ||
---|---|---|
38 | 38 |
clean_temporary_pub() |
39 | 39 | |
40 | 40 | |
41 |
def pytest_generate_tests(metafunc): |
|
42 |
if 'two_pubs' in metafunc.fixturenames: |
|
43 |
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True) |
|
44 | ||
45 | ||
46 | 41 |
@pytest.fixture |
47 | 42 |
def two_pubs(request): |
48 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
43 |
pub = create_temporary_pub(sql_mode=True)
|
|
49 | 44 |
pub.cfg['language'] = {'language': 'en'} |
50 | 45 |
pub.write_cfg() |
51 | 46 |
return pub |
... | ... | |
173 | 168 |
def run_trigger(trigger, rows): |
174 | 169 |
formdef.data_class().wipe() |
175 | 170 |
formdata = formdef.data_class()() |
171 |
formdata.id = 1 |
|
176 | 172 |
formdata.data = {'0': 'Alice', '1': 'alice@example.net'} |
177 | 173 |
formdata.status = 'wf-%s' % st1.id |
178 | 174 |
formdata.store() |
179 | 175 |
id1 = formdata.id |
180 | 176 |
formdata = formdef.data_class()() |
177 |
formdata.id = 2 |
|
181 | 178 |
formdata.data = {'0': 'Bob', '1': 'bob@example.net'} |
182 | 179 |
formdata.status = 'wf-%s' % st1.id |
183 | 180 |
formdata.store() |
tests/test_datasource.py | ||
---|---|---|
21 | 21 |
from .utilities import clean_temporary_pub, create_temporary_pub |
22 | 22 | |
23 | 23 | |
24 |
def pytest_generate_tests(metafunc): |
|
25 |
if 'pub' in metafunc.fixturenames: |
|
26 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
27 | ||
28 | ||
29 | 24 |
@pytest.fixture |
30 | 25 |
def pub(request): |
31 |
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
|
26 |
pub = create_temporary_pub(sql_mode=True)
|
|
32 | 27 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
33 | 28 |
pub.set_app_dir(req) |
34 | 29 |
tests/test_fc_auth.py | ||
---|---|---|
54 | 54 |
def setup_module(module): |
55 | 55 |
cleanup() |
56 | 56 |
global pub |
57 |
pub = create_temporary_pub() |
|
57 |
pub = create_temporary_pub(sql_mode=True)
|
|
58 | 58 | |
59 | 59 | |
60 | 60 |
def setup_user_profile(pub): |
... | ... | |
347 | 347 |
], |
348 | 348 |
} |
349 | 349 | |
350 |
pub.cfg = {'misc': {'charset': 'utf-8'}} |
|
350 |
for k in list(pub.cfg.keys()): |
|
351 |
if k not in ('misc', 'postgresql'): |
|
352 |
del pub.cfg[k] |
|
351 | 353 |
pub.user_class.wipe() |
352 | 354 |
pub.write_cfg() |
353 | 355 |
app = get_app(pub) |
tests/test_fields.py | ||
---|---|---|
135 | 135 | |
136 | 136 |
def test_bool_stats(): |
137 | 137 |
formdef = FormDef() |
138 |
formdef.name = 'title' |
|
138 | 139 |
formdef.url_name = 'title' |
139 | 140 |
formdef.fields = [fields.BoolField(id='1')] |
141 |
formdef.store() |
|
140 | 142 |
data_class = formdef.data_class() |
141 | 143 |
formdatas = [] |
142 | 144 |
for value in (True, True, True, False): |
tests/test_formdata.py | ||
---|---|---|
40 | 40 |
from .utilities import clean_temporary_pub, create_temporary_pub |
41 | 41 | |
42 | 42 | |
43 |
def pytest_generate_tests(metafunc): |
|
44 |
if 'pub' in metafunc.fixturenames: |
|
45 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
46 | ||
47 | ||
48 | 43 |
@pytest.fixture |
49 | 44 |
def pub(request): |
50 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
45 |
pub = create_temporary_pub(sql_mode=True)
|
|
51 | 46 | |
52 | 47 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
53 | 48 |
pub.set_app_dir(req) |
tests/test_formdef.py | ||
---|---|---|
28 | 28 |
from .utilities import clean_temporary_pub, create_temporary_pub |
29 | 29 | |
30 | 30 | |
31 |
def pytest_generate_tests(metafunc): |
|
32 |
if 'pub' in metafunc.fixturenames: |
|
33 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
34 | ||
35 | ||
36 | 31 |
@pytest.fixture |
37 | 32 |
def pub(request): |
38 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
33 |
pub = create_temporary_pub(sql_mode=True)
|
|
39 | 34 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
40 | 35 |
pub.set_app_dir(req) |
41 | 36 |
pub.cfg['language'] = {'language': 'en'} |
tests/test_hobo.py | ||
---|---|---|
7 | 7 |
import sys |
8 | 8 |
import tempfile |
9 | 9 |
import urllib.parse |
10 |
import zipfile |
|
10 | 11 |
from unittest import mock |
11 | 12 | |
13 |
import pytest |
|
12 | 14 |
from quixote import cleanup |
13 | 15 | |
14 | 16 |
from wcs import fields, sql |
15 | 17 |
from wcs.ctl.check_hobos import CmdCheckHobos |
16 | 18 |
from wcs.publisher import WcsPublisher |
17 | 19 |
from wcs.qommon import force_str |
20 |
from wcs.sql import cleanup_connection |
|
18 | 21 | |
19 | 22 |
from .utilities import clean_temporary_pub, create_temporary_pub |
20 | 23 | |
... | ... | |
219 | 222 |
} |
220 | 223 | |
221 | 224 | |
222 |
def setup_module(module): |
|
223 |
global pub, hobo_cmd, alt_tempdir |
|
224 |
pub = create_temporary_pub() |
|
225 |
pub.cfg['language'] = {'language': 'en'} |
|
225 |
@pytest.fixture |
|
226 |
def setuptest(): |
|
226 | 227 |
hobo_cmd = CmdCheckHobos() |
227 | 228 |
hobo_cmd.all_services = HOBO_JSON |
228 |
alt_tempdir = tempfile.mkdtemp() |
|
229 | ||
229 |
WcsPublisher.APP_DIR = tempfile.mkdtemp() |
|
230 |
pub = create_temporary_pub() |
|
231 |
pub.cfg['language'] = {'language': 'en'} |
|
230 | 232 | |
231 |
def teardown_module(module): |
|
233 |
yield pub, hobo_cmd |
|
234 |
cleanup_connection() |
|
232 | 235 |
clean_temporary_pub() |
236 |
if os.path.exists(WcsPublisher.APP_DIR): |
|
237 |
shutil.rmtree(WcsPublisher.APP_DIR) |
|
238 | ||
239 | ||
240 |
@pytest.fixture |
|
241 |
def alt_tempdir(): |
|
242 |
alt_tempdir = tempfile.mkdtemp() |
|
243 |
yield alt_tempdir |
|
233 | 244 |
shutil.rmtree(alt_tempdir) |
234 | 245 | |
235 | 246 | |
236 |
def test_configure_site_options(): |
|
247 |
@pytest.fixture |
|
248 |
def deploy_setup(alt_tempdir): |
|
249 |
WcsPublisher.APP_DIR = alt_tempdir |
|
250 |
with open(os.path.join(alt_tempdir, 'hobo.json'), 'w') as fd: |
|
251 |
hobo_json = copy.deepcopy(HOBO_JSON) |
|
252 |
del hobo_json['services'][1] # authentic |
|
253 |
fd.write(json.dumps(HOBO_JSON)) |
|
254 |
skeleton_dir = os.path.join(WcsPublisher.APP_DIR, 'skeletons') |
|
255 |
if not os.path.exists(skeleton_dir): |
|
256 |
os.mkdir(skeleton_dir) |
|
257 |
with open(os.path.join(skeleton_dir, 'export-test.wcs'), 'wb') as f: |
|
258 |
with zipfile.ZipFile(f, 'w') as z: |
|
259 |
CONFIG = { |
|
260 |
'postgresql': { |
|
261 |
'createdb-connection-params': {'database': 'postgres', 'user': os.environ['USER']}, |
|
262 |
'database-template-name': 'wcstests_hobo_%s', |
|
263 |
'user': os.environ['USER'], |
|
264 |
} |
|
265 |
} |
|
266 |
z.writestr('config.json', json.dumps(CONFIG)) |
|
267 | ||
268 | ||
269 |
def test_configure_site_options(setuptest, alt_tempdir): |
|
270 |
pub, hobo_cmd = setuptest |
|
237 | 271 |
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0] |
238 | 272 |
hobo_cmd.configure_site_options(service, pub) |
239 | 273 |
pub.load_site_options() |
... | ... | |
257 | 291 |
assert pub.get_site_option('xxx', 'variables') is None |
258 | 292 | |
259 | 293 | |
260 |
def test_update_configuration(): |
|
294 |
def test_update_configuration(setuptest): |
|
295 |
pub, hobo_cmd = setuptest |
|
261 | 296 |
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0] |
262 | 297 |
hobo_cmd.update_configuration(service, pub) |
263 | 298 |
assert pub.cfg['misc']['sitename'] == 'Test wcs' |
... | ... | |
268 | 303 |
assert pub.cfg['sms']['sender'] == 'EO' |
269 | 304 | |
270 | 305 | |
271 |
def test_update_themes(): |
|
306 |
def test_update_themes(setuptest): |
|
307 |
pub, hobo_cmd = setuptest |
|
272 | 308 |
pub.cfg['branding'] = {'theme': 'default'} |
273 | 309 |
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0] |
274 | 310 |
hobo_cmd.update_configuration(service, pub) |
... | ... | |
300 | 336 |
) |
301 | 337 | |
302 | 338 | |
303 |
def test_update_profile(): |
|
339 |
def test_update_profile(setuptest): |
|
340 |
pub, hobo_cmd = setuptest |
|
304 | 341 |
profile = HOBO_JSON.get('profile') |
305 | 342 | |
306 | 343 |
# load in an empty site |
... | ... | |
366 | 403 |
assert attribute_mapping[attribute_name] == field_id |
367 | 404 | |
368 | 405 | |
369 |
def test_configure_authentication_methods(http_requests): |
|
406 |
def test_configure_authentication_methods(setuptest, http_requests): |
|
407 |
pub, hobo_cmd = setuptest |
|
370 | 408 |
pub.cfg['idp'] = {} |
371 | 409 |
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0] |
372 | 410 | |
373 | 411 |
# with real metadata |
374 | 412 |
hobo_cmd.configure_authentication_methods(service, pub) |
413 |
hobo_cmd.configure_site_options(service, pub) |
|
375 | 414 | |
376 | 415 |
idp_keys = list(pub.cfg['idp'].keys()) |
377 | 416 |
assert len(idp_keys) == 1 |
... | ... | |
415 | 454 |
hobo_cmd.all_services = HOBO_JSON |
416 | 455 | |
417 | 456 | |
418 |
def test_deploy(): |
|
457 |
def test_deploy(setuptest, alt_tempdir, deploy_setup): |
|
458 |
dummy, hobo_cmd = setuptest |
|
459 |
cleanup_connection() |
|
419 | 460 |
cleanup() |
420 |
WcsPublisher.APP_DIR = alt_tempdir |
|
421 |
with open(os.path.join(alt_tempdir, 'hobo.json'), 'w') as fd: |
|
422 |
hobo_json = copy.deepcopy(HOBO_JSON) |
|
423 |
del hobo_json['services'][1] # authentic |
|
424 |
fd.write(json.dumps(HOBO_JSON)) |
|
425 | 461 |
hobo_cmd = CmdCheckHobos() |
426 | 462 |
base_options = {} |
427 | 463 |
sub_options_class = collections.namedtuple('Options', ['ignore_timestamp', 'redeploy', 'extra']) |
... | ... | |
433 | 469 |
assert os.path.exists(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net')) |
434 | 470 | |
435 | 471 |
# update |
472 |
cleanup_connection() |
|
436 | 473 |
cleanup() |
437 | 474 |
with open(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net', 'config.pck'), 'rb') as fd: |
438 | 475 |
pub_cfg = pickle.load(fd) |
... | ... | |
450 | 487 |
assert pub_cfg['language'] == {'language': 'fr'} |
451 | 488 | |
452 | 489 | |
453 |
def test_configure_postgresql(): |
|
490 |
def test_configure_postgresql(setuptest, alt_tempdir, deploy_setup): |
|
491 |
cleanup_connection() |
|
454 | 492 |
cleanup() |
455 |
WcsPublisher.APP_DIR = alt_tempdir |
|
456 | 493 |
with open(os.path.join(alt_tempdir, 'hobo.json'), 'w') as fd: |
457 | 494 |
hobo_json = copy.deepcopy(HOBO_JSON) |
458 | 495 |
del hobo_json['services'][1] # authentic |
... | ... | |
470 | 507 |
) |
471 | 508 |
assert os.path.exists(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net')) |
472 | 509 | |
473 |
with open(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net', 'site-options.cfg'), 'w') as fd: |
|
474 |
fd.write('[options]\n') |
|
475 |
fd.write('postgresql = true\n') |
|
476 | ||
510 |
cleanup_connection() |
|
477 | 511 |
cleanup() |
478 | 512 | |
479 | 513 |
pub = WcsPublisher.create_publisher(register_tld_names=False) |
tests/test_hobo_notify.py | ||
---|---|---|
13 | 13 |
from .utilities import create_temporary_pub, get_app |
14 | 14 | |
15 | 15 | |
16 |
def pytest_generate_tests(metafunc): |
|
17 |
if 'pub' in metafunc.fixturenames: |
|
18 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
19 | ||
20 | ||
21 | 16 |
@pytest.fixture |
22 | 17 |
def pub(request): |
23 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
18 |
pub = create_temporary_pub() |
|
24 | 19 | |
25 | 20 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
26 | 21 |
pub.set_app_dir(req) |
tests/test_hobo_sql.py | ||
---|---|---|
111 | 111 |
yield pub, hobo_cmd |
112 | 112 | |
113 | 113 |
clean_temporary_pub() |
114 |
shutil.rmtree(WcsPublisher.APP_DIR) |
|
114 |
if os.path.exists(WcsPublisher.APP_DIR): |
|
115 |
shutil.rmtree(WcsPublisher.APP_DIR) |
|
115 | 116 |
cleanup_connection() |
116 | 117 |
for dbname in (WCS_DB_NAME, NEW_WCS_DB_NAME): |
117 | 118 |
cursor.execute('DROP DATABASE IF EXISTS %s' % dbname) |
tests/test_prefill.py | ||
---|---|---|
26 | 26 |
def user(request): |
27 | 27 |
pub.user_class.wipe() |
28 | 28 |
user = pub.user_class(name='user') |
29 |
user.id = 'user' |
|
30 | 29 |
user.email = 'test@example.net' |
30 |
user.store() |
|
31 | 31 |
get_request()._user = user |
32 | 32 |
return user |
33 | 33 |
tests/test_publisher.py | ||
---|---|---|
237 | 237 |
for hostname in hostnames: |
238 | 238 |
if not os.path.exists(os.path.join(pub.APP_DIR, hostname)): |
239 | 239 |
os.mkdir(os.path.join(pub.APP_DIR, hostname)) |
240 |
# add a config.pck with postgresql configuration |
|
241 |
with open(os.path.join(pub.APP_DIR, hostname, 'config.pck'), 'wb') as fd: |
|
242 |
pickle.dump(pub.cfg, file=fd) |
|
240 | 243 | |
241 | 244 |
with mock.patch('wcs.qommon.management.commands.cron.cron_worker') as cron_worker: |
242 | 245 |
with mock.patch('wcs.qommon.publisher.QommonPublisher.get_tenants') as mock_tenants: |
... | ... | |
557 | 560 | |
558 | 561 | |
559 | 562 |
def test_clean_loggederrors_no_sql(): |
560 |
pub = create_temporary_pub() |
|
563 |
pub = create_temporary_pub(sql_mode=False)
|
|
561 | 564 | |
562 | 565 |
# do nothing, no error |
563 | 566 |
pub.clean_loggederrors() |
tests/test_register.py | ||
---|---|---|
10 | 10 |
from .utilities import clean_temporary_pub, create_temporary_pub, get_app |
11 | 11 | |
12 | 12 | |
13 |
def pytest_generate_tests(metafunc): |
|
14 |
if 'pub' in metafunc.fixturenames: |
|
15 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
16 | ||
17 | ||
18 | 13 |
@pytest.fixture |
19 | 14 |
def pub(request): |
20 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
15 |
pub = create_temporary_pub(sql_mode=True)
|
|
21 | 16 | |
22 | 17 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
23 | 18 |
pub.set_app_dir(req) |
tests/test_role.py | ||
---|---|---|
1 |
import pickle |
|
2 | ||
3 | 1 |
from quixote import get_publisher |
4 | 2 | |
5 | 3 |
from wcs import sql |
tests/test_rootdirectory.py | ||
---|---|---|
58 | 58 | |
59 | 59 | |
60 | 60 |
def indexhtml(user=None): |
61 |
req._user = req.session.user = user |
|
61 |
req._user = user |
|
62 |
req.session.user = user.id if user else None |
|
62 | 63 |
return str(wcs.forms.root.RootDirectory()._q_index()) |
63 | 64 | |
64 | 65 |
tests/test_saml_auth.py | ||
---|---|---|
43 | 43 |
role_uuid2 = str(uuid.uuid4()) |
44 | 44 | |
45 | 45 | |
46 |
def pytest_generate_tests(metafunc): |
|
47 |
if 'pub' in metafunc.fixturenames: |
|
48 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
49 | ||
50 | ||
51 | 46 |
@pytest.fixture |
52 | 47 |
def pub(request): |
53 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
48 |
pub = create_temporary_pub(sql_mode=True)
|
|
54 | 49 | |
55 | 50 |
if not pub.cfg: |
56 | 51 |
pub.cfg = {} |
tests/test_sessions.py | ||
---|---|---|
22 | 22 |
pass |
23 | 23 | |
24 | 24 | |
25 |
def pytest_generate_tests(metafunc): |
|
26 |
if 'pub' in metafunc.fixturenames: |
|
27 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
28 | ||
29 | ||
30 | 25 |
@pytest.fixture(scope='function') |
31 | 26 |
def pub(request): |
32 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
27 |
pub = create_temporary_pub() |
|
33 | 28 | |
34 | 29 |
def fin(): |
35 | 30 |
shutil.rmtree(pub.APP_DIR) |
tests/test_sql.py | ||
---|---|---|
2253 | 2253 |
assert 'UPDATE' in sql_queries[1] |
2254 | 2254 | |
2255 | 2255 | |
2256 |
def test_sql_import_zip_create_tables(): |
|
2257 |
pub = create_temporary_pub(sql_mode=True) |
|
2258 | ||
2256 |
def test_sql_import_zip_create_tables(pub): |
|
2259 | 2257 |
c = io.BytesIO() |
2260 | 2258 |
with zipfile.ZipFile(c, 'w') as z: |
2261 | 2259 |
z.writestr( |
tests/test_token.py | ||
---|---|---|
11 | 11 |
from .utilities import create_temporary_pub |
12 | 12 | |
13 | 13 | |
14 |
def pytest_generate_tests(metafunc): |
|
15 |
if 'two_pubs' in metafunc.fixturenames: |
|
16 |
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True) |
|
17 | ||
18 | ||
19 | 14 |
@pytest.fixture |
20 | 15 |
def pub(request): |
21 | 16 |
return create_temporary_pub(sql_mode=True) |
22 | 17 | |
23 | 18 | |
24 |
@pytest.fixture |
|
25 |
def two_pubs(request): |
|
26 |
return create_temporary_pub(sql_mode=(request.param == 'sql')) |
|
27 | ||
28 | ||
29 | 19 |
def test_migrate_to_sql(pub): |
30 | 20 |
get_publisher().token_class.wipe() |
31 | 21 |
assert get_publisher().token_class.count() == 0 |
... | ... | |
52 | 42 |
assert sql_token.expiration.year == now().year |
53 | 43 | |
54 | 44 | |
55 |
def test_expiration(two_pubs):
|
|
45 |
def test_expiration(pub):
|
|
56 | 46 |
get_publisher().token_class.wipe() |
57 | 47 |
token = get_publisher().token_class() |
58 | 48 |
token.store() |
... | ... | |
64 | 54 |
assert get_publisher().token_class().get(token.id) |
65 | 55 | |
66 | 56 | |
67 |
def test_clean_job(two_pubs):
|
|
57 |
def test_clean_job(pub):
|
|
68 | 58 |
get_publisher().token_class.wipe() |
69 | 59 |
token = get_publisher().token_class() |
70 | 60 |
token.store() |
tests/test_tracking_code.py | ||
---|---|---|
5 | 5 |
from .utilities import clean_temporary_pub, create_temporary_pub |
6 | 6 | |
7 | 7 | |
8 |
def pytest_generate_tests(metafunc): |
|
9 |
if 'pub' in metafunc.fixturenames: |
|
10 |
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True) |
|
11 | ||
12 | ||
13 | 8 |
@pytest.fixture |
14 | 9 |
def pub(request): |
15 |
return create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
10 |
return create_temporary_pub(sql_mode=True)
|
|
16 | 11 | |
17 | 12 | |
18 | 13 |
def teardown_module(module): |
tests/test_upload_storage.py | ||
---|---|---|
17 | 17 | |
18 | 18 |
def pytest_generate_tests(metafunc): |
19 | 19 |
if 'pub' in metafunc.fixturenames: |
20 |
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
|
20 |
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
|
21 | 21 | |
22 | 22 | |
23 | 23 |
@pytest.fixture |
tests/utilities.py | ||
---|---|---|
43 | 43 |
known_elements = KnownElements() |
44 | 44 | |
45 | 45 | |
46 |
def create_temporary_pub(sql_mode=False, legacy_theme_mode=False, lazy_mode=False):
|
|
46 |
def create_temporary_pub(sql_mode=True, legacy_theme_mode=False, lazy_mode=False):
|
|
47 | 47 |
if get_publisher(): |
48 | 48 |
get_publisher().cleanup() |
49 | 49 |
cleanup() |
... | ... | |
51 | 51 |
APP_DIR = known_elements.legacy_theme_app_dir |
52 | 52 |
elif lazy_mode and known_elements.lazy_app_dir: |
53 | 53 |
APP_DIR = known_elements.lazy_app_dir |
54 |
elif sql_mode and known_elements.sql_app_dir: |
|
54 |
elif sql_mode and known_elements.sql_app_dir and not lazy_mode:
|
|
55 | 55 |
APP_DIR = known_elements.sql_app_dir |
56 | 56 |
elif not (legacy_theme_mode or lazy_mode or sql_mode) and known_elements.pickle_app_dir: |
57 | 57 |
APP_DIR = known_elements.pickle_app_dir |
... | ... | |
61 | 61 |
known_elements.legacy_theme_app_dir = APP_DIR |
62 | 62 |
elif lazy_mode: |
63 | 63 |
known_elements.lazy_app_dir = APP_DIR |
64 |
elif sql_mode: |
|
64 |
elif sql_mode and not lazy_mode:
|
|
65 | 65 |
known_elements.sql_app_dir = APP_DIR |
66 | 66 |
else: |
67 | 67 |
known_elements.pickle_app_dir = APP_DIR |
tests/workflow/test_all.py | ||
---|---|---|
92 | 92 |
clean_temporary_pub() |
93 | 93 | |
94 | 94 | |
95 |
def pytest_generate_tests(metafunc): |
|
96 |
if 'two_pubs' in metafunc.fixturenames: |
|
97 |
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True) |
|
98 | ||
99 | ||
100 | 95 |
def pub_fixture(**kwargs): |
101 | 96 |
pub = create_temporary_pub(**kwargs) |
102 | 97 |
pub.cfg['language'] = {'language': 'en'} |
... | ... | |
118 | 113 | |
119 | 114 |
@pytest.fixture |
120 | 115 |
def two_pubs(request): |
121 |
return pub_fixture(sql_mode=(request.param == 'sql'))
|
|
116 |
return pub_fixture(sql_mode=True)
|
|
122 | 117 | |
123 | 118 | |
124 | 119 |
@pytest.fixture |
... | ... | |
1446 | 1441 | |
1447 | 1442 |
FormDef.wipe() |
1448 | 1443 |
formdef = FormDef() |
1444 |
formdef.name = 'foobar' |
|
1449 | 1445 |
formdef.url_name = 'foobar' |
1450 | 1446 |
formdef._workflow = workflow |
1447 |
formdef.store() |
|
1451 | 1448 | |
1452 | 1449 |
formdata = formdef.data_class()() |
1453 | 1450 |
formdata.just_created() |
... | ... | |
1545 | 1542 | |
1546 | 1543 |
FormDef.wipe() |
1547 | 1544 |
formdef = FormDef() |
1545 |
formdef.name = 'foobar' |
|
1548 | 1546 |
formdef.url_name = 'foobar' |
1549 | 1547 |
formdef.fields = [ |
1550 | 1548 |
FileField(id='1', label='File1', type='file', varname='file1'), |
... | ... | |
3113 | 3111 | |
3114 | 3112 |
FormDef.wipe() |
3115 | 3113 |
formdef = FormDef() |
3114 |
formdef.name = 'foobar' |
|
3116 | 3115 |
formdef.url_name = 'foobar' |
3117 | 3116 |
formdef._workflow = workflow |
3117 |
formdef.store() |
|
3118 | 3118 | |
3119 | 3119 |
formdata = formdef.data_class()() |
3120 | 3120 |
formdata.status = 'wf-st1' |
... | ... | |
3934 | 3934 |
] |
3935 | 3935 |
block.store() |
3936 | 3936 | |
3937 |
FormDef.wipe() |
|
3937 | 3938 |
formdef = FormDef() |
3938 | 3939 |
formdef.name = 'foo-export-details' |
3939 | 3940 |
formdef.fields = [ |
... | ... | |
3947 | 3948 |
FileField(id='9', label='File', type='file'), |
3948 | 3949 |
DateField(id='10', label='Date', type='date'), |
3949 | 3950 |
ItemField(id='11', label='Item', type='item', items=['foo', 'bar']), |
3950 |
ItemsField(id='11', label='Items', type='items', items=['foo', 'bar']), |
|
3951 | 3951 |
TableField(id='12', label='Table', type='table', columns=['a', 'b'], rows=['c', 'd']), |
3952 | 3952 |
PageField(id='13', label='Empty Page', type='page'), |
3953 | 3953 |
TitleField(id='14', label='Empty Title', type='title'), |
3954 | 3954 |
StringField(id='15', label='Empty String', type='string', varname='invisiblestr'), |
3955 | 3955 |
BlockField(id='16', label='Block Field', type='block:foobar'), |
3956 |
ItemsField(id='17', label='Items', type='items', items=['foo', 'bar']), |
|
3956 | 3957 |
] |
3957 | 3958 |
formdef.store() |
3958 | 3959 |
formdef.data_class().wipe() |
... | ... | |
6417 | 6418 |
# run, against no parent |
6418 | 6419 |
perform_items([update_action], formdata) |
6419 | 6420 |
card = carddef.data_class().get(carddata.id) |
6420 |
assert 'bo0' not in card.data # not called
|
|
6421 |
assert not card.data.get('bo0') # not called
|
|
6421 | 6422 | |
6422 | 6423 |
# other parent |
6423 | 6424 |
formdata.submission_context = { |
... | ... | |
6428 | 6429 |
formdata.store() |
6429 | 6430 |
perform_items([update_action], formdata) |
6430 | 6431 |
card = carddef.data_class().get(carddata.id) |
6431 |
assert 'bo0' not in card.data # not called
|
|
6432 |
assert not card.data.get('bo0') # not called
|
|
6432 | 6433 | |
6433 | 6434 |
# appropriate parent |
6434 | 6435 |
formdata.submission_context = { |
... | ... | |
6501 | 6502 |
# run, against no parent |
6502 | 6503 |
perform_items([update_action], formdata) |
6503 | 6504 |
card = carddef.data_class().get(carddata.id) |
6504 |
assert 'bo0' not in card.data # not called
|
|
6505 |
assert not card.data.get('bo0') # not called
|
|
6505 | 6506 | |
6506 | 6507 |
# appropriate parent |
6507 | 6508 |
formdata.submission_context = { |
tests/workflow/test_carddata.py | ||
---|---|---|
24 | 24 |
clean_temporary_pub() |
25 | 25 | |
26 | 26 | |
27 |
def pytest_generate_tests(metafunc): |
|
28 |
if 'two_pubs' in metafunc.fixturenames: |
|
29 |
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True) |
|
30 | ||
31 | ||
32 | 27 |
@pytest.fixture |
33 | 28 |
def pub(request): |
34 | 29 |
pub = create_temporary_pub() |
... | ... | |
45 | 40 | |
46 | 41 |
@pytest.fixture |
47 | 42 |
def two_pubs(request): |
48 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
43 |
pub = create_temporary_pub(sql_mode=True)
|
|
49 | 44 |
pub.cfg['language'] = {'language': 'en'} |
50 | 45 |
pub.write_cfg() |
51 | 46 |
req = HTTPRequest(None, {'SERVER_NAME': 'example.net', 'SCRIPT_NAME': ''}) |
... | ... | |
202 | 197 | |
203 | 198 |
assert carddef1.data_class().count() == 1 |
204 | 199 |
assert carddef2.data_class().count() == 1 |
205 |
carddata1 = carddef1.data_class().get(id=1)
|
|
206 |
carddata2 = carddef2.data_class().get(id=1)
|
|
200 |
carddata1 = carddef1.data_class().select()[0]
|
|
201 |
carddata2 = carddef2.data_class().select()[0]
|
|
207 | 202 |
assert carddata1.data['1'] == 'card1 foo' |
208 | 203 |
assert carddata2.data['1'] == 'card2 bar' |
209 | 204 |
assert carddata2.data['2'] == str(carddata1.id) |
... | ... | |
225 | 220 | |
226 | 221 |
assert carddef1.data_class().count() == 1 |
227 | 222 |
assert carddef2.data_class().count() == 1 |
228 |
carddata1 = carddef1.data_class().get(id=1)
|
|
229 |
carddata2 = carddef2.data_class().get(id=1)
|
|
223 |
carddata1 = carddef1.data_class().select()[0]
|
|
224 |
carddata2 = carddef2.data_class().select()[0]
|
|
230 | 225 |
assert carddata1.data['1'] == 'card1 fooo' |
231 | 226 |
assert carddata2.data['1'] == 'card2 barr' |
232 | 227 |
assert carddata2.data['2'] == str(carddata1.id) |
... | ... | |
259 | 254 | |
260 | 255 |
assert carddef1.data_class().count() == 1 |
261 | 256 |
assert carddef2.data_class().count() == 1 |
262 |
carddata1 = carddef1.data_class().get(id=1)
|
|
263 |
carddata2 = carddef2.data_class().get(id=1)
|
|
257 |
carddata1 = carddef1.data_class().select()[0]
|
|
258 |
carddata2 = carddef2.data_class().select()[0]
|
|
264 | 259 |
assert carddata1.data['1'] == 'card1 fooo' |
265 | 260 |
assert carddata2.data['1'] == 'card2 barr' |
266 | 261 |
assert carddata2.data['2'] == str(carddata1.id) |
... | ... | |
269 | 264 | |
270 | 265 |
assert carddef1.data_class().count() == 2 |
271 | 266 |
assert carddef2.data_class().count() == 2 |
272 |
carddata1 = carddef1.data_class().get(id=2)
|
|
273 |
carddata2 = carddef2.data_class().get(id=2)
|
|
267 |
carddata1 = carddef1.data_class().select(order_by='id')[-1]
|
|
268 |
carddata2 = carddef2.data_class().select(order_by='id')[-1]
|
|
274 | 269 |
assert carddata1.data['1'] == 'card1 fooo' |
275 | 270 |
assert carddata2.data['1'] == 'card2 barr' |
276 | 271 |
assert carddata2.data['2'] == str(carddata1.id) |
... | ... | |
292 | 287 | |
293 | 288 |
assert carddef1.data_class().count() == 1 |
294 | 289 |
assert carddef2.data_class().count() == 1 |
295 |
carddata1 = carddef1.data_class().get(id=1)
|
|
296 |
carddata2 = carddef2.data_class().get(id=1)
|
|
290 |
carddata1 = carddef1.data_class().select()[0]
|
|
291 |
carddata2 = carddef2.data_class().select()[0]
|
|
297 | 292 |
assert carddata1.data['1'] == 'card1 fooo' |
298 | 293 |
assert carddata2.data['1'] == 'card2 barr' |
299 | 294 |
assert carddata2.data['2'] == str(carddata1.id) |
... | ... | |
315 | 310 | |
316 | 311 |
assert carddef1.data_class().count() == 1 |
317 | 312 |
assert carddef2.data_class().count() == 1 |
318 |
carddata1 = carddef1.data_class().get(id=1)
|
|
319 |
carddata2 = carddef2.data_class().get(id=1)
|
|
313 |
carddata1 = carddef1.data_class().select()[0]
|
|
314 |
carddata2 = carddef2.data_class().select()[0]
|
|
320 | 315 |
assert carddata1.data['1'] == 'card1 fooo' |
321 | 316 |
assert carddata2.data['1'] == 'card2 barr' |
322 | 317 |
assert carddata2.data['2'] == str(carddata1.id) |
... | ... | |
1084 | 1079 |
formdata.perform_workflow() |
1085 | 1080 | |
1086 | 1081 |
data = carddef.data_class().select()[0] |
1087 |
assert data.user_id == user.id
|
|
1082 |
assert str(data.user_id) == str(user.id)
|
|
1088 | 1083 | |
1089 | 1084 | |
1090 | 1085 |
def test_assign_carddata_with_linked_object(pub): |
... | ... | |
1143 | 1138 | |
1144 | 1139 |
assert carddef.data_class().count() == 1 |
1145 | 1140 |
card_data = carddef.data_class().select()[0] |
1146 |
assert card_data.user_id == user.id
|
|
1141 |
assert str(card_data.user_id) == str(user.id)
|
|
1147 | 1142 | |
1148 | 1143 | |
1149 | 1144 |
def test_assign_carddata_manual_targeting(two_pubs): |
... | ... | |
1380 | 1375 |
# run workflow, verify that carddata is assign |
1381 | 1376 |
carddata.just_created() |
1382 | 1377 |
carddata.perform_workflow() |
1383 |
assert carddata.user_id == user.id
|
|
1378 |
assert str(carddata.user_id) == str(user.id)
|
|
1384 | 1379 |
assert carddata.status == 'wf-%s' % st2.id |
1385 | 1380 | |
1386 | 1381 | |
... | ... | |
1443 | 1438 |
carddata.store() |
1444 | 1439 |
carddata.just_created() |
1445 | 1440 |
carddata.perform_workflow() |
1446 |
assert carddata.user_id == user.id
|
|
1441 |
assert str(carddata.user_id) == str(user.id)
|
|
1447 | 1442 | |
1448 | 1443 |
carddata_reloaded = carddata.get(carddata.id) |
1449 | 1444 |
assert carddata_reloaded.status == 'wf-2' |
1450 |
assert carddata_reloaded.user_id == user.id
|
|
1445 |
assert str(carddata_reloaded.user_id) == str(user.id)
|
|
1451 | 1446 | |
1452 | 1447 | |
1453 | 1448 |
def test_assign_carddata_user_association(two_pubs): |
tests/workflow/test_formdata.py | ||
---|---|---|
20 | 20 |
clean_temporary_pub() |
21 | 21 | |
22 | 22 | |
23 |
def pytest_generate_tests(metafunc): |
|
24 |
if 'two_pubs' in metafunc.fixturenames: |
|
25 |
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True) |
|
26 | ||
27 | ||
28 | 23 |
@pytest.fixture |
29 | 24 |
def pub(request): |
30 | 25 |
pub = create_temporary_pub() |
... | ... | |
41 | 36 | |
42 | 37 |
@pytest.fixture |
43 | 38 |
def two_pubs(request): |
44 |
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
|
39 |
pub = create_temporary_pub(sql_mode=True)
|
|
45 | 40 |
pub.cfg['language'] = {'language': 'en'} |
46 | 41 |
pub.write_cfg() |
47 | 42 |
req = HTTPRequest(None, {'SERVER_NAME': 'example.net', 'SCRIPT_NAME': ''}) |
tests/workflow/test_notification.py | ||
---|---|---|
301 | 301 |
formdata.just_created() |
302 | 302 |
formdata.store() |
303 | 303 | |
304 |
pub.load_site_options() |
|
304 | 305 |
if not pub.site_options.has_section('variables'): |
305 | 306 |
pub.site_options.add_section('variables') |
306 | 307 |
pub.site_options.set('variables', 'portal_url', 'https://portal/') |
wcs/ctl/check_hobos.py | ||
---|---|---|
564 | 564 |
if not pub.cfg.get('postgresql'): |
565 | 565 |
return |
566 | 566 | |
567 |
if not pub.has_site_option('postgresql'): |
|
568 |
return |
|
569 | ||
570 | 567 |
import psycopg2 |
571 | 568 |
import psycopg2.errorcodes |
572 | 569 | |
573 |
- |