From 777f6c55f88cf058cea0264ef6b2b18917970cd6 Mon Sep 17 00:00:00 2001 From: Viraat Chandra Date: Fri, 29 Dec 2017 20:38:49 +0530 Subject: [PATCH] zulip_bots: Add better test for `list-plans` command of Baremetrics bot. --- .../bots/baremetrics/fixtures/list_plans.json | 50 ++++++++++++++++--- .../bots/baremetrics/test_baremetrics.py | 6 ++- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/baremetrics/fixtures/list_plans.json b/zulip_bots/zulip_bots/bots/baremetrics/fixtures/list_plans.json index 68bc536..3dc7220 100644 --- a/zulip_bots/zulip_bots/bots/baremetrics/fixtures/list_plans.json +++ b/zulip_bots/zulip_bots/bots/baremetrics/fixtures/list_plans.json @@ -6,14 +6,50 @@ } }, "response": { - "plans": [], - "meta": { - "pagination": { - "has_more": false, - "page": 0, - "per_page": 30 + "plans": [ + { + "oid": "plan_1", + "source_id": "123", + "source": "baremetrics", + "name": "Plan 1", + "interval": "year", + "interval_count": 1, + "trial_duration": null, + "trial_duration_unit": null, + "created": null, + "active": true, + "setup_fees": 0, + "amounts": [ + { + "currency": "USD", + "symbol": "$", + "symbol_right": false, + "amount": 450000 + } + ] + }, + { + "oid": "plan_2", + "source_id": "123", + "source": "baremetrics", + "name": "Plan 2", + "interval": "year", + "interval_count": 1, + "trial_duration": null, + "trial_duration_unit": null, + "created": null, + "active": true, + "setup_fees": 0, + "amounts": [ + { + "currency": "USD", + "symbol": "$", + "symbol_right": false, + "amount": 450000 + } + ] } - } + ] }, "response-headers": { "X-TokenExpires": "0", diff --git a/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py b/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py index b71fa55..c178dfb 100644 --- a/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py +++ b/zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py @@ -38,9 +38,13 @@ class TestBaremetricsBot(BotTestCase): 'baremetrics\nProvider ID: None\n\n') def test_list_plans_command(self) -> None: + r = '**Listing plans:** \n1.Name: Plan 1\nActive: True\nInterval: year\nInterval Count: 1\nAmounts: \n' \ + ' - 450000 USD\n\n2.Name: Plan 2\nActive: True\nInterval: year\nInterval Count: 1\nAmounts: \n' \ + ' - 450000 USD\n\n' + with self.mock_config_info({'api_key': 'TEST'}): with self.mock_http_conversation('list_plans'): - self.verify_reply('list-plans TEST', '**Listing plans:** \n') + self.verify_reply('list-plans TEST', r) def test_list_customers_command(self) -> None: with self.mock_config_info({'api_key': 'TEST'}):