Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tests: Create assert_user_details_in_html_response helper function.

Vishnu KS79c4a25d20c2
diff --git a/analytics/tests/test_views.py b/analytics/tests/test_views.py
index 1778af2425b..5283cc8ab58 100644
--- a/analytics/tests/test_views.py
+++ b/analytics/tests/test_views.py
@@ -576,43 +576,40 @@ class TestSupportEndpoint(ZulipTestCase):
def test_search(self) -> None:
reset_emails_in_zulip_realm()
- def check_hamlet_user_query_result(result: HttpResponse) -> None:
+ def assert_user_details_in_html_response(
+ html_response: str, full_name: str, email: str, role: str
+ ) -> None:
self.assert_in_success_response(
[
'<span class="label">user</span>\n',
- "<h3>King Hamlet</h3>",
- "<b>Email</b>: [email protected]",
+ f"<h3>{full_name}</h3>",
+ f"<b>Email</b>: {email}",
"<b>Is active</b>: True<br>",
- "<b>Role</b>: Member<br>",
- "<b>Admins</b>: [email protected], [email protected]\n",
- 'class="copy-button" data-copytext="[email protected], [email protected]"',
+ f"<b>Role</b>: {role}<br>",
],
- result,
+ html_response,
)
- def check_othello_user_query_result(result: HttpResponse) -> None:
+ def check_hamlet_user_query_result(result: HttpResponse) -> None:
+ assert_user_details_in_html_response(
+ result, "King Hamlet", "[email protected]", "Member"
+ )
self.assert_in_success_response(
[
- '<span class="label">user</span>\n',
- "<h3>Othello, the Moor of Venice</h3>",
- "<b>Email</b>: [email protected]",
- "<b>Is active</b>: True<br>",
- "<b>Role</b>: Member<br>",
+ "<b>Admins</b>: [email protected], [email protected]\n",
+ 'class="copy-button" data-copytext="[email protected], [email protected]"',
],
result,
)
- def check_polonius_user_query_result(result: HttpResponse) -> None:
- self.assert_in_success_response(
- [
- "<h3>Polonius</h3>",
- "<b>Email</b>: [email protected]",
- "<b>Is active</b>: True<br>",
- "<b>Role</b>: Guest<br>",
- ],
- result,
+ def check_othello_user_query_result(result: HttpResponse) -> None:
+ assert_user_details_in_html_response(
+ result, "Othello, the Moor of Venice", "[email protected]", "Member"
)
+ def check_polonius_user_query_result(result: HttpResponse) -> None:
+ assert_user_details_in_html_response(result, "Polonius", "[email protected]", "Guest")
+
def check_zulip_realm_query_result(result: HttpResponse) -> None:
zulip_realm = get_realm("zulip")
self.assert_in_success_response(