Exemplo n.º 1
0
 def test_duplicate_username_counter(self, filter):
     filter = (filter.expects_call().returns_fake().expects('count')
                                                   .returns(1)
                                                   .next_call()
                                                   .returns(1)
                                                   .next_call()
                                                   .returns(0))
     eq_(autocreate_username('existingname'), 'existingname3')
Exemplo n.º 2
0
 def test_too_many_tries(self, filter):
     filter = filter.is_callable().returns_fake().provides("count").returns(1)
     for i in range(3):
         # Simulate existing username.
         filter = filter.next_call().returns(1)
     # Simulate available username.
     filter = filter.next_call().returns(0)
     # After the third try, give up, and generate a random string username.
     un = autocreate_username("base")
     assert not un.startswith("base"), "Unexpected: %s" % un
Exemplo n.º 3
0
 def test_too_many_tries(self, filter):
     filter = (
         filter.is_callable().returns_fake().provides('count').returns(1))
     for i in range(3):
         # Simulate existing username.
         filter = filter.next_call().returns(1)
     # Simulate available username.
     filter = filter.next_call().returns(0)
     # After the third try, give up, and generate a random string username.
     un = autocreate_username('base')
     assert not un.startswith('base'), 'Unexpected: %s' % un
Exemplo n.º 4
0
 def test_duplicate_username_counter(self, filter):
     filter = (
         filter.expects_call()
         .returns_fake()
         .expects("count")
         .returns(1)
         .next_call()
         .returns(1)
         .next_call()
         .returns(0)
     )
     eq_(autocreate_username("existingname"), "existingname3")
Exemplo n.º 5
0
 def test_duplicate_django_username_counter(self, du, up):
     up = up.expects_call().returns_fake().expects("count").returns(0)
     du = (
         du.expects_call()
         .returns_fake()
         .expects("count")
         .returns(1)
         .next_call()
         .returns(1)
         .next_call()
         .returns(1)
         .next_call()
         .returns(0)
     )
     eq_(autocreate_username("existingname"), "existingname4")
Exemplo n.º 6
0
 def test_empty_username_is_a_random_hash(self):
     un = autocreate_username('.+')  # this shouldn't happen but it could!
     assert len(un) and not un.startswith('.+'), 'Unexpected: %s' % un
Exemplo n.º 7
0
 def test_invalid_characters(self):
     eq_(autocreate_username('testaccount+slug'), 'testaccountslug')
Exemplo n.º 8
0
 def test_duplicate_django_username_counter(self, du, up):
     up = up.expects_call().returns_fake().expects('count').returns(0)
     du = (du.expects_call().returns_fake().expects('count').returns(
         1).next_call().returns(1).next_call().returns(
             1).next_call().returns(0))
     eq_(autocreate_username('existingname'), 'existingname4')
Exemplo n.º 9
0
 def test_too_long(self):
     un = autocreate_username('f' + 'u' * 255)
     assert not un.startswith('fuuuuuuuuuuuuuuuuuu'), 'Unexpected: %s' % un
Exemplo n.º 10
0
 def test_blacklisted(self):
     BlacklistedUsername.objects.create(username='******')
     un = autocreate_username('firefox')
     assert un != 'firefox', 'Unexpected: %s' % un
Exemplo n.º 11
0
 def test_empty_username_is_a_random_hash(self):
     un = autocreate_username('.+')  # this shouldn't happen but it could!
     assert len(un) and not un.startswith('.+'), 'Unexpected: %s' % un
Exemplo n.º 12
0
 def test_invalid_characters(self):
     eq_(autocreate_username('testaccount+slug'), 'testaccountslug')
Exemplo n.º 13
0
 def test_too_long(self):
     un = autocreate_username('f' + 'u' * 255)
     assert not un.startswith('fuuuuuuuuuuuuuuuuuu'), 'Unexpected: %s' % un
Exemplo n.º 14
0
 def test_blacklisted(self):
     BlacklistedName.objects.create(name='firefox')
     un = autocreate_username('firefox')
     assert un != 'firefox', 'Unexpected: %s' % un
Exemplo n.º 15
0
 def test_too_long(self):
     un = autocreate_username("f" + "u" * 255)
     assert not un.startswith("fuuuuuuuuuuuuuuuuuu"), "Unexpected: %s" % un
Exemplo n.º 16
0
 def test_blacklisted(self):
     BlacklistedUsername.objects.create(username="******")
     un = autocreate_username("firefox")
     assert un != "firefox", "Unexpected: %s" % un