Skip to content

Commit

Permalink
Merge pull request mozilla#5932 from escattone/fix-users-api-test-cas…
Browse files Browse the repository at this point in the history
…e-1479

explicitly set the profile name to avoid random test errors
  • Loading branch information
akatsoulas authored Apr 1, 2024
2 parents 0d1a6e7 + 9c76e06 commit 290e6ae
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kitsune/users/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UsernamesTests(TestCase):
url = reverse("users.api.usernames", locale="en-US")

def setUp(self):
self.u = UserFactory(username="testUser")
self.u = UserFactory(username="testUser", profile__name="Ringo")
self.client.login(username=self.u.username, password="testpass")

def tearDown(self):
Expand All @@ -41,7 +41,13 @@ def test_query_old(self):
self.assertEqual(0, len(data))

def test_query_current(self):
res = self.client.get(urlparams(self.url, term=self.u.username[0]))
# Test that we case-insensitively search the user's username.
res = self.client.get(urlparams(self.url, term=self.u.username[0].upper()))
self.assertEqual(200, res.status_code)
data = json.loads(res.content)
self.assertEqual(1, len(data))
# Test that we also case-insensitively search the name of the user's profile.
res = self.client.get(urlparams(self.url, term=self.u.profile.name.lower()))
self.assertEqual(200, res.status_code)
data = json.loads(res.content)
self.assertEqual(1, len(data))
Expand Down

0 comments on commit 290e6ae

Please sign in to comment.