Skip to content

Commit

Permalink
WIP updating tests for BW
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Oct 27, 2023
1 parent e3f7982 commit 7516f48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
6 changes: 3 additions & 3 deletions accounts/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_user_registration(self, magic_mock_function):
'email2': ['[email protected]']
})
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, 'Registration done, activate your account')
self.assertContains(resp, 'feedbackRegistration=1')
self.assertEqual(User.objects.filter(username=username).count(), 1)
self.assertEqual(len(mail.outbox), 1) # An email was sent!
self.assertTrue(settings.EMAIL_SUBJECT_PREFIX in mail.outbox[0].subject)
Expand Down Expand Up @@ -772,7 +772,7 @@ def test_reset_view_with_email(self):
self.client.post(reverse("problems-logging-in"), {"username_or_email": "[email protected]"})

self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, "Password reset on Freesound")
self.assertEqual(mail.outbox[0].subject, "[freesound] Password reset")

@override_settings(SITE_ID=2)
def test_reset_view_with_username(self):
Expand All @@ -782,7 +782,7 @@ def test_reset_view_with_username(self):
self.client.post(reverse("problems-logging-in"), {"username_or_email": "testuser"})

self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, "Password reset on Freesound")
self.assertEqual(mail.outbox[0].subject, "[freesound] Password reset")


class EmailResetTestCase(TestCase):
Expand Down
19 changes: 8 additions & 11 deletions bookmarks/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ def test_others_bookmarks(self):
self.assertEqual(200, response.status_code)
self.assertContains(response, 'Bookmarks by Anton')

@override_settings(BW_BOOKMARK_PAGES_PUBLIC=True)
def test_no_bookmarks(self):
user = User.objects.get(username='Anton')
self.client.force_login(user)

response = self.client.get(reverse('bookmarks-for-user', kwargs={'username': user.username}))

self.assertEqual(200, response.status_code)
self.assertContains(response, 'Your bookmarks')
self.assertContains(response, 'Bookmarks')
self.assertContains(response, 'There are no uncategorized bookmarks')

@override_settings(BW_BOOKMARK_PAGES_PUBLIC=True)
def test_bookmark_category(self):
user = User.objects.get(username='Anton')
self.client.force_login(user)

category = bookmarks.models.BookmarkCategory.objects.create(name='Category1', user=user)
bookmarks.models.Bookmark.objects.create(user=user, sound_id=10)
Expand All @@ -127,11 +127,10 @@ def test_bookmark_category(self):

self.assertEqual(200, response.status_code)
self.assertEqual(2, len(response.context['page'].object_list))
self.assertContains(response, 'Your bookmarks')
self.assertContains(response, 'Bookmarks in "Category1"')
self.assertContains(response, 'Uncategorized</a> (1 bookmark)')
self.assertContains(response, 'Category1</a> (2 bookmarks)')
self.assertContains(response, 'Bookmarks')
self.assertContains(response, 'Category1')

@override_settings(BW_BOOKMARK_PAGES_PUBLIC=True)
def test_bookmark_category_oldusername(self):
user = User.objects.get(username='Anton')
self.client.force_login(user)
Expand All @@ -156,7 +155,5 @@ def test_bookmark_category_oldusername(self):
self.assertEqual(200, response.status_code)

self.assertEqual(2, len(response.context['page'].object_list))
self.assertContains(response, 'Your bookmarks')
self.assertContains(response, 'Bookmarks in "Category1"')
self.assertContains(response, 'Uncategorized</a> (1 bookmark)')
self.assertContains(response, 'Category1</a> (2 bookmarks)')
self.assertContains(response, 'Bookmarks')
self.assertContains(response, 'Category1')

0 comments on commit 7516f48

Please sign in to comment.