summary refs log tree commit diff
path: root/tests/appservice/test_appservice.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-27 11:51:06 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-27 11:51:06 +0000
commitde190e49d5711edb5503e5574296a3c2a02ca06c (patch)
treef72f980bcca9bb8e93e34800d1514a4a2cccd526 /tests/appservice/test_appservice.py
parentUpdate unit tests to use new format. (diff)
downloadsynapse-de190e49d5711edb5503e5574296a3c2a02ca06c.tar.xz
Add more unit tests for exclusive namespaces.
Diffstat (limited to 'tests/appservice/test_appservice.py')
-rw-r--r--tests/appservice/test_appservice.py50
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/appservice/test_appservice.py b/tests/appservice/test_appservice.py
index c1c2892eb1..eb7becf725 100644
--- a/tests/appservice/test_appservice.py
+++ b/tests/appservice/test_appservice.py
@@ -21,7 +21,7 @@ from tests import unittest
 def _regex(regex, exclusive=True):
     return {
         "regex": regex,
-        exclusive: exclusive
+        "exclusive": exclusive
     }
 
 
@@ -87,6 +87,54 @@ class ApplicationServiceTestCase(unittest.TestCase):
             aliases_for_event=["#irc_foobar:matrix.org", "#athing:matrix.org"]
         ))
 
+    def test_non_exclusive_alias(self):
+        self.service.namespaces[ApplicationService.NS_ALIASES].append(
+            _regex("#irc_.*:matrix.org", exclusive=False)
+        )
+        self.assertFalse(self.service.is_exclusive_alias(
+            "#irc_foobar:matrix.org"
+        ))
+
+    def test_non_exclusive_room(self):
+        self.service.namespaces[ApplicationService.NS_ROOMS].append(
+            _regex("!irc_.*:matrix.org", exclusive=False)
+        )
+        self.assertFalse(self.service.is_exclusive_room(
+            "!irc_foobar:matrix.org"
+        ))
+
+    def test_non_exclusive_user(self):
+        self.service.namespaces[ApplicationService.NS_USERS].append(
+            _regex("@irc_.*:matrix.org", exclusive=False)
+        )
+        self.assertFalse(self.service.is_exclusive_user(
+            "@irc_foobar:matrix.org"
+        ))
+
+    def test_exclusive_alias(self):
+        self.service.namespaces[ApplicationService.NS_ALIASES].append(
+            _regex("#irc_.*:matrix.org", exclusive=True)
+        )
+        self.assertTrue(self.service.is_exclusive_alias(
+            "#irc_foobar:matrix.org"
+        ))
+
+    def test_exclusive_user(self):
+        self.service.namespaces[ApplicationService.NS_USERS].append(
+            _regex("@irc_.*:matrix.org", exclusive=True)
+        )
+        self.assertTrue(self.service.is_exclusive_user(
+            "@irc_foobar:matrix.org"
+        ))
+
+    def test_exclusive_room(self):
+        self.service.namespaces[ApplicationService.NS_ROOMS].append(
+            _regex("!irc_.*:matrix.org", exclusive=True)
+        )
+        self.assertTrue(self.service.is_exclusive_room(
+            "!irc_foobar:matrix.org"
+        ))
+
     def test_regex_alias_no_match(self):
         self.service.namespaces[ApplicationService.NS_ALIASES].append(
             _regex("#irc_.*:matrix.org")