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: Simplify policy-related tests.

Steve Howell31d2660ee28a
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index 59afb8ccc12..714ad613b36 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -4397,26 +4397,19 @@ class SubscriptionAPITest(ZulipTestCase):
"create_web_public_stream_policy", invite_only=False, is_web_public=True
)
- def _test_can_create_streams(self, stream_policy: str, invite_only: bool) -> None:
- if invite_only:
-
- def validation_func(user_profile: UserProfile) -> bool:
- return user_profile.can_create_private_streams()
-
- else:
-
- def validation_func(user_profile: UserProfile) -> bool:
- return user_profile.can_create_public_streams()
+ def test_private_stream_policies(self) -> None:
+ def validation_func(user_profile: UserProfile) -> bool:
+ return user_profile.can_create_private_streams()
- self.check_has_permission_policies(stream_policy, validation_func)
+ self.check_has_permission_policies("create_private_stream_policy", validation_func)
- def test_can_create_private_streams(self) -> None:
- self._test_can_create_streams("create_private_stream_policy", invite_only=True)
+ def test_public_stream_policies(self) -> None:
+ def validation_func(user_profile: UserProfile) -> bool:
+ return user_profile.can_create_public_streams()
- def test_can_create_public_streams(self) -> None:
- self._test_can_create_streams("create_public_stream_policy", invite_only=False)
+ self.check_has_permission_policies("create_public_stream_policy", validation_func)
- def test_can_create_web_public_streams(self) -> None:
+ def test_web_public_stream_policies(self) -> None:
def validation_func(user_profile: UserProfile) -> bool:
return user_profile.can_create_web_public_streams()