diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2017-11-25 10:29:34 +0100 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2017-11-25 10:29:34 +0100 |
commit | b5abafccc2326b6abf0c71d2e3f211b4a9c0b47c (patch) | |
tree | d706514642fec9d34bfdf9d70db07f961cd0c34c /talerblog | |
parent | bc4886f00d243697374ac2013cf469d3481ebd89 (diff) | |
download | blog-b5abafccc2326b6abf0c71d2e3f211b4a9c0b47c.tar.gz blog-b5abafccc2326b6abf0c71d2e3f211b4a9c0b47c.tar.bz2 blog-b5abafccc2326b6abf0c71d2e3f211b4a9c0b47c.zip |
testcase
Diffstat (limited to 'talerblog')
-rw-r--r-- | talerblog/tests.conf | 8 | ||||
-rw-r--r-- | talerblog/tests.py | 55 |
2 files changed, 63 insertions, 0 deletions
diff --git a/talerblog/tests.conf b/talerblog/tests.conf index e69de29..05d3310 100644 --- a/talerblog/tests.conf +++ b/talerblog/tests.conf @@ -0,0 +1,8 @@ +[taler] +CURRENCY = TESTKUDOS + +[frontends] +BACKEND = http://backend.test.taler.net/ + +[blog] +INSTANCE = FSF diff --git a/talerblog/tests.py b/talerblog/tests.py index e69de29..cf9dbc6 100644 --- a/talerblog/tests.py +++ b/talerblog/tests.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +import unittest +from mock import patch, MagicMock +from talerfrontends.blog import blog +from talerfrontends.talerconfig import TalerConfig + +tc = TalerConfig.from_env() +CURRENCY = tc["taler"]["currency"].value_string(required=True) + +class BlogTestCase(unittest.TestCase): + def setUp(self): + blog.app.testing = True + self.app = blog.app.test_client() + + @patch("requests.post") + def test_proposal_creation(self, mocked_post): + 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=55&article_name=Check_Me") + mocked_post.assert_called_with( + "http://backend.test.taler.net/proposal", + json={ + "order": { + "summary": "Check Me", + "nonce": "55", + "amount": { + "value": 1, + "fraction": 0, + "currency": CURRENCY}, + "max_fee": { + "value": 1, + "fraction": 0, + "currency": CURRENCY}, + "products": [{ + "description": "Essay: Check Me", + "quantity": 1, + "product_id": 0, + "price": { + "value": 1, + "fraction": 0, + "currency": CURRENCY}}], + "fulfillment_url": "http://localhost/essay/Check_Me", + "pay_url": "http://localhost/pay", + "merchant": { + "instance": tc["blog"]["instance"].value_string(required=True), + "address": "nowhere", + "name": "Kudos Inc.", + "jurisdiction": "none"}, + "extra": {"article_name": "Check_Me"}}}) + +if "__main__" == __name__: + unittest.main() |