def test_get_replies(self, mock_requests): json_to_text = json.dumps(stubs.bad_get_replies_response) mock_requests.get.return_value = Mock( status_code=404, text=json_to_text, ) sc = Slackest(token='aaa') replies_gen = next(sc.get_replies('C0G9QF9GW', '1482960137.003543')) error = replies_gen.body['error'] self.assertEqual('thread_not_found', error)
def test_get_replies(self, mock_requests): json_to_text = json.dumps(stubs.good_get_replies_response) mock_requests.get.return_value = Mock( status_code=200, text=json_to_text, ) sc = Slackest(token='aaa') replies_gen = next(sc.get_replies('C0G9QF9GW', '1482960137.003543')) replies = replies_gen.body['messages'][0].get['reply_count'] self.assertEqual(3, replies)