def test_get_item_exception_500(mocked_responses, ): client = ConnectClient( api_key='ApiKey SU:123', use_specs=False, endpoint='https://localhost/public/v1', ) mocked_responses.add( method='GET', url= 'https://localhost/public/v1/products/PRD-276-377-545/items/PRD-276-377-545-0001', status=500, ) with pytest.raises(ClickException) as e: get_item( client=client, product_id='PRD-276-377-545', item_id='PRD-276-377-545-0001', ) assert str(e.value) == "500 - Internal Server Error: unexpected error."
def test_get_item_exception_404(mocked_responses, ): client = ConnectClient( api_key='ApiKey SU:123', use_specs=False, endpoint='https://localhost/public/v1', ) mocked_responses.add( method='GET', url= 'https://localhost/public/v1/products/PRD-276-377-545/items/PRD-276-377-545-0001', status=404, ) item = get_item( client=client, product_id='PRD-276-377-545', item_id='PRD-276-377-545-0001', ) assert item is None
def _get_item(self, data): if data.id: return get_item(self._client, self._product_id, data.id) elif data.mpn: return get_item_by_mpn(self._client, self._product_id, data.mpn)