Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Create assertInHomePage helper function.
Vishnu KS75a3059b57ae
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.pyindex 7d4fcc5b573..709ae7bda98 100644--- a/zerver/tests/test_home.py+++ b/zerver/tests/test_home.py@@ -400,6 +400,9 @@ class HomeTest(ZulipTestCase):result = self.client_get("/", dict(**kwargs))return result+ def assertInHomePage(self, string: str) -> bool:+ return self.assertIn(string, self._get_home_page().content.decode("utf-8"))+def _sanity_check(self, result: HttpResponse) -> None:"""Use this for tests that are geared toward specific edge cases, but@@ -697,9 +700,7 @@ class HomeTest(ZulipTestCase):user_profile.role = UserProfile.ROLE_REALM_ADMINISTRATORuser_profile.save()- result = self._get_home_page()- html = result.content.decode("utf-8")- self.assertIn("Invite more users", html)+ self.assertInHomePage("Invite more users")def test_show_invites_for_guest_users(self) -> None:user_profile = self.example_user("polonius")@@ -735,8 +736,7 @@ class HomeTest(ZulipTestCase):tier=CustomerPlan.STANDARD,status=CustomerPlan.ENDED,)- result_html = self._get_home_page().content.decode("utf-8")- self.assertIn("Billing", result_html)+ self.assertInHomePage("Billing")# realm admin, with CustomerPlan -> no billing linkuser.role = UserProfile.ROLE_REALM_ADMINISTRATOR@@ -748,8 +748,7 @@ class HomeTest(ZulipTestCase):user.role = UserProfile.ROLE_MEMBERuser.is_billing_admin = Trueuser.save(update_fields=["role", "is_billing_admin"])- result_html = self._get_home_page().content.decode("utf-8")- self.assertIn("Billing", result_html)+ self.assertInHomePage("Billing")# member, with CustomerPlan -> no billing linkuser.is_billing_admin = False@@ -774,8 +773,7 @@ class HomeTest(ZulipTestCase):# billing admin, with sponsorship pending -> show billing linkcustomer.sponsorship_pending = Truecustomer.save(update_fields=["sponsorship_pending"])- result_html = self._get_home_page().content.decode("utf-8")- self.assertIn("Billing", result_html)+ self.assertInHomePage("Billing")# billing admin, no customer object -> make sure it doesn't crashcustomer.delete()@@ -793,8 +791,7 @@ class HomeTest(ZulipTestCase):# Show plans link to all other users if plan_type is LIMITEDself.login("hamlet")- result_html = self._get_home_page().content.decode("utf-8")- self.assertIn("Plans", result_html)+ self.assertInHomePage("Plans")# Show plans link to no one, including admins, if SELF_HOSTED or STANDARDdo_change_plan_type(realm, Realm.SELF_HOSTED, acting_user=None)@@ -810,12 +807,10 @@ class HomeTest(ZulipTestCase):self.login("hamlet")- result_html = self._get_home_page().content.decode("utf-8")- self.assertIn("Support Zulip", result_html)+ self.assertInHomePage("Support Zulip")do_change_plan_type(realm, Realm.STANDARD_FREE, acting_user=None)- result_html = self._get_home_page().content.decode("utf-8")- self.assertIn("Support Zulip", result_html)+ self.assertInHomePage("Support Zulip")with self.settings(PROMOTE_SPONSORING_ZULIP=False):result_html = self._get_home_page().content.decode("utf-8")