-
Notifications
You must be signed in to change notification settings - Fork 11
/
conftest.py
42 lines (32 loc) · 982 Bytes
/
conftest.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
40
41
42
import pytest
from rest_framework.test import APIClient
from rest_framework_simplejwt.tokens import RefreshToken
from devopshobbies.users.models import BaseUser
from devopshobbies.tests.factories import (
BaseUserFactory,
ProfileFactory,
SubscriptionFactory,
PostFactory,
)
@pytest.fixture
def api_client():
user = BaseUser.objects.create_user(email='[email protected]', password='pass@1test')
client = APIClient()
refresh = RefreshToken.for_user(user)
client.credentials(HTTP_AUTHORIZATION=f'Bearer {refresh.access_token}')
return client
@pytest.fixture
def user1():
return BaseUserFactory()
@pytest.fixture
def user2():
return BaseUserFactory()
@pytest.fixture
def profile1(user1):
return ProfileFactory(user=user1)
@pytest.fixture
def subscription1(user1, user2):
return SubscriptionFactory(target=user1, subscriber=user2)
@pytest.fixture
def post1(user1):
return PostFactory(author=user1)