tests: stop running most tests with pickle storage (#67190)
This commit is contained in:
parent
88506eb4a2
commit
b184acabd5
|
@ -36,11 +36,6 @@ def pub(request, emails):
|
|||
return pub_fixture(sql_mode=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def nosql_pub(request, emails):
|
||||
return pub_fixture()
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
clean_temporary_pub()
|
||||
|
||||
|
@ -160,28 +155,6 @@ def test_cards_delete(pub):
|
|||
carddata.remove_self() # don't keep leftovers
|
||||
|
||||
|
||||
def test_cards_delete_nosql(nosql_pub):
|
||||
pub = nosql_pub
|
||||
create_superuser(pub)
|
||||
|
||||
CardDef.wipe()
|
||||
carddef = CardDef()
|
||||
carddef.name = 'card title'
|
||||
carddef.fields = []
|
||||
carddef.store()
|
||||
|
||||
carddata = carddef.data_class()()
|
||||
carddata.just_created()
|
||||
carddata.data = {}
|
||||
carddata.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('http://example.net/backoffice/cards/1/')
|
||||
resp = resp.click('Delete')
|
||||
assert 'Deletion is not possible as there are cards.' not in resp
|
||||
assert 'delete-button' in resp.text
|
||||
|
||||
|
||||
def test_cards_in_use_delete(pub):
|
||||
CardDef.wipe()
|
||||
carddef = CardDef()
|
||||
|
|
|
@ -38,11 +38,6 @@ def pub(request, emails):
|
|||
return pub_fixture(sql_mode=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def nosql_pub(request, emails):
|
||||
return pub_fixture()
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
clean_temporary_pub()
|
||||
|
||||
|
@ -145,18 +140,6 @@ def test_data_sources_agenda(pub, chrono_url):
|
|||
)
|
||||
|
||||
|
||||
def test_data_sources_users_no_sql(nosql_pub):
|
||||
pub = nosql_pub
|
||||
create_superuser(pub)
|
||||
NamedDataSource.wipe()
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/settings/data-sources/')
|
||||
|
||||
assert 'Users Data Sources' not in resp
|
||||
assert 'new-users' not in resp
|
||||
|
||||
|
||||
def test_data_sources_users(pub):
|
||||
create_superuser(pub)
|
||||
NamedDataSource.wipe()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import io
|
||||
import os
|
||||
import re
|
||||
import tarfile
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
from unittest import mock
|
||||
|
@ -41,11 +40,6 @@ def pub(request, emails):
|
|||
return pub_fixture(sql_mode=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def nosql_pub(request, emails):
|
||||
return pub_fixture()
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
clean_temporary_pub()
|
||||
|
||||
|
@ -790,10 +784,6 @@ def test_form_workflow_remapping(pub):
|
|||
_test_form_workflow_remapping(pub)
|
||||
|
||||
|
||||
def test_form_workflow_remapping_nosql(nosql_pub):
|
||||
_test_form_workflow_remapping(nosql_pub)
|
||||
|
||||
|
||||
def test_form_submitter_roles(pub):
|
||||
create_superuser(pub)
|
||||
create_role(pub)
|
||||
|
@ -1212,28 +1202,6 @@ def test_form_delete_with_data(pub):
|
|||
assert 'Deletion is not possible' not in resp
|
||||
|
||||
|
||||
def test_form_delete_with_data_nosql(nosql_pub):
|
||||
pub = nosql_pub
|
||||
create_superuser(pub)
|
||||
create_role(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = []
|
||||
formdef.store()
|
||||
|
||||
formdata = formdef.data_class()()
|
||||
formdata.just_created()
|
||||
formdata.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
||||
resp = app.get('/backoffice/forms/%s/' % formdef.id)
|
||||
resp = resp.click(href='delete')
|
||||
assert 'Deletion is not possible' not in resp
|
||||
|
||||
|
||||
def test_form_duplicate(pub):
|
||||
create_superuser(pub)
|
||||
create_role(pub)
|
||||
|
@ -2963,54 +2931,6 @@ def test_form_management_view(pub):
|
|||
assert 'backoffice/management/form-title/' in resp
|
||||
|
||||
|
||||
def test_form_archive(nosql_pub):
|
||||
# this doesn't exist in SQL
|
||||
pub = nosql_pub
|
||||
create_superuser(pub)
|
||||
create_role(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = []
|
||||
formdef.store()
|
||||
|
||||
data_class = formdef.data_class()
|
||||
data_class.wipe()
|
||||
for i in range(10):
|
||||
formdata = data_class()
|
||||
formdata.just_created()
|
||||
if i < 3:
|
||||
formdata.status = 'wf-new'
|
||||
else:
|
||||
formdata.status = 'wf-rejected'
|
||||
formdata.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/forms/1/')
|
||||
resp = resp.click(href='archive')
|
||||
resp = resp.form.submit('cancel')
|
||||
assert data_class.count() == 10
|
||||
assert resp.location == 'http://example.net/backoffice/forms/1/'
|
||||
|
||||
resp = app.get('/backoffice/forms/1/')
|
||||
resp = resp.click(href='archive')
|
||||
resp = resp.form.submit('submit')
|
||||
assert resp.content_type == 'application/x-wcs-archive'
|
||||
with tarfile.open(fileobj=io.BytesIO(resp.body)) as tf:
|
||||
assert 'formdef' in [x.name for x in tf.getmembers()]
|
||||
assert len(tf.getmembers()) == 8 # 7 formdata + 1 formdef
|
||||
|
||||
# second archive, it shouldn't get anything (but the formdef)
|
||||
resp = app.get('/backoffice/forms/1/')
|
||||
resp = resp.click(href='archive')
|
||||
resp = resp.form.submit('submit')
|
||||
assert resp.content_type == 'application/x-wcs-archive'
|
||||
with tarfile.open(fileobj=io.BytesIO(resp.body)) as tf:
|
||||
assert 'formdef' in [x.name for x in tf.getmembers()]
|
||||
assert len(tf.getmembers()) == 1 # 0 formdata + 1 formdef
|
||||
|
||||
|
||||
def test_form_overwrite(pub):
|
||||
create_superuser(pub)
|
||||
create_role(pub)
|
||||
|
|
|
@ -18,14 +18,9 @@ from wcs.qommon.ident.password_accounts import PasswordAccount
|
|||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -14,14 +14,9 @@ from wcs.qommon.http_request import HTTPRequest
|
|||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -27,14 +27,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
|||
from .utils import sign_uri
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -11,14 +11,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
|||
from .utils import sign_uri
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -16,14 +16,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
|||
from .utils import sign_uri
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -29,14 +29,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .utils import sign_uri
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -26,14 +26,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
|||
from .utils import sign_uri
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -97,11 +97,6 @@ def test_statistics_index(pub):
|
|||
assert resp.json['data'][0]['url'] == 'http://example.net/api/statistics/forms/count/'
|
||||
|
||||
|
||||
def test_statistics_index_no_sql(pub):
|
||||
pub.is_using_postgresql = lambda: False
|
||||
assert get_app(pub).get(sign_uri('/api/statistics/')).json == {'data': [], 'err': 0}
|
||||
|
||||
|
||||
def test_statistics_index_categories(pub):
|
||||
Category(name='Category A').store()
|
||||
Category(name='Category B').store()
|
||||
|
|
|
@ -19,14 +19,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
|||
from .utils import sign_uri
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -16,14 +16,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .utils import sign_uri
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -29,14 +29,9 @@ from wcs.wscalls import NamedWsCall
|
|||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -17,14 +17,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_superuser, create_user
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -16,14 +16,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_superuser
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -14,14 +14,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_superuser, create_user
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -19,14 +19,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_superuser
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -16,14 +16,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_environment, create_superuser
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -18,14 +18,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_user
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
|
|
|
@ -10,14 +10,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_environment, create_superuser, create_user
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -17,14 +17,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_superuser, create_user
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -14,14 +14,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_superuser
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
|
|
|
@ -62,7 +62,7 @@ def assert_equal_zip(stream1, stream2):
|
|||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
||||
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
||||
|
||||
|
||||
def pub_fixture(**kwargs):
|
||||
|
@ -80,7 +80,7 @@ def pub_fixture(**kwargs):
|
|||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
return pub_fixture(sql_mode=(request.param == 'sql'), lazy_mode=bool('lazy' in request.param))
|
||||
return pub_fixture(sql_mode=bool('sql' in request.param), lazy_mode=bool('lazy' in request.param))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -19,7 +19,7 @@ from .test_all import create_user
|
|||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
||||
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -15,17 +15,9 @@ from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, logi
|
|||
from .test_all import create_user
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request, emails):
|
||||
pub = create_temporary_pub(
|
||||
sql_mode=bool('sql' in request.param),
|
||||
lazy_mode=bool('lazy' in request.param),
|
||||
)
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
pub.write_cfg()
|
||||
|
|
|
@ -22,7 +22,7 @@ from .test_all import create_user
|
|||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
||||
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -29,7 +29,7 @@ from .test_all import create_user, create_user_and_admin
|
|||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
||||
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -21,7 +21,7 @@ from .test_all import create_user
|
|||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
||||
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -9,7 +9,7 @@ from .utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
|||
|
||||
@pytest.fixture
|
||||
def pub():
|
||||
pub = create_temporary_pub(sql_mode=False)
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
pub.cfg['identification'] = {'methods': ['password']}
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
pub.write_cfg()
|
||||
|
|
|
@ -15,14 +15,9 @@ from wcs.qommon.template import Template
|
|||
from .utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
|
|
|
@ -16,7 +16,7 @@ def setup_module(module):
|
|||
|
||||
global pub
|
||||
|
||||
pub = create_temporary_pub()
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
|
@ -87,11 +87,10 @@ def test_sort_positions(category_class):
|
|||
def test_xml_export(category_class):
|
||||
category_class.wipe()
|
||||
test = category_class()
|
||||
test.id = 1
|
||||
test.name = 'Test'
|
||||
test.description = 'Hello world'
|
||||
test.store()
|
||||
test = category_class.get(1)
|
||||
test = category_class.get(test.id)
|
||||
|
||||
assert b'<name>Test</name>' in test.export_to_xml_string(include_id=True)
|
||||
assert b' id="1"' in test.export_to_xml_string(include_id=True)
|
||||
|
@ -136,11 +135,10 @@ def test_load_old_pickle():
|
|||
def test_get_by_urlname(category_class):
|
||||
category_class.wipe()
|
||||
test = category_class()
|
||||
test.id = 1
|
||||
test.name = 'Test'
|
||||
test.description = 'Hello world'
|
||||
test.store()
|
||||
test = category_class.get(1)
|
||||
test = category_class.get(test.id)
|
||||
test2 = category_class.get_by_urlname('test')
|
||||
assert test.id == test2.id
|
||||
|
||||
|
@ -149,11 +147,10 @@ def test_get_by_urlname(category_class):
|
|||
def test_has_urlname(category_class):
|
||||
category_class.wipe()
|
||||
test = category_class()
|
||||
test.id = 1
|
||||
test.name = 'Test'
|
||||
test.description = 'Hello world'
|
||||
test.store()
|
||||
test = category_class.get(1)
|
||||
test = category_class.get(test.id)
|
||||
|
||||
assert category_class.has_urlname('test')
|
||||
assert not category_class.has_urlname('foobar')
|
||||
|
@ -163,12 +160,11 @@ def test_has_urlname(category_class):
|
|||
def test_remove_self(category_class):
|
||||
category_class.wipe()
|
||||
test = category_class()
|
||||
test.id = 1
|
||||
test.name = 'Test'
|
||||
test.description = 'Hello world'
|
||||
test.store()
|
||||
test = category_class.get(1)
|
||||
test = category_class.get(test.id)
|
||||
test.remove_self()
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
category_class.get(1)
|
||||
category_class.get(test.id)
|
||||
|
|
|
@ -38,14 +38,9 @@ def sql_pub():
|
|||
clean_temporary_pub()
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'two_pubs' in metafunc.fixturenames:
|
||||
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def two_pubs(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
pub.write_cfg()
|
||||
return pub
|
||||
|
@ -173,11 +168,13 @@ def test_trigger_jumps(pub):
|
|||
def run_trigger(trigger, rows):
|
||||
formdef.data_class().wipe()
|
||||
formdata = formdef.data_class()()
|
||||
formdata.id = 1
|
||||
formdata.data = {'0': 'Alice', '1': 'alice@example.net'}
|
||||
formdata.status = 'wf-%s' % st1.id
|
||||
formdata.store()
|
||||
id1 = formdata.id
|
||||
formdata = formdef.data_class()()
|
||||
formdata.id = 2
|
||||
formdata.data = {'0': 'Bob', '1': 'bob@example.net'}
|
||||
formdata.status = 'wf-%s' % st1.id
|
||||
formdata.store()
|
||||
|
|
|
@ -21,14 +21,9 @@ from .test_widgets import MockHtmlForm, mock_form_submission
|
|||
from .utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=bool('sql' in request.param))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ def base64url_encode(v):
|
|||
def setup_module(module):
|
||||
cleanup()
|
||||
global pub
|
||||
pub = create_temporary_pub()
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
|
||||
def setup_user_profile(pub):
|
||||
|
@ -347,7 +347,9 @@ def test_fc_settings_no_user_profile():
|
|||
],
|
||||
}
|
||||
|
||||
pub.cfg = {'misc': {'charset': 'utf-8'}}
|
||||
for k in list(pub.cfg.keys()):
|
||||
if k not in ('misc', 'postgresql'):
|
||||
del pub.cfg[k]
|
||||
pub.user_class.wipe()
|
||||
pub.write_cfg()
|
||||
app = get_app(pub)
|
||||
|
|
|
@ -135,8 +135,10 @@ def test_bool():
|
|||
|
||||
def test_bool_stats():
|
||||
formdef = FormDef()
|
||||
formdef.name = 'title'
|
||||
formdef.url_name = 'title'
|
||||
formdef.fields = [fields.BoolField(id='1')]
|
||||
formdef.store()
|
||||
data_class = formdef.data_class()
|
||||
formdatas = []
|
||||
for value in (True, True, True, False):
|
||||
|
|
|
@ -40,14 +40,9 @@ from wcs.workflows import (
|
|||
from .utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -28,14 +28,9 @@ from wcs.workflows import (
|
|||
from .utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
|
|
|
@ -7,14 +7,17 @@ import shutil
|
|||
import sys
|
||||
import tempfile
|
||||
import urllib.parse
|
||||
import zipfile
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from quixote import cleanup
|
||||
|
||||
from wcs import fields, sql
|
||||
from wcs.ctl.check_hobos import CmdCheckHobos
|
||||
from wcs.publisher import WcsPublisher
|
||||
from wcs.qommon import force_str
|
||||
from wcs.sql import cleanup_connection
|
||||
|
||||
from .utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
||||
|
@ -219,21 +222,52 @@ HOBO_JSON = {
|
|||
}
|
||||
|
||||
|
||||
def setup_module(module):
|
||||
global pub, hobo_cmd, alt_tempdir
|
||||
pub = create_temporary_pub()
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
@pytest.fixture
|
||||
def setuptest():
|
||||
hobo_cmd = CmdCheckHobos()
|
||||
hobo_cmd.all_services = HOBO_JSON
|
||||
alt_tempdir = tempfile.mkdtemp()
|
||||
WcsPublisher.APP_DIR = tempfile.mkdtemp()
|
||||
pub = create_temporary_pub()
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
yield pub, hobo_cmd
|
||||
cleanup_connection()
|
||||
clean_temporary_pub()
|
||||
if os.path.exists(WcsPublisher.APP_DIR):
|
||||
shutil.rmtree(WcsPublisher.APP_DIR)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def alt_tempdir():
|
||||
alt_tempdir = tempfile.mkdtemp()
|
||||
yield alt_tempdir
|
||||
shutil.rmtree(alt_tempdir)
|
||||
|
||||
|
||||
def test_configure_site_options():
|
||||
@pytest.fixture
|
||||
def deploy_setup(alt_tempdir):
|
||||
WcsPublisher.APP_DIR = alt_tempdir
|
||||
with open(os.path.join(alt_tempdir, 'hobo.json'), 'w') as fd:
|
||||
hobo_json = copy.deepcopy(HOBO_JSON)
|
||||
del hobo_json['services'][1] # authentic
|
||||
fd.write(json.dumps(HOBO_JSON))
|
||||
skeleton_dir = os.path.join(WcsPublisher.APP_DIR, 'skeletons')
|
||||
if not os.path.exists(skeleton_dir):
|
||||
os.mkdir(skeleton_dir)
|
||||
with open(os.path.join(skeleton_dir, 'export-test.wcs'), 'wb') as f:
|
||||
with zipfile.ZipFile(f, 'w') as z:
|
||||
CONFIG = {
|
||||
'postgresql': {
|
||||
'createdb-connection-params': {'database': 'postgres', 'user': os.environ['USER']},
|
||||
'database-template-name': 'wcstests_hobo_%s',
|
||||
'user': os.environ['USER'],
|
||||
}
|
||||
}
|
||||
z.writestr('config.json', json.dumps(CONFIG))
|
||||
|
||||
|
||||
def test_configure_site_options(setuptest, alt_tempdir):
|
||||
pub, hobo_cmd = setuptest
|
||||
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0]
|
||||
hobo_cmd.configure_site_options(service, pub)
|
||||
pub.load_site_options()
|
||||
|
@ -257,7 +291,8 @@ def test_configure_site_options():
|
|||
assert pub.get_site_option('xxx', 'variables') is None
|
||||
|
||||
|
||||
def test_update_configuration():
|
||||
def test_update_configuration(setuptest):
|
||||
pub, hobo_cmd = setuptest
|
||||
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0]
|
||||
hobo_cmd.update_configuration(service, pub)
|
||||
assert pub.cfg['misc']['sitename'] == 'Test wcs'
|
||||
|
@ -268,7 +303,8 @@ def test_update_configuration():
|
|||
assert pub.cfg['sms']['sender'] == 'EO'
|
||||
|
||||
|
||||
def test_update_themes():
|
||||
def test_update_themes(setuptest):
|
||||
pub, hobo_cmd = setuptest
|
||||
pub.cfg['branding'] = {'theme': 'default'}
|
||||
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0]
|
||||
hobo_cmd.update_configuration(service, pub)
|
||||
|
@ -300,7 +336,8 @@ def test_update_themes():
|
|||
)
|
||||
|
||||
|
||||
def test_update_profile():
|
||||
def test_update_profile(setuptest):
|
||||
pub, hobo_cmd = setuptest
|
||||
profile = HOBO_JSON.get('profile')
|
||||
|
||||
# load in an empty site
|
||||
|
@ -366,12 +403,14 @@ def test_update_profile():
|
|||
assert attribute_mapping[attribute_name] == field_id
|
||||
|
||||
|
||||
def test_configure_authentication_methods(http_requests):
|
||||
def test_configure_authentication_methods(setuptest, http_requests):
|
||||
pub, hobo_cmd = setuptest
|
||||
pub.cfg['idp'] = {}
|
||||
service = [x for x in HOBO_JSON.get('services', []) if x.get('service-id') == 'wcs'][0]
|
||||
|
||||
# with real metadata
|
||||
hobo_cmd.configure_authentication_methods(service, pub)
|
||||
hobo_cmd.configure_site_options(service, pub)
|
||||
|
||||
idp_keys = list(pub.cfg['idp'].keys())
|
||||
assert len(idp_keys) == 1
|
||||
|
@ -415,13 +454,10 @@ def test_configure_authentication_methods(http_requests):
|
|||
hobo_cmd.all_services = HOBO_JSON
|
||||
|
||||
|
||||
def test_deploy():
|
||||
def test_deploy(setuptest, alt_tempdir, deploy_setup):
|
||||
dummy, hobo_cmd = setuptest
|
||||
cleanup_connection()
|
||||
cleanup()
|
||||
WcsPublisher.APP_DIR = alt_tempdir
|
||||
with open(os.path.join(alt_tempdir, 'hobo.json'), 'w') as fd:
|
||||
hobo_json = copy.deepcopy(HOBO_JSON)
|
||||
del hobo_json['services'][1] # authentic
|
||||
fd.write(json.dumps(HOBO_JSON))
|
||||
hobo_cmd = CmdCheckHobos()
|
||||
base_options = {}
|
||||
sub_options_class = collections.namedtuple('Options', ['ignore_timestamp', 'redeploy', 'extra'])
|
||||
|
@ -433,6 +469,7 @@ def test_deploy():
|
|||
assert os.path.exists(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net'))
|
||||
|
||||
# update
|
||||
cleanup_connection()
|
||||
cleanup()
|
||||
with open(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net', 'config.pck'), 'rb') as fd:
|
||||
pub_cfg = pickle.load(fd)
|
||||
|
@ -450,9 +487,9 @@ def test_deploy():
|
|||
assert pub_cfg['language'] == {'language': 'fr'}
|
||||
|
||||
|
||||
def test_configure_postgresql():
|
||||
def test_configure_postgresql(setuptest, alt_tempdir, deploy_setup):
|
||||
cleanup_connection()
|
||||
cleanup()
|
||||
WcsPublisher.APP_DIR = alt_tempdir
|
||||
with open(os.path.join(alt_tempdir, 'hobo.json'), 'w') as fd:
|
||||
hobo_json = copy.deepcopy(HOBO_JSON)
|
||||
del hobo_json['services'][1] # authentic
|
||||
|
@ -470,10 +507,7 @@ def test_configure_postgresql():
|
|||
)
|
||||
assert os.path.exists(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net'))
|
||||
|
||||
with open(os.path.join(alt_tempdir, 'tenants', 'wcs.example.net', 'site-options.cfg'), 'w') as fd:
|
||||
fd.write('[options]\n')
|
||||
fd.write('postgresql = true\n')
|
||||
|
||||
cleanup_connection()
|
||||
cleanup()
|
||||
|
||||
pub = WcsPublisher.create_publisher(register_tld_names=False)
|
||||
|
|
|
@ -13,14 +13,9 @@ from wcs.qommon.http_request import HTTPRequest
|
|||
from .utilities import create_temporary_pub, get_app
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub()
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -111,7 +111,8 @@ def setuptest():
|
|||
yield pub, hobo_cmd
|
||||
|
||||
clean_temporary_pub()
|
||||
shutil.rmtree(WcsPublisher.APP_DIR)
|
||||
if os.path.exists(WcsPublisher.APP_DIR):
|
||||
shutil.rmtree(WcsPublisher.APP_DIR)
|
||||
cleanup_connection()
|
||||
for dbname in (WCS_DB_NAME, NEW_WCS_DB_NAME):
|
||||
cursor.execute('DROP DATABASE IF EXISTS %s' % dbname)
|
||||
|
|
|
@ -26,8 +26,8 @@ def setup_module(module):
|
|||
def user(request):
|
||||
pub.user_class.wipe()
|
||||
user = pub.user_class(name='user')
|
||||
user.id = 'user'
|
||||
user.email = 'test@example.net'
|
||||
user.store()
|
||||
get_request()._user = user
|
||||
return user
|
||||
|
||||
|
|
|
@ -237,6 +237,9 @@ def test_cron_command(settings):
|
|||
for hostname in hostnames:
|
||||
if not os.path.exists(os.path.join(pub.APP_DIR, hostname)):
|
||||
os.mkdir(os.path.join(pub.APP_DIR, hostname))
|
||||
# add a config.pck with postgresql configuration
|
||||
with open(os.path.join(pub.APP_DIR, hostname, 'config.pck'), 'wb') as fd:
|
||||
pickle.dump(pub.cfg, file=fd)
|
||||
|
||||
with mock.patch('wcs.qommon.management.commands.cron.cron_worker') as cron_worker:
|
||||
with mock.patch('wcs.qommon.publisher.QommonPublisher.get_tenants') as mock_tenants:
|
||||
|
@ -557,7 +560,7 @@ def test_clean_thumbnails():
|
|||
|
||||
|
||||
def test_clean_loggederrors_no_sql():
|
||||
pub = create_temporary_pub()
|
||||
pub = create_temporary_pub(sql_mode=False)
|
||||
|
||||
# do nothing, no error
|
||||
pub.clean_loggederrors()
|
||||
|
|
|
@ -10,14 +10,9 @@ from wcs.qommon.ident.password_accounts import PasswordAccount
|
|||
from .utilities import clean_temporary_pub, create_temporary_pub, get_app
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
|
||||
pub.set_app_dir(req)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import pickle
|
||||
|
||||
from quixote import get_publisher
|
||||
|
||||
from wcs import sql
|
||||
|
|
|
@ -58,7 +58,8 @@ def teardown_module(module):
|
|||
|
||||
|
||||
def indexhtml(user=None):
|
||||
req._user = req.session.user = user
|
||||
req._user = user
|
||||
req.session.user = user.id if user else None
|
||||
return str(wcs.forms.root.RootDirectory()._q_index())
|
||||
|
||||
|
||||
|
|
|
@ -43,14 +43,9 @@ role_uuid1 = str(uuid.uuid4())
|
|||
role_uuid2 = str(uuid.uuid4())
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
if not pub.cfg:
|
||||
pub.cfg = {}
|
||||
|
|
|
@ -22,14 +22,9 @@ def teardown_module():
|
|||
pass
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def pub(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub()
|
||||
|
||||
def fin():
|
||||
shutil.rmtree(pub.APP_DIR)
|
||||
|
|
|
@ -2253,9 +2253,7 @@ def test_logged_error_store_without_integrity_error(pub, sql_queries):
|
|||
assert 'UPDATE' in sql_queries[1]
|
||||
|
||||
|
||||
def test_sql_import_zip_create_tables():
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
|
||||
def test_sql_import_zip_create_tables(pub):
|
||||
c = io.BytesIO()
|
||||
with zipfile.ZipFile(c, 'w') as z:
|
||||
z.writestr(
|
||||
|
|
|
@ -11,21 +11,11 @@ from wcs.qommon.tokens import Token
|
|||
from .utilities import create_temporary_pub
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'two_pubs' in metafunc.fixturenames:
|
||||
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
return create_temporary_pub(sql_mode=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def two_pubs(request):
|
||||
return create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
|
||||
|
||||
def test_migrate_to_sql(pub):
|
||||
get_publisher().token_class.wipe()
|
||||
assert get_publisher().token_class.count() == 0
|
||||
|
@ -52,7 +42,7 @@ def test_migrate_to_sql(pub):
|
|||
assert sql_token.expiration.year == now().year
|
||||
|
||||
|
||||
def test_expiration(two_pubs):
|
||||
def test_expiration(pub):
|
||||
get_publisher().token_class.wipe()
|
||||
token = get_publisher().token_class()
|
||||
token.store()
|
||||
|
@ -64,7 +54,7 @@ def test_expiration(two_pubs):
|
|||
assert get_publisher().token_class().get(token.id)
|
||||
|
||||
|
||||
def test_clean_job(two_pubs):
|
||||
def test_clean_job(pub):
|
||||
get_publisher().token_class.wipe()
|
||||
token = get_publisher().token_class()
|
||||
token.store()
|
||||
|
|
|
@ -5,14 +5,9 @@ from wcs.formdef import FormDef
|
|||
from .utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
return create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
return create_temporary_pub(sql_mode=True)
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
|
|
|
@ -17,7 +17,7 @@ from .utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
|||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'pub' in metafunc.fixturenames:
|
||||
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-lazy'], indirect=True)
|
||||
metafunc.parametrize('pub', ['sql', 'sql-lazy'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -43,7 +43,7 @@ class KnownElements:
|
|||
known_elements = KnownElements()
|
||||
|
||||
|
||||
def create_temporary_pub(sql_mode=False, legacy_theme_mode=False, lazy_mode=False):
|
||||
def create_temporary_pub(sql_mode=True, legacy_theme_mode=False, lazy_mode=False):
|
||||
if get_publisher():
|
||||
get_publisher().cleanup()
|
||||
cleanup()
|
||||
|
@ -51,7 +51,7 @@ def create_temporary_pub(sql_mode=False, legacy_theme_mode=False, lazy_mode=Fals
|
|||
APP_DIR = known_elements.legacy_theme_app_dir
|
||||
elif lazy_mode and known_elements.lazy_app_dir:
|
||||
APP_DIR = known_elements.lazy_app_dir
|
||||
elif sql_mode and known_elements.sql_app_dir:
|
||||
elif sql_mode and known_elements.sql_app_dir and not lazy_mode:
|
||||
APP_DIR = known_elements.sql_app_dir
|
||||
elif not (legacy_theme_mode or lazy_mode or sql_mode) and known_elements.pickle_app_dir:
|
||||
APP_DIR = known_elements.pickle_app_dir
|
||||
|
@ -61,7 +61,7 @@ def create_temporary_pub(sql_mode=False, legacy_theme_mode=False, lazy_mode=Fals
|
|||
known_elements.legacy_theme_app_dir = APP_DIR
|
||||
elif lazy_mode:
|
||||
known_elements.lazy_app_dir = APP_DIR
|
||||
elif sql_mode:
|
||||
elif sql_mode and not lazy_mode:
|
||||
known_elements.sql_app_dir = APP_DIR
|
||||
else:
|
||||
known_elements.pickle_app_dir = APP_DIR
|
||||
|
|
|
@ -92,11 +92,6 @@ def teardown_module(module):
|
|||
clean_temporary_pub()
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'two_pubs' in metafunc.fixturenames:
|
||||
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
def pub_fixture(**kwargs):
|
||||
pub = create_temporary_pub(**kwargs)
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
|
@ -118,7 +113,7 @@ def pub(request):
|
|||
|
||||
@pytest.fixture
|
||||
def two_pubs(request):
|
||||
return pub_fixture(sql_mode=(request.param == 'sql'))
|
||||
return pub_fixture(sql_mode=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -1446,8 +1441,10 @@ def test_register_comment_to(pub):
|
|||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'foobar'
|
||||
formdef.url_name = 'foobar'
|
||||
formdef._workflow = workflow
|
||||
formdef.store()
|
||||
|
||||
formdata = formdef.data_class()()
|
||||
formdata.just_created()
|
||||
|
@ -1545,6 +1542,7 @@ def test_register_comment_to_with_attachment(pub):
|
|||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'foobar'
|
||||
formdef.url_name = 'foobar'
|
||||
formdef.fields = [
|
||||
FileField(id='1', label='File1', type='file', varname='file1'),
|
||||
|
@ -3113,8 +3111,10 @@ def test_workflow_display_message_to(pub):
|
|||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'foobar'
|
||||
formdef.url_name = 'foobar'
|
||||
formdef._workflow = workflow
|
||||
formdef.store()
|
||||
|
||||
formdata = formdef.data_class()()
|
||||
formdata.status = 'wf-st1'
|
||||
|
@ -3934,6 +3934,7 @@ def test_export_to_model_form_details_section(pub, filename):
|
|||
]
|
||||
block.store()
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'foo-export-details'
|
||||
formdef.fields = [
|
||||
|
@ -3947,12 +3948,12 @@ def test_export_to_model_form_details_section(pub, filename):
|
|||
FileField(id='9', label='File', type='file'),
|
||||
DateField(id='10', label='Date', type='date'),
|
||||
ItemField(id='11', label='Item', type='item', items=['foo', 'bar']),
|
||||
ItemsField(id='11', label='Items', type='items', items=['foo', 'bar']),
|
||||
TableField(id='12', label='Table', type='table', columns=['a', 'b'], rows=['c', 'd']),
|
||||
PageField(id='13', label='Empty Page', type='page'),
|
||||
TitleField(id='14', label='Empty Title', type='title'),
|
||||
StringField(id='15', label='Empty String', type='string', varname='invisiblestr'),
|
||||
BlockField(id='16', label='Block Field', type='block:foobar'),
|
||||
ItemsField(id='17', label='Items', type='items', items=['foo', 'bar']),
|
||||
]
|
||||
formdef.store()
|
||||
formdef.data_class().wipe()
|
||||
|
@ -6417,7 +6418,7 @@ def test_call_external_workflow_with_parent_object(pub):
|
|||
# run, against no parent
|
||||
perform_items([update_action], formdata)
|
||||
card = carddef.data_class().get(carddata.id)
|
||||
assert 'bo0' not in card.data # not called
|
||||
assert not card.data.get('bo0') # not called
|
||||
|
||||
# other parent
|
||||
formdata.submission_context = {
|
||||
|
@ -6428,7 +6429,7 @@ def test_call_external_workflow_with_parent_object(pub):
|
|||
formdata.store()
|
||||
perform_items([update_action], formdata)
|
||||
card = carddef.data_class().get(carddata.id)
|
||||
assert 'bo0' not in card.data # not called
|
||||
assert not card.data.get('bo0') # not called
|
||||
|
||||
# appropriate parent
|
||||
formdata.submission_context = {
|
||||
|
@ -6501,7 +6502,7 @@ def test_call_external_workflow_use_caller_variable(pub):
|
|||
# run, against no parent
|
||||
perform_items([update_action], formdata)
|
||||
card = carddef.data_class().get(carddata.id)
|
||||
assert 'bo0' not in card.data # not called
|
||||
assert not card.data.get('bo0') # not called
|
||||
|
||||
# appropriate parent
|
||||
formdata.submission_context = {
|
||||
|
|
|
@ -24,11 +24,6 @@ def teardown_module(module):
|
|||
clean_temporary_pub()
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'two_pubs' in metafunc.fixturenames:
|
||||
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub()
|
||||
|
@ -45,7 +40,7 @@ def pub(request):
|
|||
|
||||
@pytest.fixture
|
||||
def two_pubs(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
pub.write_cfg()
|
||||
req = HTTPRequest(None, {'SERVER_NAME': 'example.net', 'SCRIPT_NAME': ''})
|
||||
|
@ -202,8 +197,8 @@ def test_create_carddata_with_links(pub):
|
|||
|
||||
assert carddef1.data_class().count() == 1
|
||||
assert carddef2.data_class().count() == 1
|
||||
carddata1 = carddef1.data_class().get(id=1)
|
||||
carddata2 = carddef2.data_class().get(id=1)
|
||||
carddata1 = carddef1.data_class().select()[0]
|
||||
carddata2 = carddef2.data_class().select()[0]
|
||||
assert carddata1.data['1'] == 'card1 foo'
|
||||
assert carddata2.data['1'] == 'card2 bar'
|
||||
assert carddata2.data['2'] == str(carddata1.id)
|
||||
|
@ -225,8 +220,8 @@ def test_create_carddata_with_links(pub):
|
|||
|
||||
assert carddef1.data_class().count() == 1
|
||||
assert carddef2.data_class().count() == 1
|
||||
carddata1 = carddef1.data_class().get(id=1)
|
||||
carddata2 = carddef2.data_class().get(id=1)
|
||||
carddata1 = carddef1.data_class().select()[0]
|
||||
carddata2 = carddef2.data_class().select()[0]
|
||||
assert carddata1.data['1'] == 'card1 fooo'
|
||||
assert carddata2.data['1'] == 'card2 barr'
|
||||
assert carddata2.data['2'] == str(carddata1.id)
|
||||
|
@ -259,8 +254,8 @@ def test_create_carddata_with_links(pub):
|
|||
|
||||
assert carddef1.data_class().count() == 1
|
||||
assert carddef2.data_class().count() == 1
|
||||
carddata1 = carddef1.data_class().get(id=1)
|
||||
carddata2 = carddef2.data_class().get(id=1)
|
||||
carddata1 = carddef1.data_class().select()[0]
|
||||
carddata2 = carddef2.data_class().select()[0]
|
||||
assert carddata1.data['1'] == 'card1 fooo'
|
||||
assert carddata2.data['1'] == 'card2 barr'
|
||||
assert carddata2.data['2'] == str(carddata1.id)
|
||||
|
@ -269,8 +264,8 @@ def test_create_carddata_with_links(pub):
|
|||
|
||||
assert carddef1.data_class().count() == 2
|
||||
assert carddef2.data_class().count() == 2
|
||||
carddata1 = carddef1.data_class().get(id=2)
|
||||
carddata2 = carddef2.data_class().get(id=2)
|
||||
carddata1 = carddef1.data_class().select(order_by='id')[-1]
|
||||
carddata2 = carddef2.data_class().select(order_by='id')[-1]
|
||||
assert carddata1.data['1'] == 'card1 fooo'
|
||||
assert carddata2.data['1'] == 'card2 barr'
|
||||
assert carddata2.data['2'] == str(carddata1.id)
|
||||
|
@ -292,8 +287,8 @@ def test_create_carddata_with_links(pub):
|
|||
|
||||
assert carddef1.data_class().count() == 1
|
||||
assert carddef2.data_class().count() == 1
|
||||
carddata1 = carddef1.data_class().get(id=1)
|
||||
carddata2 = carddef2.data_class().get(id=1)
|
||||
carddata1 = carddef1.data_class().select()[0]
|
||||
carddata2 = carddef2.data_class().select()[0]
|
||||
assert carddata1.data['1'] == 'card1 fooo'
|
||||
assert carddata2.data['1'] == 'card2 barr'
|
||||
assert carddata2.data['2'] == str(carddata1.id)
|
||||
|
@ -315,8 +310,8 @@ def test_create_carddata_with_links(pub):
|
|||
|
||||
assert carddef1.data_class().count() == 1
|
||||
assert carddef2.data_class().count() == 1
|
||||
carddata1 = carddef1.data_class().get(id=1)
|
||||
carddata2 = carddef2.data_class().get(id=1)
|
||||
carddata1 = carddef1.data_class().select()[0]
|
||||
carddata2 = carddef2.data_class().select()[0]
|
||||
assert carddata1.data['1'] == 'card1 fooo'
|
||||
assert carddata2.data['1'] == 'card2 barr'
|
||||
assert carddata2.data['2'] == str(carddata1.id)
|
||||
|
@ -1084,7 +1079,7 @@ def test_assign_carddata_with_data_sourced_object(pub):
|
|||
formdata.perform_workflow()
|
||||
|
||||
data = carddef.data_class().select()[0]
|
||||
assert data.user_id == user.id
|
||||
assert str(data.user_id) == str(user.id)
|
||||
|
||||
|
||||
def test_assign_carddata_with_linked_object(pub):
|
||||
|
@ -1143,7 +1138,7 @@ def test_assign_carddata_with_linked_object(pub):
|
|||
|
||||
assert carddef.data_class().count() == 1
|
||||
card_data = carddef.data_class().select()[0]
|
||||
assert card_data.user_id == user.id
|
||||
assert str(card_data.user_id) == str(user.id)
|
||||
|
||||
|
||||
def test_assign_carddata_manual_targeting(two_pubs):
|
||||
|
@ -1380,7 +1375,7 @@ def test_assign_carddata_targeting_itself(pub):
|
|||
# run workflow, verify that carddata is assign
|
||||
carddata.just_created()
|
||||
carddata.perform_workflow()
|
||||
assert carddata.user_id == user.id
|
||||
assert str(carddata.user_id) == str(user.id)
|
||||
assert carddata.status == 'wf-%s' % st2.id
|
||||
|
||||
|
||||
|
@ -1443,11 +1438,11 @@ def test_assign_carddata_from_created_object(pub):
|
|||
carddata.store()
|
||||
carddata.just_created()
|
||||
carddata.perform_workflow()
|
||||
assert carddata.user_id == user.id
|
||||
assert str(carddata.user_id) == str(user.id)
|
||||
|
||||
carddata_reloaded = carddata.get(carddata.id)
|
||||
assert carddata_reloaded.status == 'wf-2'
|
||||
assert carddata_reloaded.user_id == user.id
|
||||
assert str(carddata_reloaded.user_id) == str(user.id)
|
||||
|
||||
|
||||
def test_assign_carddata_user_association(two_pubs):
|
||||
|
|
|
@ -20,11 +20,6 @@ def teardown_module(module):
|
|||
clean_temporary_pub()
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'two_pubs' in metafunc.fixturenames:
|
||||
metafunc.parametrize('two_pubs', ['pickle', 'sql'], indirect=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pub(request):
|
||||
pub = create_temporary_pub()
|
||||
|
@ -41,7 +36,7 @@ def pub(request):
|
|||
|
||||
@pytest.fixture
|
||||
def two_pubs(request):
|
||||
pub = create_temporary_pub(sql_mode=(request.param == 'sql'))
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
pub.cfg['language'] = {'language': 'en'}
|
||||
pub.write_cfg()
|
||||
req = HTTPRequest(None, {'SERVER_NAME': 'example.net', 'SCRIPT_NAME': ''})
|
||||
|
|
|
@ -301,6 +301,7 @@ def test_notifications_target_url(sql_pub, http_requests):
|
|||
formdata.just_created()
|
||||
formdata.store()
|
||||
|
||||
pub.load_site_options()
|
||||
if not pub.site_options.has_section('variables'):
|
||||
pub.site_options.add_section('variables')
|
||||
pub.site_options.set('variables', 'portal_url', 'https://portal/')
|
||||
|
|
|
@ -564,9 +564,6 @@ class CmdCheckHobos(Command):
|
|||
if not pub.cfg.get('postgresql'):
|
||||
return
|
||||
|
||||
if not pub.has_site_option('postgresql'):
|
||||
return
|
||||
|
||||
import psycopg2
|
||||
import psycopg2.errorcodes
|
||||
|
||||
|
|
Loading…
Reference in New Issue