def test_get_picture_fails_as_expected(self, pv_find_picture): pv_find_picture.side_effect = NotFoundError('no picture there, friend') resp_object = pv.get_picture('4231') response_data_dict = json.loads(resp_object.data) pv_find_picture.assert_called_once_with('4231') assert resp_object.status_code == 404 assert resp_object.data == '"no picture there, friend"'
def test_get_picture_calls_find_picture_method(self, pv_find_picture): pv_find_picture.return_value = {'e': 'd'} resp_object = pv.get_picture('4231') response_data_dict = json.loads(resp_object.data) pv_find_picture.assert_called_once_with('4231') assert resp_object.status_code == 200 assert 'e' in response_data_dict assert len(response_data_dict.keys()) == 1
def test_get_picture_calls_generic_get_view(self, pv_generic_get_view): resp_object = pv.get_picture('hooha') pv_generic_get_view.assert_called_once_with(item_id='hooha', document_type='picture')