示例#1
0
文件: tests.py 项目: pdc/kanbo
    def test_it_randomizes_names_If_collision(self):
        mock_func = Mock('func')
        mock_func.side_effect = [True, False]
        result = get_username({'username': '******'}, user_exists=mock_func)

        self.assertEqual('yar', result['username'][:3])
        self.assertTrue(re.match('[a-f0-9]{16}', result['username'][3:]))

        # Check it called the exists function twice.
        self.assertEqual(2, len(mock_func.call_args_list))
        self.assertEqual(call('yar'), mock_func.call_args_list[0])
        self.assertEqual(call(result['username']), mock_func.call_args_list[1])
示例#2
0
文件: tests.py 项目: pdc/kanbo
    def test_random_nantional_characters(self):
        result = get_username({'username': u'æÆßøØœŒåÅij'})

        self.assertEqual('aeaessoooeoeaaij', result['username'])
示例#3
0
文件: tests.py 项目: pdc/kanbo
    def test_it_mangles_lukasz_as_little_as_possible(self):
        # Most special letters get handled by the decompositoon step,
        # but the Polish Ł has no decomposition info.
        result = get_username({'username': u'ŁukaszKorecki'}, user_exists=lambda u: False)

        self.assertEqual('lukaszkorecki', result['username'])
示例#4
0
文件: tests.py 项目: pdc/kanbo
    def test_asciification_drops_accents(self):
        result = get_username({'username': '******'}, user_exists=lambda u: False)

        self.assertEqual('zoe', result['username'])
示例#5
0
文件: tests.py 项目: pdc/kanbo
    def test_it_shortens_proffered_username(self):
        result = get_username({'username': '******'}, user_exists=lambda u: False)

        self.assertEqual('long-name-more-than-thirty-cha', result['username'])
示例#6
0
文件: tests.py 项目: pdc/kanbo
    def test_it_slugifies_proffered_username(self):
        result = get_username({'username': '******'}, user_exists=lambda u: False)

        self.assertEqual('mister-apple-cheeks', result['username'])
示例#7
0
文件: tests.py 项目: pdc/kanbo
    def test_it_uses_proffered_username(self):
        result = get_username({'username': '******'}, user_exists=lambda u: False)

        self.assertEqual('smarfpon3', result['username'])
示例#8
0
文件: tests.py 项目: pdc/kanbo
    def test_it_uses_existing_user_if_supplied(self):
        user = User.objects.create(username='******')
        result = get_username({}, user)

        self.assertEqual('bantha69', result['username'])