tests: autouse the media fixture (#46868)
This commit is contained in:
parent
3f95f865ca
commit
1193c631ae
|
@ -25,7 +25,6 @@ import django
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.core.cache import cache
|
||||
from django_rbac.utils import get_ou_model, get_role_model
|
||||
from django.conf import settings
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.db.migrations.executor import MigrationExecutor
|
||||
from django.db import connection
|
||||
|
@ -49,6 +48,21 @@ from . import utils
|
|||
Role = get_role_model()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def settings(settings, request):
|
||||
# our post_migrate handlers depends upon some values of the settings (like
|
||||
# A2_RBAC_MANAGED_CONTENT_TYPES), making the media fixture "autouse=True"
|
||||
# fixed the order of running settings and transactional_db, but
|
||||
# transactional_db use the flush() which use the post_migrate handlers to
|
||||
# restore a blank database state. To force the ordering of transactional_db
|
||||
# and settings fixture we need to override the later and use a dynamic call
|
||||
# to the transactional_db fixture when needed.
|
||||
if 'transactional_db' in request.fixturenames:
|
||||
request.getfixturevalue('transactional_db')
|
||||
yield settings
|
||||
settings.finalize()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app_factory():
|
||||
wtm = django_webtest.WebTestMixin()
|
||||
|
@ -233,6 +247,8 @@ def concurrency(settings):
|
|||
|
||||
@pytest.fixture
|
||||
def migrations():
|
||||
from django.conf import settings
|
||||
|
||||
if isinstance(settings.MIGRATION_MODULES, DisableMigrations):
|
||||
pytest.skip('this test requires native migrations')
|
||||
|
||||
|
@ -390,7 +406,7 @@ def french_translation():
|
|||
deactivate()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.fixture(autouse=True)
|
||||
def media(settings, tmpdir):
|
||||
settings.MEDIA_ROOT = str(tmpdir.mkdir('media'))
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ def test_birthdate_api(db, app, admin, mailoutbox, freezer):
|
|||
qs.delete()
|
||||
|
||||
|
||||
def test_profile_image(db, app, admin, mailoutbox, media):
|
||||
def test_profile_image(db, app, admin, mailoutbox):
|
||||
Attribute.objects.create(name='cityscape_image', label='cityscape', kind='profile_image',
|
||||
asked_on_registration=True, required=False,
|
||||
user_visible=True, user_editable=True)
|
||||
|
|
|
@ -135,7 +135,7 @@ OIDC_CLIENT_PARAMS = [
|
|||
|
||||
|
||||
@pytest.fixture(params=OIDC_CLIENT_PARAMS)
|
||||
def oidc_client(request, superuser, app, simple_user, media, oidc_settings):
|
||||
def oidc_client(request, superuser, app, simple_user, oidc_settings):
|
||||
Attribute.objects.create(
|
||||
name='cityscape_image',
|
||||
label='cityscape',
|
||||
|
@ -163,7 +163,7 @@ def oidc_client(request, superuser, app, simple_user, media, oidc_settings):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def normal_oidc_client(superuser, app, simple_user, media):
|
||||
def normal_oidc_client(superuser, app, simple_user):
|
||||
url = reverse('admin:authentic2_idp_oidc_oidcclient_add')
|
||||
assert OIDCClient.objects.count() == 0
|
||||
response = utils.login(app, superuser, path=url)
|
||||
|
|
|
@ -78,7 +78,7 @@ def keys():
|
|||
|
||||
|
||||
@pytest.fixture()
|
||||
def idp(saml_settings, db, media):
|
||||
def idp(saml_settings, db):
|
||||
code_attribute = Attribute.objects.create(kind='string', name='code', label='Code')
|
||||
mobile_attribute = Attribute.objects.create(kind='string', name='mobile',
|
||||
label='Mobile')
|
||||
|
|
|
@ -31,7 +31,7 @@ def profile(transactional_db):
|
|||
Attribute.objects.create(name='phone', kind='phone_number', label='Numéro de téléphone')
|
||||
|
||||
|
||||
def test_user_import(media, transactional_db, profile):
|
||||
def test_user_import(transactional_db, profile):
|
||||
content = '''email key verified,first_name,last_name,phone no-create
|
||||
tnoel@entrouvert.com,Thomas,Noël,1234
|
||||
fpeters@entrouvert.com,Frédéric,Péters,5678
|
||||
|
|
|
@ -362,7 +362,7 @@ def test_user_table(app, admin, user_ou1, ou1):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('encoding', ['utf-8-sig', 'cp1252', 'iso-8859-15'])
|
||||
def test_user_import(encoding, transactional_db, app, admin, ou1, admin_ou1, media):
|
||||
def test_user_import(encoding, transactional_db, app, admin, ou1, admin_ou1):
|
||||
Attribute.objects.create(name='phone', kind='phone_number', label='Numéro de téléphone')
|
||||
|
||||
user_count = User.objects.count()
|
||||
|
@ -525,7 +525,7 @@ def import_csv(csv_content, app):
|
|||
return response
|
||||
|
||||
|
||||
def test_user_import_attributes(transactional_db, app, admin, media):
|
||||
def test_user_import_attributes(transactional_db, app, admin):
|
||||
Attribute.objects.create(name='more', kind='string', label='Signe particulier')
|
||||
Attribute.objects.create(name='title', kind='title', label='Titre')
|
||||
Attribute.objects.create(name='bike', kind='boolean', label='Vélo')
|
||||
|
@ -588,7 +588,7 @@ def test_detail_view_deleted(app, admin, simple_user):
|
|||
app.get(url, status=404)
|
||||
|
||||
|
||||
def test_user_import_row_error_display(transactional_db, app, admin, media):
|
||||
def test_user_import_row_error_display(transactional_db, app, admin):
|
||||
User.objects.create(first_name='Elliott', last_name='1', ou=get_default_ou())
|
||||
User.objects.create(first_name='Elliott', last_name='2', ou=get_default_ou())
|
||||
content = '''first_name key,last_name
|
||||
|
|
Loading…
Reference in New Issue