-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
51 lines (39 loc) · 1.16 KB
/
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
43
44
45
46
47
48
49
50
51
import pytest
from rest_framework.test import APIClient
from zoomedia.userprofile.models import Profile
from rest_framework_simplejwt.tokens import RefreshToken
from django.contrib.auth import get_user_model
from zoomedia.tests.factories import (
UserFactory,
ProfileFactory,
FollowFactory,
PostFactory,
)
@pytest.fixture
def api_client(user1):
# user = get_user_model().objects.create_user(username = "testy",email='[email protected]', password='pass@1test')
client = APIClient()
refresh = RefreshToken.for_user(user1)
client.credentials(HTTP_AUTHORIZATION=f'Bearer {refresh.access_token}')
return client
@pytest.fixture
def user1():
return UserFactory()
@pytest.fixture
def user2():
return UserFactory()
@pytest.fixture
def follow1(user1 , user2):
return FollowFactory(follower = user1, following = user2)
@pytest.fixture
def post1(user1):
return PostFactory(author=user1)
@pytest.fixture
def post2(user2):
return PostFactory(author=user2)
@pytest.fixture
def profile1(user1):
return ProfileFactory(user=user1)
@pytest.fixture
def profile2(user2):
return ProfileFactory(user=user2)