combo/tests/conftest.py

41 lines
995 B
Python

import pytest
from django.contrib.auth.models import User
import django_webtest
@pytest.fixture
def app(request):
wtm = django_webtest.WebTestMixin()
wtm._patch_settings()
request.addfinalizer(wtm._unpatch_settings)
return django_webtest.DjangoTestApp()
@pytest.fixture
def john_doe():
try:
user = User.objects.get(username='john.doe')
except User.DoesNotExist:
user = User.objects.create_user('john.doe', email='john.doe@example.com', password='john.doe')
return user
@pytest.fixture
def jane_doe():
try:
admin2 = User.objects.get(username='jane.doe')
except User.DoesNotExist:
admin2 = User.objects.create_user('jane.doe', email='jane.doe@example.com', password='jane.doe')
return admin2
@pytest.fixture
def admin_user():
try:
user = User.objects.get(username='admin')
except User.DoesNotExist:
user = User.objects.create_superuser('admin', email=None, password='admin')
return user