budjeto/conftest.py

40 lines
1.1 KiB
Python

import pytest
from django.contrib.auth import get_user_model
from rest_framework.test import APIRequestFactory, APIClient
@pytest.fixture()
def User(db):
return get_user_model()
@pytest.fixture()
def mkadmin(db):
def inner(username='alice',
email='alice@email.com',
password='alicepassword'):
User = get_user_model()
user = User.objects.create_superuser(username=username,
email=email,
password=password)
return user
return inner
@pytest.fixture()
def mkuser(db):
def inner(username='alice',
email='alice@email.com',
password='alicepassword'):
User = get_user_model()
user = User.objects.create(username=username,
email=email,
password=password)
return user
return inner
@pytest.fixture()
def client():
return APIClient()
@pytest.fixture()
def factory():
return APIRequestFactory()