def test_ko(): _add_response(500, {"error": "result"}) client = RESTClient() with pytest.raises(click.ClickException) as e: client.get("/endpoint") assert str(e.value) == "Internal server error"
def test_ko_401(): _add_response(401, {"error": "result"}) client = RESTClient() with pytest.raises(click.ClickException) as e: client.get("/endpoint") assert str(e.value) == "Unauthorized"
class RESTQuery(Query): def __init__(self, endpoint): super().__init__() self.client = RESTClient() self.endpoint = endpoint def execute(self): response = self.client.get(self.endpoint) super()._handle_response(response) self._handle_response(response)
def __init__(self, endpoint): super().__init__() self.client = RESTClient() self.endpoint = endpoint
def test_ok_200(): _add_response(200, {"data": "result"}) client = RESTClient() assert client.get("/endpoint") == {"data": "result"}