Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_call_without_service_raises_exception(self):
stub_endpoint = apiron.StubEndpoint(stub_response="foo")
with pytest.raises(TypeError):
stub_endpoint()
def test_str_method(self):
foo = apiron.StubEndpoint(path="/bar/baz")
assert str(foo) == "/bar/baz"
def test_repr_method(self):
foo = apiron.StubEndpoint(path="/bar/baz")
assert repr(foo) == "StubEndpoint(path='/bar/baz')"
def test_stub_default_response(self, service):
service.stub_endpoint = apiron.StubEndpoint()
assert service.stub_endpoint() == {"response": "StubEndpoint(path='/')"}
def test_call_dynamic(self, test_call_kwargs, expected_response, service, stub_function):
service.stub_endpoint = apiron.StubEndpoint(stub_response=stub_function)
actual_response = service.stub_endpoint(**test_call_kwargs)
assert actual_response == expected_response
def test_call_static(self, service):
service.stub_endpoint = apiron.StubEndpoint(stub_response="stub response")
assert service.stub_endpoint() == "stub response"