gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-bank] 02/02: check withdrawing POSTs the expected da


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] 02/02: check withdrawing POSTs the expected data to exchange
Date: Wed, 15 Nov 2017 12:20:00 +0100

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

marcello pushed a commit to branch master
in repository bank.

commit 477f3bcf115abb84fbe6e5a27b8845da6a5ff6ab
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Nov 15 12:18:02 2017 +0100

    check withdrawing POSTs the expected data to exchange
---
 talerbank/app/tests.py | 30 +++++++++++++++++++++++++-----
 talerbank/app/views.py | 10 ----------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 2a76f62..55bea32 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -15,7 +15,6 @@
 #  @author Marcello Stanisci
 
 import json
-import hashlib
 from django.test import TestCase, Client
 from django.core.urlresolvers import reverse
 from django.conf import settings
@@ -35,7 +34,8 @@ class WithdrawTestCase(TestCase):
     def setUp(self):
         user_bankaccount = BankAccount(
             user=User.objects.create_user(username="test_user",
-                                          password="test_password"))
+                                          password="test_password"),
+            account_no=100)
         user_bankaccount.save()
 
         exchange_bankaccount = BankAccount(
@@ -45,7 +45,9 @@ class WithdrawTestCase(TestCase):
         exchange_bankaccount.save()
     
     @patch('hashlib.new') # Need to patch update() and hexdigest() methods.
-    def test_withdraw(self, mocked_hashlib):
+    @patch('requests.post')
+    @patch('time.time')
+    def test_withdraw(self, mocked_time, mocked_post, mocked_hashlib):
         client = Client()
         wire_details = '''{
             "test": {
@@ -74,10 +76,28 @@ class WithdrawTestCase(TestCase):
         hasher.hexdigest = MagicMock()
         hasher.hexdigest.return_value = "0"
         mocked_hashlib.return_value = hasher
-
+        post = MagicMock()
+        post.status_code = 200
+        mocked_post.return_value = post
+        mocked_time.return_value = 0
         response = client.post(reverse("pin-verify", urlconf=urls),
                                {"pin_1": "0"})
-        print(response.content)
+        expected_json = {
+            "reserve_pub": "UVZ789",
+            "execution_date": "/Date(0)/",
+            "sender_account_details": {
+                "type": "test",
+                "bank_uri": "http://testserver/";,
+                "account_number": 100 
+                },
+            "transfer_details": {"timestamp": 0},
+            "amount": {
+                "value": 0,
+                "fraction": 1,
+                "currency": settings.TALER_CURRENCY} 
+        }
+        
mocked_post.assert_called_with("http://exchange.example/admin/add/incoming";,
+                                       json=expected_json)
 
 class RegisterTestCase(TestCase):
     """User registration"""
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 1e8d56f..8900c87 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -15,16 +15,6 @@
 #  @author Marcello Stanisci
 #  @author Florian Dold
 
-# wire_transfer() needs to be wrapped in such a way that
-# any possible exception is caught in *one* place.  It is used when:
-#
-# 1. withdrawing is finalized (pin_tan_verify())
-# 2. a new user is registered (register())
-# 3. the exchange moves money to account X (add_incoming())
-#
-# NOTE: this abstracting function needs _sometimes_ to update the
-# session, depending on the situation.
-
 from urllib.parse import urljoin
 from functools import wraps
 import json

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



reply via email to

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