-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest_fixtures.py
39 lines (35 loc) · 999 Bytes
/
conftest_fixtures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# all fixtures write here
import pytest
from django.contrib.auth.models import User
@pytest.fixture
def user(db):
user = User.objects.create_user('new-user')
print("new-user")
return user
@pytest.fixture
def new_user_factory(db):
def create_app_user(
username: str,
password: str = None,
first_name: str = 'FName',
last_name: str = 'LName',
email: str = 'email@n.com',
is_staff: str = False,
is_superuser: str = False,
is_active: str = True,
):
user = User.objects.create_user(
username=username,
password=password,
first_name=first_name,
last_name=last_name,
email=email,
is_staff=is_staff,
is_superuser=is_superuser,
is_active=is_active,
)
return user
return create_app_user
@pytest.fixture
def new_user(db, new_user_factory):
return new_user_factory("test","pass","fname","lname")