gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-survey] branch master updated: enabling testcases


From: gnunet
Subject: [GNUnet-SVN] [taler-survey] branch master updated: enabling testcases
Date: Fri, 24 Nov 2017 12:05:26 +0100

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

marcello pushed a commit to branch master
in repository survey.

The following commit(s) were added to refs/heads/master by this push:
     new 407b62e  enabling testcases
407b62e is described below

commit 407b62e27e7c72d1681ae0524183486abb8bce5f
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Nov 24 12:05:05 2017 +0100

    enabling testcases
---
 Makefile.in            |  5 ++---
 talersurvey/tests.conf |  6 ++++++
 talersurvey/tests.py   | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index eb34733..f0028d2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -48,6 +48,5 @@ install: $(templates) install-data
 # run testcases
 .PHONY: check
 check:
-       @export TALER_CONFIG_FILE=./talersurvey/tests.conf; \
-        export address@hidden@/lib/python3.5/site-packages; \
-        python3 ./talersurvey/tests.py
+       @export address@hidden@/talersurvey/tests.conf; \
+        python3 talersurvey/tests.py
diff --git a/talersurvey/tests.conf b/talersurvey/tests.conf
new file mode 100644
index 0000000..8c82598
--- /dev/null
+++ b/talersurvey/tests.conf
@@ -0,0 +1,6 @@
+[taler]
+currency = TESTKUDOS
+
+[frontends]
+BACKEND = http://backend.test.taler.net/
+FRACTION = 100000000
diff --git a/talersurvey/tests.py b/talersurvey/tests.py
new file mode 100644
index 0000000..2ad119a
--- /dev/null
+++ b/talersurvey/tests.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import unittest
+from talersurvey.survey import survey
+from mock import patch, MagicMock
+from talersurvey.talerconfig import TalerConfig
+
+TC = TalerConfig.from_env()
+CURRENCY = TC["taler"]["currency"].value_string(required=True)
+
+class SurveyTestCase(unittest.TestCase):
+    def setUp(self):
+        survey.app.testing = True
+        self.app = survey.app.test_client()
+
+    @patch("requests.post")
+    def test_authorize(self, mocked_post):
+        ret_post = MagicMock()
+        ret_post.status_code = 200
+        ret_post.json.return_value = {
+            "tip_id": "Jeppo02",
+            "exchange_uri": "http://exchange.example.com/";,
+            "expiration": "/Date(2018)/"}
+        mocked_post.return_value = ret_post
+        # Actual preference's ignored.
+        self.app.post("/")
+        mocked_post.assert_called_with(
+            "http://backend.test.taler.net/tip-authorize";, json={
+            "amount": {
+                "value": 1,
+                "fraction": 0,
+                "currency": CURRENCY},
+            "instance": "default",
+            "justification": "Payment methods survey"})
+
+if __name__ == "__main__":
+    unittest.main()

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



reply via email to

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