summaryrefslogtreecommitdiff
path: root/talersurvey
diff options
context:
space:
mode:
Diffstat (limited to 'talersurvey')
-rw-r--r--talersurvey/tests.conf6
-rw-r--r--talersurvey/tests.py37
2 files changed, 43 insertions, 0 deletions
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()