summaryrefslogtreecommitdiff
path: root/ishtar_common/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-04-06 18:36:47 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2023-04-17 15:47:16 +0200
commit71a256dc52ed3391638dcf9669cf57d75475d326 (patch)
tree422181b331fcd809a6c4a4316d76d960a248f4d5 /ishtar_common/tests.py
parent59d92f268b2a002b006250258bdc54880e080013 (diff)
downloadIshtar-71a256dc52ed3391638dcf9669cf57d75475d326.tar.bz2
Ishtar-71a256dc52ed3391638dcf9669cf57d75475d326.zip
Display of a changelog with alert display when updates are made
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r--ishtar_common/tests.py48
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,