Skip to content

Commit

Permalink
Add tests and changed mb_username in existing tests from uuid to a word
Browse files Browse the repository at this point in the history
  • Loading branch information
anshg1214 committed Apr 7, 2022
1 parent 37ba47b commit b21b567
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions critiquebrainz/frontend/views/test/profile_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class ProfileApplicationsViewsTestCase(FrontendTestCase):

def setUp(self):
super(ProfileApplicationsViewsTestCase, self).setUp()
self.user = User(db_users.get_or_create(1, u"aef06569-098f-4218-a577-b413944d9493", new_user_data={
self.user = User(db_users.get_or_create(1, "Tester", new_user_data={
"display_name": u"Tester",
}))
self.hacker = User(db_users.get_or_create(2, u"9371e5c7-5995-4471-a5a9-33481f897f9c", new_user_data={
self.hacker = User(db_users.get_or_create(2, "Hacker", new_user_data={
"display_name": u"Hacker!",
}))
self.application = dict(
Expand Down
2 changes: 1 addition & 1 deletion critiquebrainz/frontend/views/test/test_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ArtistViewsTestCase(FrontendTestCase):
def setUp(self):
super(ArtistViewsTestCase, self).setUp()
self.reviewer = User(db_users.get_or_create(
1, "aef06569-098f-4218-a577-b413944d9493", new_user_data={"display_name": u"Reviewer"}
1, "Reviewer", new_user_data={"display_name": u"Reviewer"}
))

@mock.patch('critiquebrainz.frontend.external.musicbrainz_db.release_group.browse_release_groups')
Expand Down
4 changes: 2 additions & 2 deletions critiquebrainz/frontend/views/test/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class CommentViewsTestCase(FrontendTestCase):

def setUp(self):
super(CommentViewsTestCase, self).setUp()
self.reviewer = User(db_users.get_or_create(1, "aef06569-098f-4218-a577-b413944d9493", new_user_data={
self.reviewer = User(db_users.get_or_create(1, "reviewer", new_user_data={
"display_name": u"Reviewer",
}))
self.commenter = User(db_users.get_or_create(2, "9371e5c7-5995-4471-a5a9-33481f897f9c", new_user_data={
self.commenter = User(db_users.get_or_create(2, "commenter", new_user_data={
"display_name": u"Commenter",
}))
self.license = db_license.create(
Expand Down
2 changes: 1 addition & 1 deletion critiquebrainz/frontend/views/test/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def setUp(self):
id="CC BY-SA 3.0",
full_name="Created so we can fill the form correctly.",
)
self.user = User(db_users.get_or_create(1, "aef06569-098f-4218-a577-b413944d9493", new_user_data={
self.user = User(db_users.get_or_create(1, "Tester", new_user_data={
"display_name": "Tester",
}))

Expand Down
4 changes: 2 additions & 2 deletions critiquebrainz/frontend/views/test/test_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class ReviewViewsTestCase(FrontendTestCase):

def setUp(self):
super(ReviewViewsTestCase, self).setUp()
self.user = User(db_users.get_or_create(1, "aef06569-098f-4218-a577-b413944d9493", new_user_data={
self.user = User(db_users.get_or_create(1, "Tester", new_user_data={
"display_name": u"Tester",
}))
self.hacker = User(db_users.get_or_create(2, "9371e5c7-5995-4471-a5a9-33481f897f9c", new_user_data={
self.hacker = User(db_users.get_or_create(2, "Hacker", new_user_data={
"display_name": u"Hacker!",
}))
self.license = db_license.create(
Expand Down
2 changes: 1 addition & 1 deletion critiquebrainz/frontend/views/test/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StatisticsViewsTestCase(FrontendTestCase):

def setUp(self):
super(StatisticsViewsTestCase, self).setUp()
self.user = User(db_users.get_or_create(1, "aef06569-098f-4218-a577-b413944d9493", new_user_data={
self.user = User(db_users.get_or_create(1, "Tester", new_user_data={
"display_name": u"Tester",
}))
self.license = db_license.create(
Expand Down
16 changes: 14 additions & 2 deletions critiquebrainz/frontend/views/test/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class UserViewsTestCase(FrontendTestCase):

def setUp(self):
super(UserViewsTestCase, self).setUp()
self.user = User(db_users.get_or_create(1, "aef06569-098f-4218-a577-b413944d9493", new_user_data={
self.user = User(db_users.get_or_create(1, "Tester", new_user_data={
"display_name": u"Tester",
}))
self.admin = User(db_users.get_or_create(2, "9371e5c7-5995-4471-a5a9-33481f897f9c", new_user_data={
self.hacker = User(db_users.create(musicbrainz_row_id = 2, display_name = u"Hacker"))
self.admin = User(db_users.get_or_create(3, "Admin", new_user_data={
"display_name": u"Admin",
}))

Expand All @@ -26,6 +27,17 @@ def test_reviews(self):
self.assert200(response)
self.assertIn("Tester", str(response.data))

# test reviews for user present in db, and logged in
self.temporary_login(self.user)
response = self.client.get("/user/{user_id}".format(user_id=self.user.id))
self.assert200(response)
self.assertIn("Tester", str(response.data))

# test reviews for user present in db, but without musicbrainz_id
response = self.client.get("/user/{user_id}".format(user_id=self.hacker.id))
self.assert200(response)
self.assertIn("Hacker", str(response.data))

def test_info(self):
# test info for user not in db
response = self.client.get("/user/{user_id}/info".format(user_id="random-user-id"))
Expand Down

0 comments on commit b21b567

Please sign in to comment.