diff options
author | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2019-12-02 15:10:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 15:10:23 +0000 |
commit | b69732705d4b2bf4cb467da7df7f283905c7d7eb (patch) | |
tree | b9f454389c30b3451eb0572cbe023d435d15d21d /tests | |
parent | Merge pull request #16 from matrix-org/babolivier/dinsic-state-retrieval (diff) | |
download | synapse-b69732705d4b2bf4cb467da7df7f283905c7d7eb.tar.xz |
Capatilise letters after a - in new user displaynames (#14)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/handlers/test_register.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py index 5ffba2ca7a..b2aa5c2478 100644 --- a/tests/handlers/test_register.py +++ b/tests/handlers/test_register.py @@ -20,6 +20,7 @@ from twisted.internet import defer from synapse.api.constants import UserTypes from synapse.api.errors import ResourceLimitError, SynapseError from synapse.handlers.register import RegistrationHandler +from synapse.rest.client.v2_alpha.register import _map_email_to_displayname from synapse.types import RoomAlias, UserID, create_requester from .. import unittest @@ -235,3 +236,30 @@ class RegistrationTestCase(unittest.HomeserverTestCase): self.handler.register(localpart=invalid_user_id), SynapseError ) + + def test_email_to_displayname_mapping(self): + """Test that custom emails are mapped to new user displaynames correctly""" + self._check_mapping( + "jack-phillips.rivers@big-org.com", + "Jack-Phillips Rivers [Big-Org]", + ) + + self._check_mapping( + "bob.jones@matrix.org", + "Bob Jones [Tchap Admin]", + ) + + self._check_mapping( + "bob-jones.blabla@gouv.fr", + "Bob-Jones Blabla [Gouv]", + ) + + # Multibyte unicode characters + self._check_mapping( + u"j\u030a\u0065an-poppy.seed@example.com", + u"J\u030a\u0065an-Poppy Seed [Example]", + ) + + def _check_mapping(self, i, expected): + result = _map_email_to_displayname(i) + self.assertEqual(result, expected) |