From f3d2d3a01efba00e3ffca9d6547cd214e32475b0 Mon Sep 17 00:00:00 2001 From: novokrest Date: Sat, 2 Jun 2018 11:57:40 +0300 Subject: [PATCH] beeminder: Add tests for valid messages. --- .../test_message_with_daystamp_and_value.json | 28 ++++++++++++++++++ ...e_with_daystamp_and_value_and_comment.json | 29 +++++++++++++++++++ .../bots/beeminder/test_beeminder.py | 12 ++++++++ 3 files changed, 69 insertions(+) create mode 100644 zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value.json create mode 100644 zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value_and_comment.json diff --git a/zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value.json b/zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value.json new file mode 100644 index 0000000..681ac40 --- /dev/null +++ b/zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value.json @@ -0,0 +1,28 @@ +{ + "request": { + "api_url": "https://www.beeminder.com/api/v1/users/aaron/goals/goal/datapoints.json", + "method": "POST", + "json": { + "auth_token": "XXXXXX", + "daystamp": "20180602", + "value": "2" + } + }, + "response": { + "timestamp": 1527961199, + "value": 2, + "comment": "", + "id": "5b125325bfec03556a008fc4", + "updated_at": 1527927589, + "requestid": null, + "canonical": "02 2", + "fulltext": "2018-Jun-02 entered at 13:49 via api", + "origin": "api", + "daystamp": "20180602", + "status": "created" + }, + "response-headers": { + "status": 200, + "content-type": "application/json; charset=utf-8" + } +} diff --git a/zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value_and_comment.json b/zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value_and_comment.json new file mode 100644 index 0000000..2bc797c --- /dev/null +++ b/zulip_bots/zulip_bots/bots/beeminder/fixtures/test_message_with_daystamp_and_value_and_comment.json @@ -0,0 +1,29 @@ +{ + "request": { + "api_url": "https://www.beeminder.com/api/v1/users/aaron/goals/goal/datapoints.json", + "method": "POST", + "json": { + "auth_token": "XXXXXX", + "daystamp": "20180602", + "value": "2", + "comment": "hi there!" + } + }, + "response": { + "timestamp": 1527961199, + "value": 2, + "comment": "hi there", + "id": "5b1258f7bfec032233000020", + "updated_at": 1527929079, + "requestid": null, + "canonical": "02 2 \"hi there!\"", + "fulltext": "2018-Jun-02 entered at 14:14 via api", + "origin": "api", + "daystamp": "20180602", + "status": "created" + }, + "response-headers": { + "status": 200, + "content-type": "application/json; charset=utf-8" + } +} diff --git a/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py b/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py index c769312..fd86a13 100644 --- a/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py +++ b/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py @@ -30,12 +30,24 @@ following the syntax shown below :smile:.\n \ self.mock_http_conversation('test_help_message'): self.verify_reply('help', self.help_message) + def test_message_with_daystamp_and_value(self) -> None: + bot_response = '[Datapoint](https://www.beeminder.com/aaron/goal) created.' + with self.mock_config_info(self.normal_config), \ + self.mock_http_conversation('test_message_with_daystamp_and_value'): + self.verify_reply('20180602, 2', bot_response) + def test_message_with_value_and_comment(self) -> None: bot_response = '[Datapoint](https://www.beeminder.com/aaron/goal) created.' with self.mock_config_info(self.normal_config), \ self.mock_http_conversation('test_message_with_value_and_comment'): self.verify_reply('2, hi there!', bot_response) + def test_message_with_daystamp_and_value_and_comment(self) -> None: + bot_response = '[Datapoint](https://www.beeminder.com/aaron/goal) created.' + with self.mock_config_info(self.normal_config), \ + self.mock_http_conversation('test_message_with_daystamp_and_value_and_comment'): + self.verify_reply('20180602, 2, hi there!', bot_response) + def test_syntax_error(self) -> None: with self.mock_config_info(self.normal_config), \ self.mock_http_conversation('test_syntax_error'):