From 6d76fca2d944def11a4259b3c9c3c0df2cea9d40 Mon Sep 17 00:00:00 2001
From: Jesper Zedlitz <jesper@zedlitz.de>
Date: Mon, 30 Dec 2024 07:13:19 +0100
Subject: [PATCH] unittest for Frictionless Data Resource

---
 formats/json_format.py       | 5 +----
 tests/data/ufo-resource.json | 2 +-
 tests/test_json_format.py    | 7 +++++++
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/formats/json_format.py b/formats/json_format.py
index 5cf52fb..41f4e65 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 d05d9c2..701306a 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 2f579ab..23a892c 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()
-- 
GitLab