beeminder: Add tests for valid messages.

This commit is contained in:
novokrest 2018-06-02 11:57:40 +03:00
parent d68a19f2dc
commit f3d2d3a01e
3 changed files with 69 additions and 0 deletions

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -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'):