Skip to content

Commit

Permalink
Make merge suggestion test independent of localsettings (#2112)
Browse files Browse the repository at this point in the history
* Make merge suggestion test independent of localsettings
  • Loading branch information
richardebeling authored Feb 12, 2024
1 parent aee330f commit 3da7e4f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions evap/staff/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@ def setUpTestData(cls):
cls.main_user = baker.make(UserProfile, _fill_optional=["email"])
cls.other_user = baker.make(UserProfile, _fill_optional=["email"])

# The merge candidate is created first, so the account is older.
cls.suggested_merge_candidate = baker.make(UserProfile, email="user@student.institution.example.com")
cls.suggested_main_user = baker.make(UserProfile, email="user@institution.example.com")

def test_redirection_user_merge_view(self):
page = self.app.get(self.url, user=self.manager)

Expand All @@ -364,15 +360,17 @@ def test_redirection_user_merge_view(self):
self.assertContains(page, self.main_user.email)
self.assertContains(page, self.other_user.email)

@override_settings(INSTITUTION_EMAIL_DOMAINS=["institution.example.com", "student.institution.example.com"])
def test_suggested_merge(self):
suggested_merge_candidate = baker.make(UserProfile, email="user@student.institution.example.com")
suggested_main_user = baker.make(UserProfile, email="user@institution.example.com")

self.assertLess(suggested_merge_candidate.pk, suggested_main_user.pk)

page = self.app.get(self.url, user=self.manager)

expected_url = reverse(
"staff:user_merge", args=[self.suggested_main_user.id, self.suggested_merge_candidate.id]
)
unexpected_url = reverse(
"staff:user_merge", args=[self.suggested_merge_candidate.id, self.suggested_main_user.id]
)
expected_url = reverse("staff:user_merge", args=[suggested_main_user.pk, suggested_merge_candidate.pk])
unexpected_url = reverse("staff:user_merge", args=[suggested_merge_candidate.pk, suggested_main_user.pk])

self.assertContains(page, f'<a href="{expected_url}"')
self.assertNotContains(page, f'<a href="{unexpected_url}"')
Expand Down

0 comments on commit 3da7e4f

Please sign in to comment.