[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] 02/04: testing empty responses from /history
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] 02/04: testing empty responses from /history |
Date: |
Sun, 07 May 2017 13:08:43 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository bank.
commit 6225b374a7f1112f9f538ceb4536cd157be9bd89
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sun May 7 12:09:46 2017 +0200
testing empty responses from /history
---
talerbank/app/tests.py | 9 ++++++---
talerbank/app/views.py | 2 ++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 4f81bcb..929ab70 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -121,7 +121,6 @@ class HistoryTestCase(TestCase):
# Get a delta=+1 record in the middle of the list: FAILS
response = c.get(reverse("history", urlconf=urls), {"auth": "basic",
"delta": "+1", "start": "5"},
**{"HTTP_X_TALER_BANK_USERNAME": "User",
"HTTP_X_TALER_BANK_PASSWORD": "Password"})
- logger.info(response.content.decode("utf-8"))
data = response.content.decode("utf-8")
data = json.loads(data)
self.assertEqual(data["data"][0]["row_id"], 6)
@@ -136,8 +135,12 @@ class HistoryTestCase(TestCase):
# Get non-existent record: the latest plus one in the future
response = c.get(reverse("history", urlconf=urls), {"auth": "basic",
"delta": "+1", "start": "10"},
**{"HTTP_X_TALER_BANK_USERNAME": "User",
"HTTP_X_TALER_BANK_PASSWORD": "Password"})
- data = response.content.decode("utf-8")
- self.assertJSONEqual(data, {"data": []})
+ self.assertEqual(204, response.status_code)
+
+ # Get credit records
+ response = c.get(reverse("history", urlconf=urls), {"auth": "basic",
"delta": "+1", "direction": "credit"},
+ **{"HTTP_X_TALER_BANK_USERNAME": "User",
"HTTP_X_TALER_BANK_PASSWORD": "Password"})
+ self.assertEqual(204, response.status_code)
# This tests whether a bank account goes red and then
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 7d2cb6d..fcdf7f0 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -378,6 +378,8 @@ def history(request):
# FIXME *DO* return 204 No content when history is empty.
qs = BankTransaction.objects.filter(query_string,
sign_filter).order_by("%sid" % sign)[:delta]
+ if 0 == qs.count():
+ return HttpResponse(status=204)
for entry in qs:
counterpart = entry.credit_account.user.username
sign_ = "-"
--
To stop receiving notification emails like this one, please contact
address@hidden