diff --git a/formats/json_format.py b/formats/json_format.py index 5cf52fbfca54ba6ecbaea99c4f06740694316759..41f4e658ba3c2005dad2fd65f7682acaf1216c9a 100644 --- a/formats/json_format.py +++ b/formats/json_format.py @@ -23,9 +23,6 @@ def is_valid(resource, file): return resource["schema_valid"] return True - except json.JSONDecodeError as e: - resource["error"] = str(e) - return False - except UnicodeDecodeError as e: + except Exception as e: resource["error"] = str(e) return False diff --git a/tests/data/ufo-resource.json b/tests/data/ufo-resource.json index d05d9c2c4e9b7a1c29605b8f9695917580771024..701306ab8533c00d9c13d8c03bfa10ddd9d19435 100644 --- a/tests/data/ufo-resource.json +++ b/tests/data/ufo-resource.json @@ -1,7 +1,7 @@ { "name": "ufo", "type": "table", - "path": "http://localhost:8000/ufo.csv", + "path": "tests/data/ufo.csv", "format": "csv", "mediatype": "text/csv", "encoding": "utf-8", diff --git a/tests/test_json_format.py b/tests/test_json_format.py index 2f579ab8105a956aac4816b33ee2767ff436bccd..23a892cc948f247d50ad92ad3e3ae5d3c0ca2caf 100644 --- a/tests/test_json_format.py +++ b/tests/test_json_format.py @@ -15,6 +15,13 @@ class TestJsonFormat(unittest.TestCase): self.assertFalse(is_valid(resource, file)) self.assertIsNotNone(resource.get("error")) + def test_is_valid__frictionless_valid(self): + resource = {} + with open("tests/data/ufo-resource.json", "r") as file: + self.assertTrue(is_valid(resource, file)) + self.assertIsNone(resource.get("error")) + self.assertTrue(resource.get("schema_valid")) + if __name__ == "__main__": unittest.main()