summaryrefslogtreecommitdiff
path: root/talersurvey/tests.py
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2017-11-24 12:05:05 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2017-11-24 12:05:05 +0100
commit407b62e27e7c72d1681ae0524183486abb8bce5f (patch)
tree07b57ce36f793e926e7fac386844b6709127cc18 /talersurvey/tests.py
parent413a3100f126419144fba94981f1dad732c3d71d (diff)
downloadsurvey-407b62e27e7c72d1681ae0524183486abb8bce5f.tar.gz
survey-407b62e27e7c72d1681ae0524183486abb8bce5f.tar.bz2
survey-407b62e27e7c72d1681ae0524183486abb8bce5f.zip
enabling testcases
Diffstat (limited to 'talersurvey/tests.py')
-rw-r--r--talersurvey/tests.py37
1 files changed, 37 insertions, 0 deletions
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()