File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
3
from frictionless import Resource , resources
4
+ from frictionless .resources .json import SchemaResource
4
5
5
6
# File
6
7
@@ -162,3 +163,16 @@ def test_resource_from_descriptor_with_class_datatype():
162
163
assert resource .type == "table"
163
164
assert resource .datatype == "table"
164
165
assert isinstance (resource , resources .TableResource )
166
+
167
+
168
+ def test_schema_resource_with_path_property ():
169
+ # Non regression test for issue #1688
170
+ schema_descriptor = {
171
+ "name" : "schema" ,
172
+ "path" : "abc" ,
173
+ "fields" : [],
174
+ }
175
+ resource = Resource (schema_descriptor , datatype = "schema" )
176
+ assert resource .type == "json"
177
+ assert resource .datatype == "schema"
178
+ assert isinstance (resource , SchemaResource )
Original file line number Diff line number Diff line change @@ -45,7 +45,13 @@ def __call__(
45
45
path = source
46
46
if isinstance (source , str ):
47
47
path = helpers .join_basepath (source , basepath = basepath )
48
- md_type = Detector .detect_metadata_type (path , format = options .get ("format" ))
48
+
49
+ md_type = options .get ("datatype" )
50
+ if not md_type :
51
+ md_type = Detector .detect_metadata_type (
52
+ path , format = options .get ("format" )
53
+ )
54
+
49
55
if md_type != "resource" :
50
56
options ["path" if isinstance (source , str ) else "data" ] = source
51
57
resource = cls (control = control , basepath = basepath , ** options ) # type: ignore
You can’t perform that action at this time.
0 commit comments