summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-09-19 11:58:06 +0100
committerBrendan Abolivier <babolivier@matrix.org>2019-09-19 11:58:06 +0100
commitae036ed63605cbe0bb62010565eece6c7b1a9249 (patch)
treeec4d1cb082fb60c8c90c1f4efc39db32158d20d9
parentMerge pull request #2 from matrix-org/babolivier/dinsic-3pid-invite (diff)
downloadsynapse-ae036ed63605cbe0bb62010565eece6c7b1a9249.tar.xz
Add unit tests for strip_invalid_mxid_characters
-rw-r--r--tests/test_types.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_types.py b/tests/test_types.py

index d83c36559f..73d3b2cda2 100644 --- a/tests/test_types.py +++ b/tests/test_types.py
@@ -12,9 +12,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from six import string_types from synapse.api.errors import SynapseError -from synapse.types import GroupID, RoomAlias, UserID, map_username_to_mxid_localpart +from synapse.types import ( + GroupID, + RoomAlias, + UserID, + map_username_to_mxid_localpart, + strip_invalid_mxid_characters, +) from tests import unittest from tests.utils import TestHomeServer @@ -106,3 +113,16 @@ class MapUsernameTestCase(unittest.TestCase): self.assertEqual( map_username_to_mxid_localpart(u'têst'.encode('utf-8')), "t=c3=aast" ) + + +class StripInvalidMxidCharactersTestCase(unittest.TestCase): + def test_return_type(self): + unstripped = strip_invalid_mxid_characters("test") + stripped = strip_invalid_mxid_characters("test@") + + self.assertTrue(isinstance(unstripped, string_types), type(unstripped)) + self.assertTrue(isinstance(stripped, string_types), type(stripped)) + + def test_strip(self): + stripped = strip_invalid_mxid_characters("test@") + self.assertEqual(stripped, "test", stripped)