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_constructor_stores_passed_attributes(self):
foo = apiron.Endpoint(path="/foo/", default_method="POST")
assert "/foo/" == foo.path
assert "POST" == foo.default_method
def test_repr_method(self):
foo = apiron.Endpoint(path="/bar/baz")
assert repr(foo) == "Endpoint(path='/bar/baz')"
def test_format_path_with_incorrect_kwargs(self):
foo = apiron.Endpoint(path="/{one}/{two}/")
path_kwargs = {"foo": "bar"}
with pytest.warns(RuntimeWarning, match="An unknown path kwarg was supplied"):
with pytest.raises(KeyError):
foo.get_formatted_path(**path_kwargs)
def test_call(self, service):
service.foo = apiron.Endpoint()
service.foo()
def test_get_merged_params_with_empty_param(self):
foo = apiron.Endpoint(default_params={"foo": "bar"}, required_params={"baz"})
with pytest.warns(RuntimeWarning, match="endpoint was called with empty parameters"):
assert {"foo": "bar", "baz": None} == foo.get_merged_params({"baz": None})
def test_get_merged_params(self):
foo = apiron.Endpoint(default_params={"foo": "bar"}, required_params={"baz"})
assert {"foo": "bar", "baz": "qux"} == foo.get_merged_params({"baz": "qux"})
def test_endpoints_when_multiple_endpoints(self, service):
foo = Endpoint(path="/foo")
bar = Endpoint(path="/bar")
service.foo = foo
service.bar = bar
assert service.endpoints == {foo, bar}
def test_required_headers(self):
foo = apiron.Endpoint()
assert {} == foo.required_headers
def endpoints(cls):
return {attr for attr_name, attr in cls.__dict__.items() if isinstance(attr, Endpoint)}