diff options
author | MS <ms@taler.net> | 2020-08-27 12:41:57 +0200 |
---|---|---|
committer | MS <ms@taler.net> | 2020-08-27 12:41:57 +0200 |
commit | 35c6e5e2708df14f49f462c7857cd3294e52bd3f (patch) | |
tree | f36e3e11aaefc50eac7e9fbe879925d4b561ada9 /talerbank/app | |
parent | d78c748c463999c401d673953e0f45b46e2c7a1b (diff) | |
download | bank-35c6e5e2708df14f49f462c7857cd3294e52bd3f.tar.gz bank-35c6e5e2708df14f49f462c7857cd3294e52bd3f.tar.bz2 bank-35c6e5e2708df14f49f462c7857cd3294e52bd3f.zip |
use helper
Diffstat (limited to 'talerbank/app')
-rw-r--r-- | talerbank/app/tests.py | 36 | ||||
-rw-r--r-- | 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"), |