[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch master updated: adapting to new amount
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch master updated: adapting to new amount format <curr>:x.y |
Date: |
Mon, 05 Feb 2018 10:47:51 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new 860d826 adapting to new amount format <curr>:x.y
860d826 is described below
commit 860d826caf185c7d259c00c3dd0d9c6820d5d192
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Feb 5 10:47:23 2018 +0100
adapting to new amount format <curr>:x.y
---
talerbank/app/schemas.py | 7 ++++++-
talerbank/app/tests.py | 27 +++++++--------------------
talerbank/app/views.py | 2 +-
3 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/talerbank/app/schemas.py b/talerbank/app/schemas.py
index 269d791..1ddb684 100644
--- a/talerbank/app/schemas.py
+++ b/talerbank/app/schemas.py
@@ -54,6 +54,7 @@ class JSONFieldException(ValueError):
self.http_status_code = http_status_code
super().__init__()
+'''
AMOUNT_SCHEMA = {
"type": "object",
"properties": {
@@ -62,7 +63,11 @@ AMOUNT_SCHEMA = {
"currency": {"type": "string",
"pattern": "^"+settings.TALER_CURRENCY+"$"}
}
-}
+}'''
+
+AMOUNT_SCHEMA = {
+ "type": "string",
+ "pattern": "^"+settings.TALER_CURRENCY+":([0-9]+)\.?([0-9]+)?$"}
WITHDRAW_SESSION_SCHEMA = {
"type": "object",
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index bebf876..f6ccb4b 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -257,10 +257,7 @@ class RejectTestCase(TestCase):
"credit_account": %d, \
"subject": "TESTWTID", \
"exchange_url": "https://exchange.test", \
- "amount": \
- {"value": 5, \
- "fraction": 0, \
- "currency": "%s"}}' \
+ "amount": "%s:5.0"}' \
% (rejecting.bankaccount.account_no,
settings.TALER_CURRENCY)
response = client.post(
@@ -270,7 +267,7 @@ class RejectTestCase(TestCase):
follow=True, **{
"HTTP_X_TALER_BANK_USERNAME": "rejected_user",
"HTTP_X_TALER_BANK_PASSWORD": "rejected_password"})
-
+ self.assertEqual(response.status_code, 200)
data = response.content.decode("utf-8")
jdata = json.loads(data)
rejected = User.objects.get(username="rejected_user")
@@ -307,10 +304,7 @@ class AddIncomingTestCase(TestCase):
"credit_account": 1, \
"subject": "TESTWTID", \
"exchange_url": "https://exchange.test", \
- "amount": \
- {"value": 1, \
- "fraction": 0, \
- "currency": "%s"}}' \
+ "amount": "%s:1.0"}' \
% settings.TALER_CURRENCY
response = client.post(
reverse("add-incoming", urlconf=urls),
@@ -324,11 +318,7 @@ class AddIncomingTestCase(TestCase):
"credit_account": 1, \
"subject": "TESTWTID", \
"exchange_url": "https://exchange.test", \
- "amount": \
- {"value": 1, \
- "fraction": 0, \
- "currency": "%s"}}' \
- % "WRONGCURRENCY"
+ "amount": "WRONGCURRENCY:1.0"}'
response = client.post(
reverse("add-incoming", urlconf=urls),
data=data,
@@ -336,17 +326,14 @@ class AddIncomingTestCase(TestCase):
follow=True,
**{"HTTP_X_TALER_BANK_USERNAME": "user_user",
"HTTP_X_TALER_BANK_PASSWORD": "user_password"})
- self.assertEqual(406, response.status_code)
+ # note: a bad currency request gets 400.
+ self.assertEqual(400, response.status_code)
# Try to go debit
data = '{"auth": {"type": "basic"}, \
"credit_account": 1, \
"subject": "TESTWTID", \
"exchange_url": "https://exchange.test", \
- "amount": \
- {"value": 50, \
- "fraction": 1, \
- "currency": "%s"}}' \
- % settings.TALER_CURRENCY
+ "amount": "%s:50.1"}' % settings.TALER_CURRENCY
response = client.post(
reverse("add-incoming", urlconf=urls),
data=data,
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 5f7d366..55686ce 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -561,7 +561,7 @@ def add_incoming(request, user_account):
subject = "%s %s" % (data["subject"], data["exchange_url"])
credit_account = BankAccount.objects.get(
account_no=data["credit_account"])
- wtrans = wire_transfer(Amount(**data["amount"]),
+ wtrans = wire_transfer(Amount.parse(data["amount"]),
user_account.bankaccount,
credit_account,
subject)
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-bank] branch master updated: adapting to new amount format <curr>:x.y,
gnunet <=