def test_with_key_error(self, mocked_extract_lot_adapter, mocked_decode_path_info): mocked_extract_lot_adapter.side_effect = iter(['adapter']) returned_value = extract_lot(self.mocked_request) assert returned_value is None assert mocked_extract_lot_adapter.call_count == 0 assert mocked_decode_path_info.call_count == 0
def test_with_path_without_lots_in_path(self, mocked_extract_lot_adapter, mocked_decode_path_info): path = 'domain/api/0/notLots' mocked_extract_lot_adapter.side_effect = ['adapter'] self.mocked_request.environ = {'PATH_INFO': path} mocked_decode_path_info.side_effect = iter([path]) returned_value = extract_lot(self.mocked_request) assert returned_value is None assert mocked_decode_path_info.call_count == 1 assert mocked_extract_lot_adapter.call_count == 0
def test_with_path_and_id(self, mocked_extract_lot_adapter, mocked_decode_path_info): path = 'domain/api/0/lots/lotID' mocked_extract_lot_adapter.side_effect = iter(['adapter']) self.mocked_request.environ = {'PATH_INFO': path} mocked_decode_path_info.side_effect = iter([path]) returned_value = extract_lot(self.mocked_request) assert returned_value == 'adapter' assert mocked_decode_path_info.call_count == 1 assert mocked_extract_lot_adapter.call_count == 1 mocked_extract_lot_adapter.assert_called_with(self.mocked_request, path.split('/')[4])