Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unit tests for ProfileFollowing View #1472

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions project/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,30 @@ def test_get_user_profile(self):
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.user.username)
self.assertTemplateUsed(response, "account.html")


class ProfileFollowing(BaseTestCase):
"""A class to test user profiles following view"""

def setUp(self) -> None:
super(ProfileFollowing, self).setUp()

self.user2 = get_user_model().objects.create_user(
username="newuser2", email="[email protected]", password="password123"
)
self.user3 = get_user_model().objects.create_user(
username="newuser3", email="[email protected]", password="password123"
Comment on lines +227 to +230
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these users have distinct email addresses?

)

self.user.profile.following.add(self.user2.profile)
self.user.profile.following.add(self.user3.profile)

def test_get_user_profile(self):
"""Whether user_profile function works as expected"""

self.client.login(username="newuser", password="password123")
response = self.client.get(reverse("profile-following", args=["newuser"]))
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.user2.username)
self.assertContains(response, self.user3.username)
self.assertTemplateUsed(response, "profile_following.html")