gnunet-svn
[Top][All Lists]
Advanced

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

[taler-bank] branch master updated: use helper


From: gnunet
Subject: [taler-bank] branch master updated: use helper
Date: Thu, 27 Aug 2020 12:42:05 +0200

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

ms pushed a commit to branch master
in repository bank.

The following commit(s) were added to refs/heads/master by this push:
     new 35c6e5e  use helper
35c6e5e is described below

commit 35c6e5e2708df14f49f462c7857cd3294e52bd3f
Author: MS <ms@taler.net>
AuthorDate: Thu Aug 27 12:41:57 2020 +0200

    use helper
---
 talerbank/app/tests.py | 36 +++++++++++++++++++++---------------
 talerbank/app/urls.py  |  1 +
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 6617ced..d91aca4 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -65,7 +65,7 @@ def clear_db():
         cursor.execute("ALTER SEQUENCE app_banktransaction_id_seq RESTART")
 
 # Testing the "Access API":
-#     (testing) registration* + ask for balance* + withdraw: create* / ask 
status / abort / confirm.
+#     (testing) registration* + ask for balance* + withdraw: create* / ask 
status* / abort* / confirm.
 class AccessApiWithdrawTestCase(TestCase):
     def setUp(self):
         clear_db()
@@ -76,36 +76,42 @@ class AccessApiWithdrawTestCase(TestCase):
             balance=SignedAmount(True, Amount(settings.TALER_CURRENCY, 100, 0))
         )
         self.user_bank_account.save()
+        self.client = Client()
 
-    def test_withdraw_create(self):
-        c = Client()
-        r = c.post(
+    def create_withdrawal(self):
+        r = self.client.post(
             reverse("access-api-withdrawal", 
kwargs=dict(acct_id="RandomUser")),
             HTTP_AUTHORIZATION=make_auth_line("RandomUser", "XYZ"),
             content_type="application/json",
             data=dict(amount=f"{settings.TALER_CURRENCY}:5")
         )
         self.assertEqual(r.status_code, 200)
+        data = r.content.decode("utf-8")
+        data_dict = json.loads(data)
+        withdrawal_id = data_dict.get("withdrawal_id")
+        self.assertTrue(withdrawal_id)
+        return withdrawal_id
+
+    def test_withdraw_create(self):
+        self.create_withdrawal()
 
     def test_withdraw_status(self):
-        c = Client()
-        r = c.post(
-            reverse("access-api-withdrawal", 
kwargs=dict(acct_id="RandomUser")),
+        withdrawal_id = self.create_withdrawal()
+        r = self.client.get(
+            reverse("access-api-withdrawal-status",
+                    kwargs=dict(acct_id="RandomUser", wid=withdrawal_id)),
             HTTP_AUTHORIZATION=make_auth_line("RandomUser", "XYZ"),
-            content_type="application/json",
-            data=dict(amount=f"{settings.TALER_CURRENCY}:5")
         )
         self.assertEqual(r.status_code, 200)
-        data = r.content.decode("utf-8")
-        data_dict = json.loads(data)
-        withdrawal_id = data_dict.get("withdrawal_id")
+
+    def test_withdraw_abort(self):
+        withdrawal_id = self.create_withdrawal()
         self.assertTrue(withdrawal_id)
-        r = c.get(
-            reverse("access-api-withdrawal-status",
+        r = self.client.post(
+            reverse("access-api-withdrawal-abort",
                     kwargs=dict(acct_id="RandomUser", wid=withdrawal_id)),
             HTTP_AUTHORIZATION=make_auth_line("RandomUser", "XYZ"),
         )
-        print(r.content.decode("utf-8"))
         self.assertEqual(r.status_code, 200)
 
 class AccessApiBalanceTestCase(TestCase):
diff --git a/talerbank/app/urls.py b/talerbank/app/urls.py
index 9f2ab15..004bad6 100644
--- a/talerbank/app/urls.py
+++ b/talerbank/app/urls.py
@@ -75,6 +75,7 @@ taler_bank_accounts_api_patterns = [
     path(
         "accounts/<str:acct_id>/withdrawals/<str:wid>/abort",
         views.bank_accounts_api_abort_withdrawal,
+        name="access-api-withdrawal-abort"
     ),
     path("testing/withdraw", views.withdraw_headless, name="testing-withdraw"),
     path("testing/register", views.register_headless, 
name="testing-withdraw-register"),

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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