Files
website-v2/users/tests/fixtures.py
Frank Wiles 29878c3f90 Rework versions models
- Added ListView and DetailView
- Move to pytest style tests
- Fix migrations to be clean to rebuild and throw away existing data
- Add model_bakery
2022-05-28 16:00:24 -05:00

57 lines
1.1 KiB
Python

import pytest
from django.utils import timezone
from model_bakery import baker
@pytest.fixture
def user(db):
"""Regular website user"""
user = baker.make(
"users.User",
email="user@example.com",
first_name="Regular",
last_name="User",
last_login=timezone.now(),
)
user.set_password("password")
user.save()
return user
@pytest.fixture
def staff_user(db):
"""Staff website user with access to the Django admin"""
user = baker.make(
"users.User",
email="staff@example.com",
first_name="Staff",
last_name="User",
last_login=timezone.now(),
is_staff=True,
)
user.set_password("password")
user.save()
return user
@pytest.fixture
def super_user(db):
"""Superuser with access to everything"""
user = baker.make(
"users.User",
email="super@example.com",
first_name="Super",
last_name="User",
last_login=timezone.now(),
is_staff=True,
is_superuser=True,
)
user.set_password("password")
user.save()
return user