gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] 05/05: fix /history test, as moving admin test


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] 05/05: fix /history test, as moving admin test into the other tests file altered the way row_ids are defined during the test run.
Date: Wed, 10 May 2017 16:22:08 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

commit 58127cb13b509e7d17f0d6d59a1e10160e14636a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed May 10 14:13:55 2017 +0200

    fix /history test, as moving admin test into the other tests file
    altered the way row_ids are defined during the test run.
---
 talerbank/app/tests.py | 80 +++++++++++++++++++++++++-------------------------
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 3d93e5a..2461124 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -18,7 +18,7 @@ from django.test import TestCase, Client
 from django.core.urlresolvers import reverse
 from django.conf import settings
 from django.contrib.auth.models import User
-from .models import BankAccount
+from .models import BankAccount, BankTransaction
 from . import urls
 from . import amounts
 from .views import wire_transfer
@@ -31,6 +31,7 @@ logger = logging.getLogger(__name__)
 def clearDb():
     User.objects.all().delete()
     BankAccount.objects.all().delete()
+    BankTransaction.objects.all().delete()
 
 
 class RegisterTestCase(TestCase):
@@ -88,6 +89,40 @@ class AmountTestCase(TestCase):
         self.assertEqual(1, amounts.amount_cmp(a2, a1))
         self.assertEqual(0, amounts.amount_cmp(a1, _a1))
 
+class AddIncomingTestCase(TestCase):
+    """Test money transfer's API"""
+
+    def setUp(self):
+        bank = User.objects.create_user(username="bank_user",
+                                        password="bank_password")
+        bank_account = BankAccount(user=bank,
+                                   currency=settings.TALER_CURRENCY)
+        user = User.objects.create_user(username="user_user",
+                                        password="user_password")
+        user_account = BankAccount(user=user,
+                                   currency=settings.TALER_CURRENCY)
+        bank_account.save()
+        user_account.save()
+
+    def tearDown(self):
+        clearDb()
+
+    def test_add_incoming(self):
+        c = Client()
+        data = '{"auth": {"type": "basic"}, \
+                 "credit_account": 1, \
+                 "wtid": "TESTWTID", \
+                 "exchange_url": "https://exchange.test";, \
+                 "amount": \
+                   {"value": 1, \
+                    "fraction": 0, \
+                    "currency": "%s"}}' \
+               % settings.TALER_CURRENCY
+        response = c.post(reverse("add-incoming", urlconf=urls),
+                          data=data,
+                          content_type="application/json",
+                          follow=True, **{"HTTP_X_TALER_BANK_USERNAME": 
"user_user", "HTTP_X_TALER_BANK_PASSWORD": "user_password"})
+        self.assertEqual(200, response.status_code)
 
 class HistoryTestCase(TestCase):
 
@@ -132,9 +167,11 @@ class HistoryTestCase(TestCase):
         data = response.content.decode("utf-8")
         data = json.loads(data)
         self.assertEqual(data["data"][0]["subject"], "h")
-        # Get non-existent record: the latest plus one in the future
-        response = c.get(reverse("history", urlconf=urls), {"auth": "basic", 
"delta": "1", "start": "10"},
+        # Get non-existent record: the latest plus one in the future: 
transaction "h" takes row_id 11
+        response = c.get(reverse("history", urlconf=urls), {"auth": "basic", 
"delta": "1", "start": "11"},
                          **{"HTTP_X_TALER_BANK_USERNAME": "User", 
"HTTP_X_TALER_BANK_PASSWORD": "Password"})
+        response_txt = response.content.decode("utf-8")
+        logger.info(response_txt)
         self.assertEqual(204, response.status_code)
         # Get credit records
         response = c.get(reverse("history", urlconf=urls), {"auth": "basic", 
"delta": "+1", "direction": "credit"},
@@ -201,40 +238,3 @@ class DebitTestCase(TestCase):
         tmp["value"] = 1
 
         self.assertEqual(0, amounts.amount_cmp(ub0.balance_obj, tmp))
-
-class AddIncomingTestCase(TestCase):
-    """Test money transfer's API"""
-
-    def setUp(self):
-        bank = User.objects.create_user(username="bank_user",
-                                        password="bank_password")
-        bank_account = BankAccount(user=bank,
-                                   currency=settings.TALER_CURRENCY)
-        user = User.objects.create_user(username="user_user",
-                                        password="user_password")
-        user_account = BankAccount(user=user,
-                                   currency=settings.TALER_CURRENCY)
-        bank_account.save()
-        user_account.save()
-
-    def tearDown(self):
-        User.objects.all().delete()
-        BankAccount.objects.all().delete()
-
-    def test_add_incoming(self):
-        c = Client()
-        data = '{"auth": {"type": "basic"}, \
-                 "credit_account": 1, \
-                 "wtid": "TESTWTID", \
-                 "exchange_url": "https://exchange.test";, \
-                 "amount": \
-                   {"value": 1, \
-                    "fraction": 0, \
-                    "currency": "%s"}}' \
-               % settings.TALER_CURRENCY
-        response = c.post(reverse("add-incoming", urlconf=urls),
-                          data=data,
-                          content_type="application/json",
-                          follow=True, **{"HTTP_X_TALER_BANK_USERNAME": 
"user_user", "HTTP_X_TALER_BANK_PASSWORD": "user_password"})
-        logger.info(response.content.decode("utf-8"))
-        self.assertEqual(200, response.status_code)

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]