From 127efeeb68a4ee6fe6c3bfe417a980878f6e165d Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 27 Feb 2015 11:10:48 +0000 Subject: Update unit tests to use new format. --- tests/storage/test_appservice.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests/storage/test_appservice.py') diff --git a/tests/storage/test_appservice.py b/tests/storage/test_appservice.py index fc733d4c79..9a646fa6eb 100644 --- a/tests/storage/test_appservice.py +++ b/tests/storage/test_appservice.py @@ -50,9 +50,15 @@ class ApplicationServiceStoreTestCase(unittest.TestCase): def test_update_and_retrieval_of_service(self): url = "https://matrix.org/appservices/foobar" hs_token = "hstok" - user_regex = ["@foobar_.*:matrix.org"] - alias_regex = ["#foobar_.*:matrix.org"] - room_regex = [] + user_regex = [ + {"regex": "@foobar_.*:matrix.org", "exclusive": True} + ] + alias_regex = [ + {"regex": "#foobar_.*:matrix.org", "exclusive": True} + ] + room_regex = [ + + ] service = ApplicationService( url=url, hs_token=hs_token, token=self.as_token, namespaces={ ApplicationService.NS_USERS: user_regex, -- cgit 1.4.1 From de190e49d5711edb5503e5574296a3c2a02ca06c Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 27 Feb 2015 11:51:06 +0000 Subject: Add more unit tests for exclusive namespaces. --- tests/appservice/test_appservice.py | 50 ++++++++++++++++++++++++++++++++++++- tests/storage/test_appservice.py | 2 +- 2 files changed, 50 insertions(+), 2 deletions(-) (limited to 'tests/storage/test_appservice.py') 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") diff --git a/tests/storage/test_appservice.py b/tests/storage/test_appservice.py index 9a646fa6eb..ca5b92ec85 100644 --- a/tests/storage/test_appservice.py +++ b/tests/storage/test_appservice.py @@ -54,7 +54,7 @@ class ApplicationServiceStoreTestCase(unittest.TestCase): {"regex": "@foobar_.*:matrix.org", "exclusive": True} ] alias_regex = [ - {"regex": "#foobar_.*:matrix.org", "exclusive": True} + {"regex": "#foobar_.*:matrix.org", "exclusive": False} ] room_regex = [ -- cgit 1.4.1