diff options
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r-- | ishtar_common/tests.py | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 774fab2a2..97002f13d 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -1348,9 +1348,9 @@ class UserProfileTest(TestCase): self.user.set_password(self.password) self.user.save() self.client = Client() - self.client.login(username=self.username, password=self.password) def test_profile_edit(self): + self.client.login(username=self.username, password=self.password) base_url = "/profile/" base_profile = self.user.ishtaruser.current_profile response = self.client.get(base_url) @@ -1407,6 +1407,52 @@ class UserProfileTest(TestCase): self.assertEqual(self.user.ishtaruser.person.profiles.count(), 1) + def _check_changelog_alert(self, content, check_ok=True): + soup = Soup(content, "lxml") + messages = soup.findAll("div", {"id": "message_list"}) + if not check_ok and not len(messages): + return + self.assertEqual(len(messages), 1) + for div in messages: + content = str(div.extract()) + if check_ok: + self.assertIn("/changelog/", content) + else: + self.assertNotIn("/changelog/", content) + + def test_changelog(self): + url = "/changelog/" + response = self.client.get(url) + self.assertRedirects(response, "/accounts/login/?next={}".format(url)) + self.client.login(username=self.username, password=self.password) + user = models.IshtarUser.objects.get(pk=self.user.pk) + self.assertEqual(user.latest_news_version, "") + user.display_news = False + user.save() + + response = self.client.get("/") + self.assertEqual(response.status_code, 200) + response = self.client.get("/") + # 2 times because the first page on server start do not have the version in cache + # not a big deal at all... + + # display_news set to False + self._check_changelog_alert(response.content.decode(), check_ok=False) + user.display_news = True + user.save() + response = self.client.get("/") + self._check_changelog_alert(response.content.decode()) + + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + user = models.IshtarUser.objects.get(pk=self.user.pk) + # checked version updated + self.assertNotEqual(user.latest_news_version, "") + # now no link to changelog displayed + response = self.client.get("/") + self._check_changelog_alert(response.content.decode(), check_ok=False) + + class AcItem: def __init__( self, |