[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-donations] branch master updated: testcase
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-donations] branch master updated: testcase |
Date: |
Sat, 25 Nov 2017 10:41:22 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository donations.
The following commit(s) were added to refs/heads/master by this push:
new 924a8d2 testcase
924a8d2 is described below
commit 924a8d24255637bfb0053a54a5d4ca997a59ca91
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sat Nov 25 10:40:25 2017 +0100
testcase
---
Makefile.in | 2 +-
talerdonations/tests.conf | 5 ++++
talerdonations/tests.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index dbe1651..07f0eb9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -48,5 +48,5 @@ install: $(templates) install-data
# run testcases
.PHONY: check
check:
- @export address@hidden@/talersurvey/tests.conf; \
+ @export address@hidden@/talerdonations/tests.conf; \
python3 talerdonations/tests.py
diff --git a/talerdonations/tests.conf b/talerdonations/tests.conf
index e69de29..8f18f90 100644
--- a/talerdonations/tests.conf
+++ b/talerdonations/tests.conf
@@ -0,0 +1,5 @@
+[taler]
+CURRENCY = TESTKUDOS
+
+[frontends]
+BACKEND = http://backend.test.taler.net/
diff --git a/talerdonations/tests.py b/talerdonations/tests.py
index e69de29..48ef764 100644
--- a/talerdonations/tests.py
+++ b/talerdonations/tests.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+
+import unittest
+from mock import patch, MagicMock
+from talerdonations.donations import donations
+from talerdonations.talerconfig import TalerConfig
+from datetime import datetime
+
+tc = TalerConfig.from_env()
+CURRENCY = tc["taler"]["currency"].value_string(required=True)
+
+class DonationsTestCase(unittest.TestCase):
+ def setUp(self):
+ donations.app.testing = True
+ self.app = donations.app.test_client()
+
+ @patch("requests.post")
+ @patch("random.randint")
+ @patch("datetime.datetime")
+ def test_proposal_creation(self, mocked_datetime,
+ mocked_random, mocked_post):
+ mocked_datetime.today.return_value = datetime.today()
+ mocked_random.return_value = 333
+ order_id = "donation-%s-%X-%s" % \
+ ("Tor", mocked_random(),
mocked_datetime.today().strftime("%H_%M_%S"))
+ ret_post = MagicMock()
+ ret_post.status_code = 200
+ ret_post.json.return_value = {}
+ mocked_post.return_value = ret_post
+ self.app.get(
+
"/generate-contract?nonce=44&donation_receiver=Tor&donation_amount=1.0")
+ mocked_post.assert_called_with(
+ "http://backend.test.taler.net/proposal", json={
+ "order": {
+ "summary": "Donation!",
+ "order_id": order_id,
+ "nonce": "44",
+ "amount": {
+ "value": 1,
+ "fraction": 0,
+ "currency": CURRENCY},
+ "max_fee": {
+ "value": 1,
+ "fraction": 0,
+ "currency": CURRENCY},
+ "order_id": order_id,
+ "products": [{
+ "description": "Donation to Tor",
+ "quantity": 1,
+ "product_id": 0,
+ "price": {
+ "value": 1,
+ "fraction": 0,
+ "currency": CURRENCY}}],
+ "fulfillment_url":
+ "http://localhost/fulfillment?order_id=%s" % order_id,
+ "pay_url": "http://localhost/pay",
+ "merchant": {
+ "instance": "Tor",
+ "address": "nowhere",
+ "name": "Kudos Inc.",
+ "jurisdiction": "none"}
+ }})
+
+if "__main__" == __name__:
+ unittest.main()
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-donations] branch master updated: testcase,
gnunet <=