Ejemplo n.º 1
0
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"
Ejemplo n.º 2
0
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"
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 def __init__(self, endpoint):
     super().__init__()
     self.client = RESTClient()
     self.endpoint = endpoint
Ejemplo n.º 5
0
def test_ok_200():
    _add_response(200, {"data": "result"})
    client = RESTClient()

    assert client.get("/endpoint") == {"data": "result"}