-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed url names and unit tests for follow
- Loading branch information
1 parent
245981c
commit ce1d693
Showing
3 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from django.contrib.auth import get_user_model | ||
from django.test import TestCase, Client | ||
from django.urls import reverse | ||
from ..models import Follow | ||
|
||
class SetupTestCase(TestCase): | ||
def setUp(self): | ||
|
@@ -36,3 +37,60 @@ def tearDown(self): | |
User = get_user_model() | ||
User.objects.all().delete() | ||
return super().tearDown() | ||
|
||
|
||
class FollowSetupTestCase(TestCase): | ||
def setUp(self): | ||
self.client = Client() | ||
self.user_one_data = { | ||
'username': 'user_one', | ||
'email': '[email protected]', | ||
'password': 'Password123' | ||
} | ||
self.user_two_data = { | ||
'username': 'user_two', | ||
'email': '[email protected]', | ||
'password': 'Password123' | ||
} | ||
User = get_user_model() | ||
User.objects.create_user(**self.user_one_data) | ||
User.objects.create_user(**self.user_two_data) | ||
return super().setUp() | ||
|
||
def tearDown(self): | ||
get_user_model().objects.all().delete() | ||
return super().tearDown() | ||
|
||
class UnfollowSetupTestCase(TestCase): | ||
def setUp(self): | ||
self.client = Client() | ||
self.user_one_data = { | ||
'username': 'user_one', | ||
'email': '[email protected]', | ||
'password': 'Password123' | ||
} | ||
self.user_two_data = { | ||
'username': 'user_two', | ||
'email': '[email protected]', | ||
'password': 'Password123' | ||
} | ||
|
||
self.user_three_data = { | ||
'username': 'user_three', | ||
'email': '[email protected]', | ||
'password': 'Password123' | ||
} | ||
User = get_user_model() | ||
User.objects.create_user(**self.user_one_data) | ||
User.objects.create_user(**self.user_two_data) | ||
User.objects.create_user(**self.user_three_data) | ||
user_one_id = User.objects.get(username='user_one').user_id | ||
user_two_id = User.objects.get(username='user_two').user_id | ||
user_three_id = User.objects.get(username='user_three').user_id | ||
Follow.objects.create(user_id=user_one_id, followed_user_id=user_two_id) | ||
return super().setUp() | ||
|
||
def tearDown(self): | ||
get_user_model().objects.all().delete() | ||
Follow.objects.all().delete() | ||
return super().tearDown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters