add tests

This commit is contained in:
imperosol
2026-06-11 14:22:38 +02:00
parent 867362fb51
commit 998efc7c6b
4 changed files with 47 additions and 6 deletions
+16 -3
View File
@@ -144,6 +144,8 @@ class TestRefilling(TestFullClickBase):
assert self.updated_amount(self.customer) == 0
def test_refilling_no_refer_fail(self):
"""Check that the refill fails is the HTTP_REFERER header is missing"""
def refill():
return self.client.post(
reverse(
@@ -157,13 +159,13 @@ class TestRefilling(TestFullClickBase):
)
self.client.force_login(self.club_admin)
assert refill()
assert refill().status_code == 403
self.client.force_login(self.root)
assert refill()
assert refill().status_code == 403
self.client.force_login(self.subscriber)
assert refill()
assert refill().status_code == 403
assert self.updated_amount(self.customer) == 0
@@ -199,6 +201,17 @@ class TestRefilling(TestFullClickBase):
== 404
)
def test_refilling_above_limit_fails(self):
"""Test that it's forbidden to refill a customer above the limit."""
self.login_in_bar()
limit = settings.SITH_ACCOUNT_MAX_MONEY
# create a refilling to check that current balance is taken into account
baker.make(Refilling, customer=self.customer.customer, amount=limit // 2)
response = self.refill_user(self.customer, self.counter, (limit // 2) + 1)
assert response.status_code == 200 # no redirect = failure
self.customer.customer.refresh_from_db()
assert self.updated_amount(self.customer) == limit // 2
def test_refilling_counter_success(self):
self.login_in_bar()