tests: move fixtures in conftest (#30105)
This commit is contained in:
parent
00a0d2aa83
commit
d084008f85
|
@ -3,11 +3,16 @@ import copy
|
|||
import pytest
|
||||
import django_webtest
|
||||
from collections import namedtuple
|
||||
import pathlib2
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from django_rbac.utils import get_ou_model
|
||||
|
||||
User = get_user_model()
|
||||
OU = get_ou_model()
|
||||
TEST_DIR = pathlib2.Path(__file__).parent
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -25,7 +30,6 @@ def partner_ou(db):
|
|||
return OU.objects.create(name='partner', slug='ou')
|
||||
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def glc(app, partner_ou, db):
|
||||
from authentic2_idp_oidc.models import OIDCClient
|
||||
|
@ -78,3 +82,36 @@ def hooks(settings):
|
|||
yield hook
|
||||
hook.clear()
|
||||
del settings.A2_HOOKS['__all__']
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin(db):
|
||||
user = User(
|
||||
username='admin',
|
||||
email='admin@example.net',
|
||||
is_superuser=True,
|
||||
is_staff=True)
|
||||
user.ou = OU.objects.get(slug='territoire')
|
||||
user.set_password('admin')
|
||||
user.save()
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jpeg_file():
|
||||
with (TEST_DIR / 'minimal.jpg').open('rb') as fd:
|
||||
yield fd.read()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def png_file():
|
||||
with (TEST_DIR / 'minimal.png').open('rb') as fd:
|
||||
yield fd.read()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pdf_file():
|
||||
with (TEST_DIR / 'minimal.pdf').open('rb') as fd:
|
||||
yield fd.read()
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import base64
|
|||
import uuid
|
||||
|
||||
import pytest
|
||||
import pathlib2
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from authentic2_cut import models
|
||||
|
@ -16,20 +15,6 @@ JOHN = u'Jôhn'
|
|||
DOE = u'Dôe'
|
||||
EMAIL = 'john.doe@example.com'
|
||||
|
||||
TEST_DIR = pathlib2.Path(__file__).parent
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin(db):
|
||||
user = User(
|
||||
username='admin',
|
||||
email='admin@example.net',
|
||||
is_superuser=True,
|
||||
is_staff=True)
|
||||
user.set_password('admin')
|
||||
user.save()
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def john(glc_app):
|
||||
|
@ -63,24 +48,6 @@ def test_create_user(john):
|
|||
assert john
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jpeg_file():
|
||||
with (TEST_DIR / 'minimal.jpg').open('rb') as fd:
|
||||
yield fd.read()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def png_file():
|
||||
with (TEST_DIR / 'minimal.png').open('rb') as fd:
|
||||
yield fd.read()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pdf_file():
|
||||
with (TEST_DIR / 'minimal.pdf').open('rb') as fd:
|
||||
yield fd.read()
|
||||
|
||||
|
||||
def helper_test_validation_image(glc_app, john, image_file, extension):
|
||||
external_id = uuid.uuid4().hex
|
||||
response = glc_app.post_json('/api/users/%s/validate/' % john._oidc_sub, params={
|
||||
|
|
Loading…
Reference in New Issue