def test_add_bad_response(self):
client = Client(self.api_url)
contact_manager = ContactManager(client)
contact_value = '#channel'
with patch.object(client, 'put', return_value={}) as put_mock, \
patch.object(client, 'get', return_value={'contacts': []}) as get_mock:
with self.assertRaises(ResponseStructureError):
contact_manager.add(contact_value, CONTACT_SLACK)
self.assertTrue(put_mock.called)
self.assertTrue(get_mock.called)
expected_request_data = {
'value': contact_value,
'type': CONTACT_SLACK
}
put_mock.assert_called_with('contact', json=expected_request_data)
评论列表
文章目录