Esempio n. 1
0
    def test_get_short_name_sort_first_name_both_names(self):
        """
        Tests the output of get_short_name.
        """
        user = User()
        user.first_name = 'test_first_name'
        user.last_name = 'test_last_name'

        with patch('openslides.users.models.config') as mock_config:
            mock_config.__getitem__.return_value = True
            short_name = user.get_short_name()

        self.assertEqual(
            short_name, 'test_first_name test_last_name',
            "User.get_short_name() returns wrong string when it has a fist_name "
            "and a last_name and is sorted by first_name.")
Esempio n. 2
0
    def test_get_short_name_sort_first_name_both_names(self):
        """
        Tests the output of get_short_name.
        """
        user = User()
        user.first_name = 'test_first_name'
        user.last_name = 'test_last_name'

        with patch('openslides.users.models.config') as mock_config:
            mock_config.__getitem__.return_value = True
            short_name = user.get_short_name()

        self.assertEqual(
            short_name,
            'test_first_name test_last_name',
            "User.get_short_name() returns wrong string when it has a fist_name "
            "and a last_name and is sorted by first_name.")
Esempio n. 3
0
    def test_while_spaces_in_name_parts(self):
        """
        Tests the output if the name parts have white spaces at the begin or
        end.
        """
        user = User()
        user.first_name = ' test_first_name\n '
        user.last_name = ' test_last_name \n'

        with patch('openslides.users.models.config') as mock_config:
            mock_config.__getitem__.return_value = True
            short_name = user.get_short_name()

        self.assertEqual(
            short_name,
            'test_first_name test_last_name',
            "User.get_short_name() has to strip whitespaces from the name parts.")