예제 #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'])