def test_invalid_request(): client = Client(URL) client.auth_data = {"token": "some-token"} with requests_mock.mock() as m: m.post(URL, status_code=400, text="Some error") with pytest.raises(DeepstreamioHTTPError): client._execute([{"something": "something"}])
def test_not_batched(): client = Client(URL) client.auth_data = {"token": "some-token"} # success with requests_mock.mock() as m: m.post(URL, status_code=200, json={ 'result': 'SUCCESS', 'body': [{ "success": True, "data": "hoj" }] }) body = [{ 'topic': 'record', 'action': 'head', 'recordName': 'record-name', }] assert client._execute(body) == (True, [{ "success": True, "data": "hoj" }]) # success with requests_mock.mock() as m: m.post(URL, status_code=200, json={ 'result': 'FAILURE', 'body': [{ "success": False, "error": "Some" }] }) body = [{ 'topic': 'record', 'action': 'head', 'recordName': 'record-name', }] assert client._execute(body) == (False, [{ "success": False, "error": "Some" }])