rename find_available_username → get_free_username
This commit is contained in:
parent
4fa042079f
commit
62c2a742d4
2 changed files with 4 additions and 4 deletions
|
@ -57,7 +57,7 @@ class ENSCASBackend:
|
||||||
year = get_entrance_year(attributes)
|
year = get_entrance_year(attributes)
|
||||||
return self._get_or_create(uid, year)
|
return self._get_or_create(uid, year)
|
||||||
|
|
||||||
def find_available_username(self, clipper_uid):
|
def get_free_username(self, clipper_uid):
|
||||||
"""Find an available username for the new user.
|
"""Find an available username for the new user.
|
||||||
|
|
||||||
If you override this method, make sure it returns a username that is not taken
|
If you override this method, make sure it returns a username that is not taken
|
||||||
|
@ -93,7 +93,7 @@ class ENSCASBackend:
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
if user is None:
|
if user is None:
|
||||||
username = self.find_available_username(uid)
|
username = self.get_free_username(uid)
|
||||||
user = UserModel.objects.create_user(username=username)
|
user = UserModel.objects.create_user(username=username)
|
||||||
Clipper.objects.create(user=user, entrance_year=entrance_year, uid=uid)
|
Clipper.objects.create(user=user, entrance_year=entrance_year, uid=uid)
|
||||||
return user
|
return user
|
||||||
|
|
|
@ -14,11 +14,11 @@ class TestBackend(TestCase):
|
||||||
def test_usernames_uniqueness(self):
|
def test_usernames_uniqueness(self):
|
||||||
backend = ENSCASBackend()
|
backend = ENSCASBackend()
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
username = backend.find_available_username("toto")
|
username = backend.get_free_username("toto")
|
||||||
self.assertFalse(UserModel.objects.filter(username=username).exists())
|
self.assertFalse(UserModel.objects.filter(username=username).exists())
|
||||||
UserModel.objects.create(username=username)
|
UserModel.objects.create(username=username)
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
username = backend.find_available_username("tutu")
|
username = backend.get_free_username("tutu")
|
||||||
self.assertFalse(UserModel.objects.filter(username=username).exists())
|
self.assertFalse(UserModel.objects.filter(username=username).exists())
|
||||||
UserModel.objects.create(username=username)
|
UserModel.objects.create(username=username)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue