-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
57 lines (37 loc) · 1.31 KB
/
conftest.py
File metadata and controls
57 lines (37 loc) · 1.31 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from django.contrib.auth.models import User
from django.test import Client
from oauth2_provider.models import AccessToken
import pytest
from bats_ai.core.models import VettingDetails
from .factories import AccessTokenFactory, SuperuserFactory, UserFactory, VettingDetailsFactory
@pytest.fixture
def client() -> Client:
return Client()
@pytest.fixture
def user() -> User:
return UserFactory()
@pytest.fixture
def user_token(user) -> AccessToken:
return AccessTokenFactory(user=user)
@pytest.fixture
def authenticated_client(user: User, user_token: AccessToken) -> Client:
client = Client()
client.defaults['HTTP_AUTHORIZATION'] = f'Bearer {user_token.token}'
return client
@pytest.fixture
def superuser() -> User:
return SuperuserFactory()
@pytest.fixture
def superuser_token(superuser) -> AccessToken:
return AccessTokenFactory(user=superuser)
@pytest.fixture
def authorized_client(superuser: User, superuser_token: AccessToken) -> Client:
client = Client()
client.defaults['HTTP_AUTHORIZATION'] = f'Bearer {superuser_token.token}'
return client
@pytest.fixture
def vetting_details(user: User) -> VettingDetails:
return VettingDetailsFactory(user=user)
@pytest.fixture
def random_user_vetting_details() -> VettingDetails:
return VettingDetailsFactory(user=UserFactory())