Skip to content

Commit

Permalink
[chores] Minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Mar 7, 2022
1 parent e4dc71f commit da1870e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions openwisp_radius/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ def has_key(key):
# Phone number is given preference over email and username.
if has_key('phone_number'):
user_lookup |= Q(phone_number=data['phone_number'])
if has_key('email'):
user_lookup |= Q(email=data['email'])
if has_key('username'):
user_lookup |= Q(username=data['username'])
if has_key('email'):
user_lookup |= Q(email=data['email'])
users = User.objects.filter(user_lookup).values_list('id', flat=True)
if not users:
# Error is not related to cross organization registration
Expand Down
5 changes: 2 additions & 3 deletions openwisp_radius/tests/test_api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ def test_register_duplicate_different_org(self):
self.assertEqual(OrganizationUser.objects.count(), org_user_count + 2)

with self.subTest('Test user already registered with organization'):
# Make test_user2 organization user for org2.
# Make test_user2 member of org2.
# The query will give preference to phone_number which
# will return HTTP 409 response. But since the other
# information belongs to user which already has account
# information belongs to an user which already has account
# with this organization, it should return HTTP 400.
OrganizationUser.objects.create(user=test_user2, organization=org2)
# User combination of username, email and phone number
Expand All @@ -291,7 +291,6 @@ def test_register_duplicate_different_org(self):
'password2': 'password',
}
response = self.client.post(url, data=params)
print(response.data)
self.assertEqual(response.status_code, 400)
self.assertEqual(User.objects.count(), init_user_count + 2)
self.assertEqual(OrganizationUser.objects.count(), org_user_count + 3)
Expand Down

0 comments on commit da1870e

Please sign in to comment.