diff --git a/packetary/api.py b/packetary/api.py index 2da17a7..bd83aeb 100644 --- a/packetary/api.py +++ b/packetary/api.py @@ -310,10 +310,12 @@ class RepositoryApi(object): try: jsonschema.validate(data, schema) except jsonschema.ValidationError as e: - self._raise_validation_error("data", e.message, e.absolute_path) + self._raise_validation_error( + "data", e.message, e.path + ) except jsonschema.SchemaError as e: self._raise_validation_error( - "schema", e.message, e.absolute_schema_path + "schema", e.message, e.schema_path ) @staticmethod diff --git a/packetary/schemas/package_files_schema.py b/packetary/schemas/package_files_schema.py index 2120fed..fef91a6 100644 --- a/packetary/schemas/package_files_schema.py +++ b/packetary/schemas/package_files_schema.py @@ -21,6 +21,6 @@ PACKAGE_FILES_SCHEMA = { "type": "array", "items": { "type": "string", - "pattern": "^(\/|file:\/\/|https?:\/\/).+$" + "pattern": r"^(/|file:///|https?://).+$" } } diff --git a/packetary/tests/test_schemas.py b/packetary/tests/test_schemas.py index 004ebf1..b650098 100644 --- a/packetary/tests/test_schemas.py +++ b/packetary/tests/test_schemas.py @@ -251,9 +251,8 @@ class TestPackageFilesSchema(base.TestCase): def test_valid_file_urls(self): file_urls = [ - "file://test1.pkg", - "file:///test2.pkg", - "/test3.pkg", + "file:///test1.pkg", + "/test2.pkg", "http://test4.pkg", "https://test5.pkg" ] @@ -278,10 +277,11 @@ class TestPackageFilesSchema(base.TestCase): def test_validation_fail_if_invalid_file_urls(self): file_urls = [ - ["test1.pkg"], # does not match pattern - ["./test2.pkg"], # does not match pattern - ["file//test3.pkg"], # does not match pattern - ["http//test4.pkg"] # does not match pattern + ["test1.pkg"], + ["./test2.pkg"], + ["file//test3.pkg"], + ["http//test4.pkg"], + ["file://test4.pkg"] ] for url in file_urls[2:]: