示例#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"
示例#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"
示例#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)
示例#4
0
def test_ok_200():
    _add_response(200, {"data": "result"})
    client = RESTClient()

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