From cf16fd3d4fd22dfaf7db7cf188778837b1de2d6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Sun, 10 Jul 2022 11:38:24 +0200
Subject: [PATCH 4/7] tests: stop running most tests with pickle storage
 (#67190)

---
 tests/admin_pages/test_card.py                | 27 ------
 tests/admin_pages/test_datasource.py          | 17 ----
 tests/admin_pages/test_form.py                | 80 ------------------
 tests/api/test_access.py                      |  7 +-
 tests/api/test_all.py                         |  7 +-
 tests/api/test_carddef.py                     |  7 +-
 tests/api/test_category.py                    |  7 +-
 tests/api/test_custom_view.py                 |  7 +-
 tests/api/test_formdata.py                    |  7 +-
 tests/api/test_formdef.py                     |  7 +-
 tests/api/test_statistics.py                  |  5 --
 tests/api/test_user.py                        |  7 +-
 tests/api/test_workflow.py                    |  7 +-
 tests/backoffice_pages/test_all.py            |  7 +-
 tests/backoffice_pages/test_carddata.py       |  7 +-
 tests/backoffice_pages/test_columns.py        |  7 +-
 tests/backoffice_pages/test_custom_view.py    |  7 +-
 tests/backoffice_pages/test_export.py         |  7 +-
 tests/backoffice_pages/test_filters.py        |  7 +-
 tests/backoffice_pages/test_form_inspect.py   |  7 +-
 tests/backoffice_pages/test_statistics.py     |  7 +-
 tests/backoffice_pages/test_submission.py     |  7 +-
 .../backoffice_pages/test_workflow_inspect.py |  7 +-
 tests/form_pages/test_all.py                  |  4 +-
 tests/form_pages/test_block.py                |  2 +-
 tests/form_pages/test_computed_field.py       | 10 +--
 tests/form_pages/test_file_field.py           |  2 +-
 tests/form_pages/test_formdata.py             |  2 +-
 tests/form_pages/test_live.py                 |  2 +-
 tests/test_auth_pages.py                      |  2 +-
 tests/test_carddef.py                         |  7 +-
 tests/test_categories.py                      | 16 ++--
 tests/test_ctl.py                             |  9 +-
 tests/test_datasource.py                      |  7 +-
 tests/test_fc_auth.py                         |  6 +-
 tests/test_fields.py                          |  2 +
 tests/test_formdata.py                        |  7 +-
 tests/test_formdef.py                         |  7 +-
 tests/test_hobo.py                            | 82 +++++++++++++------
 tests/test_hobo_notify.py                     |  7 +-
 tests/test_hobo_sql.py                        |  3 +-
 tests/test_prefill.py                         |  2 +-
 tests/test_publisher.py                       |  5 +-
 tests/test_register.py                        |  7 +-
 tests/test_role.py                            |  2 -
 tests/test_rootdirectory.py                   |  3 +-
 tests/test_saml_auth.py                       |  7 +-
 tests/test_sessions.py                        |  7 +-
 tests/test_sql.py                             |  4 +-
 tests/test_token.py                           | 14 +---
 tests/test_tracking_code.py                   |  7 +-
 tests/test_upload_storage.py                  |  2 +-
 tests/utilities.py                            |  6 +-
 tests/workflow/test_all.py                    | 21 ++---
 tests/workflow/test_carddata.py               | 41 ++++------
 tests/workflow/test_formdata.py               |  7 +-
 tests/workflow/test_notification.py           |  1 +
 wcs/ctl/check_hobos.py                        |  3 -
 58 files changed, 156 insertions(+), 422 deletions(-)

diff --git a/tests/admin_pages/test_card.py b/tests/admin_pages/test_card.py
index 35a9da1c7..41af43669 100644
--- a/tests/admin_pages/test_card.py
+++ b/tests/admin_pages/test_card.py
@@ -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()
diff --git a/tests/admin_pages/test_datasource.py b/tests/admin_pages/test_datasource.py
index d7f756eaf..6e77ae10a 100644
--- a/tests/admin_pages/test_datasource.py
+++ b/tests/admin_pages/test_datasource.py
@@ -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()
diff --git a/tests/admin_pages/test_form.py b/tests/admin_pages/test_form.py
index 0391c8fea..f2ea424d8 100644
--- a/tests/admin_pages/test_form.py
+++ b/tests/admin_pages/test_form.py
@@ -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)
diff --git a/tests/api/test_access.py b/tests/api/test_access.py
index f45433f23..0ee91d382 100644
--- a/tests/api/test_access.py
+++ b/tests/api/test_access.py
@@ -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)
diff --git a/tests/api/test_all.py b/tests/api/test_all.py
index e2caddc5e..4df7c7a0b 100644
--- a/tests/api/test_all.py
+++ b/tests/api/test_all.py
@@ -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)
diff --git a/tests/api/test_carddef.py b/tests/api/test_carddef.py
index b110c1c96..b24a66672 100644
--- a/tests/api/test_carddef.py
+++ b/tests/api/test_carddef.py
@@ -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)
diff --git a/tests/api/test_category.py b/tests/api/test_category.py
index d0eeae010..d311f3c03 100644
--- a/tests/api/test_category.py
+++ b/tests/api/test_category.py
@@ -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)
diff --git a/tests/api/test_custom_view.py b/tests/api/test_custom_view.py
index c1ecffeaf..d55134267 100644
--- a/tests/api/test_custom_view.py
+++ b/tests/api/test_custom_view.py
@@ -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)
diff --git a/tests/api/test_formdata.py b/tests/api/test_formdata.py
index 5ed6d2865..dad4ea7f2 100644
--- a/tests/api/test_formdata.py
+++ b/tests/api/test_formdata.py
@@ -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)
diff --git a/tests/api/test_formdef.py b/tests/api/test_formdef.py
index c2774e8b4..ee26b5300 100644
--- a/tests/api/test_formdef.py
+++ b/tests/api/test_formdef.py
@@ -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)
diff --git a/tests/api/test_statistics.py b/tests/api/test_statistics.py
index 73121347e..5ec55e39b 100644
--- a/tests/api/test_statistics.py
+++ b/tests/api/test_statistics.py
@@ -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()
diff --git a/tests/api/test_user.py b/tests/api/test_user.py
index 43419176f..f9d84863c 100644
--- a/tests/api/test_user.py
+++ b/tests/api/test_user.py
@@ -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)
diff --git a/tests/api/test_workflow.py b/tests/api/test_workflow.py
index 6d0e593be..3520ca623 100644
--- a/tests/api/test_workflow.py
+++ b/tests/api/test_workflow.py
@@ -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)
diff --git a/tests/backoffice_pages/test_all.py b/tests/backoffice_pages/test_all.py
index 6b32b64c4..e9fb9e225 100644
--- a/tests/backoffice_pages/test_all.py
+++ b/tests/backoffice_pages/test_all.py
@@ -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)
diff --git a/tests/backoffice_pages/test_carddata.py b/tests/backoffice_pages/test_carddata.py
index b24a69127..5c84db643 100644
--- a/tests/backoffice_pages/test_carddata.py
+++ b/tests/backoffice_pages/test_carddata.py
@@ -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)
diff --git a/tests/backoffice_pages/test_columns.py b/tests/backoffice_pages/test_columns.py
index f0a78d5da..1feea54de 100644
--- a/tests/backoffice_pages/test_columns.py
+++ b/tests/backoffice_pages/test_columns.py
@@ -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)
diff --git a/tests/backoffice_pages/test_custom_view.py b/tests/backoffice_pages/test_custom_view.py
index 7af0dcd75..3189761e8 100644
--- a/tests/backoffice_pages/test_custom_view.py
+++ b/tests/backoffice_pages/test_custom_view.py
@@ -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)
diff --git a/tests/backoffice_pages/test_export.py b/tests/backoffice_pages/test_export.py
index 6983fca01..e3f282c5b 100644
--- a/tests/backoffice_pages/test_export.py
+++ b/tests/backoffice_pages/test_export.py
@@ -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)
diff --git a/tests/backoffice_pages/test_filters.py b/tests/backoffice_pages/test_filters.py
index 743066a85..6a88f65b1 100644
--- a/tests/backoffice_pages/test_filters.py
+++ b/tests/backoffice_pages/test_filters.py
@@ -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)
diff --git a/tests/backoffice_pages/test_form_inspect.py b/tests/backoffice_pages/test_form_inspect.py
index 42c7b1189..7e15e4419 100644
--- a/tests/backoffice_pages/test_form_inspect.py
+++ b/tests/backoffice_pages/test_form_inspect.py
@@ -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']}
diff --git a/tests/backoffice_pages/test_statistics.py b/tests/backoffice_pages/test_statistics.py
index 4650ad02d..8205c5b9d 100644
--- a/tests/backoffice_pages/test_statistics.py
+++ b/tests/backoffice_pages/test_statistics.py
@@ -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)
diff --git a/tests/backoffice_pages/test_submission.py b/tests/backoffice_pages/test_submission.py
index 0b0b7c824..a848d9007 100644
--- a/tests/backoffice_pages/test_submission.py
+++ b/tests/backoffice_pages/test_submission.py
@@ -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)
diff --git a/tests/backoffice_pages/test_workflow_inspect.py b/tests/backoffice_pages/test_workflow_inspect.py
index 3df90b670..f3ac04004 100644
--- a/tests/backoffice_pages/test_workflow_inspect.py
+++ b/tests/backoffice_pages/test_workflow_inspect.py
@@ -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']}
diff --git a/tests/form_pages/test_all.py b/tests/form_pages/test_all.py
index d82761529..0f6cdd9be 100644
--- a/tests/form_pages/test_all.py
+++ b/tests/form_pages/test_all.py
@@ -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
diff --git a/tests/form_pages/test_block.py b/tests/form_pages/test_block.py
index 928ad5c70..f07d93a16 100644
--- a/tests/form_pages/test_block.py
+++ b/tests/form_pages/test_block.py
@@ -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
diff --git a/tests/form_pages/test_computed_field.py b/tests/form_pages/test_computed_field.py
index f9f28b5e9..9f3fc8f3b 100644
--- a/tests/form_pages/test_computed_field.py
+++ b/tests/form_pages/test_computed_field.py
@@ -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()
diff --git a/tests/form_pages/test_file_field.py b/tests/form_pages/test_file_field.py
index e6de9dcd9..27f3c81ec 100644
--- a/tests/form_pages/test_file_field.py
+++ b/tests/form_pages/test_file_field.py
@@ -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
diff --git a/tests/form_pages/test_formdata.py b/tests/form_pages/test_formdata.py
index 8bacab855..13ef1e668 100644
--- a/tests/form_pages/test_formdata.py
+++ b/tests/form_pages/test_formdata.py
@@ -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
diff --git a/tests/form_pages/test_live.py b/tests/form_pages/test_live.py
index c4a847be8..e88d98d87 100644
--- a/tests/form_pages/test_live.py
+++ b/tests/form_pages/test_live.py
@@ -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
diff --git a/tests/test_auth_pages.py b/tests/test_auth_pages.py
index bdb3b976b..6603826b3 100644
--- a/tests/test_auth_pages.py
+++ b/tests/test_auth_pages.py
@@ -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()
diff --git a/tests/test_carddef.py b/tests/test_carddef.py
index f0e1fe863..bd18d660e 100644
--- a/tests/test_carddef.py
+++ b/tests/test_carddef.py
@@ -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'}
diff --git a/tests/test_categories.py b/tests/test_categories.py
index 8ad635280..63b185486 100644
--- a/tests/test_categories.py
+++ b/tests/test_categories.py
@@ -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)
diff --git a/tests/test_ctl.py b/tests/test_ctl.py
index 69be165ea..6f2af81ce 100644
--- a/tests/test_ctl.py
+++ b/tests/test_ctl.py
@@ -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()
diff --git a/tests/test_datasource.py b/tests/test_datasource.py
index 5bb70b036..99f02ecbd 100644
--- a/tests/test_datasource.py
+++ b/tests/test_datasource.py
@@ -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)
 
diff --git a/tests/test_fc_auth.py b/tests/test_fc_auth.py
index 645d32548..b5e2db8f6 100644
--- a/tests/test_fc_auth.py
+++ b/tests/test_fc_auth.py
@@ -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)
diff --git a/tests/test_fields.py b/tests/test_fields.py
index 3606cba70..1617cafbb 100644
--- a/tests/test_fields.py
+++ b/tests/test_fields.py
@@ -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):
diff --git a/tests/test_formdata.py b/tests/test_formdata.py
index 8f89f6685..122791879 100644
--- a/tests/test_formdata.py
+++ b/tests/test_formdata.py
@@ -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)
diff --git a/tests/test_formdef.py b/tests/test_formdef.py
index 147aec02e..0311eaf16 100644
--- a/tests/test_formdef.py
+++ b/tests/test_formdef.py
@@ -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'}
diff --git a/tests/test_hobo.py b/tests/test_hobo.py
index f1dfd978a..8710b3ff3 100644
--- a/tests/test_hobo.py
+++ b/tests/test_hobo.py
@@ -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)
diff --git a/tests/test_hobo_notify.py b/tests/test_hobo_notify.py
index 2f730f36b..551df1e3a 100644
--- a/tests/test_hobo_notify.py
+++ b/tests/test_hobo_notify.py
@@ -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)
diff --git a/tests/test_hobo_sql.py b/tests/test_hobo_sql.py
index 93de62ca4..ec6f8533b 100644
--- a/tests/test_hobo_sql.py
+++ b/tests/test_hobo_sql.py
@@ -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)
diff --git a/tests/test_prefill.py b/tests/test_prefill.py
index 5b8db4e95..d7cbc3322 100644
--- a/tests/test_prefill.py
+++ b/tests/test_prefill.py
@@ -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
 
diff --git a/tests/test_publisher.py b/tests/test_publisher.py
index f61ed682b..4c71b6aa2 100644
--- a/tests/test_publisher.py
+++ b/tests/test_publisher.py
@@ -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()
diff --git a/tests/test_register.py b/tests/test_register.py
index cb03928d9..eb50992ce 100644
--- a/tests/test_register.py
+++ b/tests/test_register.py
@@ -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)
diff --git a/tests/test_role.py b/tests/test_role.py
index b0d89f05b..5cb76f28e 100644
--- a/tests/test_role.py
+++ b/tests/test_role.py
@@ -1,5 +1,3 @@
-import pickle
-
 from quixote import get_publisher
 
 from wcs import sql
diff --git a/tests/test_rootdirectory.py b/tests/test_rootdirectory.py
index 6343e4cd9..601374ec7 100644
--- a/tests/test_rootdirectory.py
+++ b/tests/test_rootdirectory.py
@@ -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())
 
 
diff --git a/tests/test_saml_auth.py b/tests/test_saml_auth.py
index 713eb0776..d111d558d 100644
--- a/tests/test_saml_auth.py
+++ b/tests/test_saml_auth.py
@@ -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 = {}
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index ab113d004..43f846e06 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -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)
diff --git a/tests/test_sql.py b/tests/test_sql.py
index 90d2dd812..92d7fff40 100644
--- a/tests/test_sql.py
+++ b/tests/test_sql.py
@@ -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(
diff --git a/tests/test_token.py b/tests/test_token.py
index 17cdf1529..8a7bccc2b 100644
--- a/tests/test_token.py
+++ b/tests/test_token.py
@@ -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()
diff --git a/tests/test_tracking_code.py b/tests/test_tracking_code.py
index 6594eca82..3bf7eff33 100644
--- a/tests/test_tracking_code.py
+++ b/tests/test_tracking_code.py
@@ -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):
diff --git a/tests/test_upload_storage.py b/tests/test_upload_storage.py
index 1f2f12ba0..c9f1bd46c 100644
--- a/tests/test_upload_storage.py
+++ b/tests/test_upload_storage.py
@@ -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
diff --git a/tests/utilities.py b/tests/utilities.py
index 021d5a737..01e1c32f0 100644
--- a/tests/utilities.py
+++ b/tests/utilities.py
@@ -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
diff --git a/tests/workflow/test_all.py b/tests/workflow/test_all.py
index 2266d1d56..d100157e3 100644
--- a/tests/workflow/test_all.py
+++ b/tests/workflow/test_all.py
@@ -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 = {
diff --git a/tests/workflow/test_carddata.py b/tests/workflow/test_carddata.py
index f54c3b8a9..c414a0dd7 100644
--- a/tests/workflow/test_carddata.py
+++ b/tests/workflow/test_carddata.py
@@ -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):
diff --git a/tests/workflow/test_formdata.py b/tests/workflow/test_formdata.py
index 1ddef97ae..96725f93c 100644
--- a/tests/workflow/test_formdata.py
+++ b/tests/workflow/test_formdata.py
@@ -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': ''})
diff --git a/tests/workflow/test_notification.py b/tests/workflow/test_notification.py
index 7fab5667d..59d167c7a 100644
--- a/tests/workflow/test_notification.py
+++ b/tests/workflow/test_notification.py
@@ -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/')
diff --git a/wcs/ctl/check_hobos.py b/wcs/ctl/check_hobos.py
index aba7f08f6..93f19d800 100644
--- a/wcs/ctl/check_hobos.py
+++ b/wcs/ctl/check_hobos.py
@@ -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
 
-- 
2.36.1

