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_invalid_uri_with_invalid_path(invalid_uri):
"""Verify we catch multiple invalid components."""
uri = rfc3986.uri_reference(invalid_uri)
uri = uri.copy_with(path="#foobar")
with pytest.raises(exceptions.InvalidComponentsError):
validators.Validator().check_validity_of("host", "path",).validate(
uri
)
def test_forbidden_passwords(uri):
"""Verify that passwords are disallowed."""
validator = validators.Validator().forbid_use_of_password()
with pytest.raises(exceptions.PasswordForbidden):
validator.validate(uri)
def test_missing_host_component(uri):
"""Verify that missing host components cause errors."""
validators.Validator().validate(uri)
validator = validators.Validator().require_presence_of("host")
with pytest.raises(exceptions.MissingComponentError):
validator.validate(uri)
def test_missing_path_component(uri):
"""Verify that missing path components cause errors."""
validator = validators.Validator().require_presence_of("path")
with pytest.raises(exceptions.MissingComponentError):
validator.validate(uri)
def test_checking_validity_of_component():
"""Verify that we validate components we're validating."""
with pytest.raises(ValueError):
validators.Validator().check_validity_of("frob")