rename find_available_username → get_free_username

This commit is contained in:
Martin Pépin 2020-05-12 21:28:23 +02:00
parent 4fa042079f
commit 62c2a742d4
2 changed files with 4 additions and 4 deletions

View file

@ -57,7 +57,7 @@ class ENSCASBackend:
year = get_entrance_year(attributes)
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.
If you override this method, make sure it returns a username that is not taken
@ -93,7 +93,7 @@ class ENSCASBackend:
user = None
if user is None:
username = self.find_available_username(uid)
username = self.get_free_username(uid)
user = UserModel.objects.create_user(username=username)
Clipper.objects.create(user=user, entrance_year=entrance_year, uid=uid)
return user

View file

@ -14,11 +14,11 @@ class TestBackend(TestCase):
def test_usernames_uniqueness(self):
backend = ENSCASBackend()
for _ in range(10):
username = backend.find_available_username("toto")
username = backend.get_free_username("toto")
self.assertFalse(UserModel.objects.filter(username=username).exists())
UserModel.objects.create(username=username)
for _ in range(10):
username = backend.find_available_username("tutu")
username = backend.get_free_username("tutu")
self.assertFalse(UserModel.objects.filter(username=username).exists())
UserModel.objects.create(username=username)