Skip to content

Commit

Permalink
add few more test for admin filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed May 28, 2024
1 parent 1e4d771 commit 6862a51
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hordak/tests/admin/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ def test_search_query(self):
'?_changelist_filters=q%3DBank">Bank account</a>',
html=True,
)
self.assertContains(res, '<p class="paginator">1 account</p>', html=True)

def test_filter_query(self):
"""Test that filter query works"""
superuser = get_user_model().objects.create_superuser(username="superuser")
self.client.force_login(superuser)
url = reverse("admin:hordak_account_changelist")
res = self.client.get(url + "?type__exact=AS")
self.assertContains(
res,
f'<a href="/admin/hordak/account/{self.bank_account.id}/change/'
'?_changelist_filters=type__exact%3DAS">Bank account</a>',
html=True,
)
self.assertContains(res, '<p class="paginator">1 account</p>', html=True)

def test_filter_query_liability(self):
"""Test that filter query works"""
superuser = get_user_model().objects.create_superuser(username="superuser")
self.client.force_login(superuser)
url = reverse("admin:hordak_account_changelist")
res = self.client.get(url + "?type__exact=LI")
self.assertContains(res, '<p class="paginator">0 accounts</p>', html=True)

def test_account_edit(self):
"""Test account edit page"""
Expand Down

0 comments on commit 6862a51

Please sign in to comment.