Skip to content

Commit

Permalink
move models to separate modules
Browse files Browse the repository at this point in the history
- move python.py and models.py to a models directory
- update unit tests
- use Dataset instead of ConjunctiveGraph per RDFLib/rdflib#2405
  • Loading branch information
minhnh committed Nov 12, 2024
1 parent 38cb8d6 commit ba7c343
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/rdf_utils/python.py → src/rdf_utils/models/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any
from rdflib import Graph, URIRef
from rdf_utils.namespace import NS_MM_PYTHON
from rdf_utils.models import ModelBase
from rdf_utils.models.common import ModelBase


URI_PY_TYPE_MODULE_ATTR = NS_MM_PYTHON["ModuleAttribute"]
Expand Down
14 changes: 9 additions & 5 deletions tests/test_python_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
import unittest
from urllib.request import urlopen
import pyshacl
from rdflib import ConjunctiveGraph, URIRef
from rdf_utils.models import ModelBase, ModelLoader
from rdflib import Dataset, URIRef
from rdf_utils.models.common import ModelBase, ModelLoader
from rdf_utils.uri import URL_MM_PYTHON_JSON, URL_MM_PYTHON_SHACL, URL_SECORO_M
from rdf_utils.resolver import install_resolver
from rdf_utils.python import import_attr_from_model, import_attr_from_node, load_py_module_attr
from rdf_utils.models.python import (
import_attr_from_model,
import_attr_from_node,
load_py_module_attr,
)


TEST_URL = f"{URL_SECORO_M}/models/tests"
Expand Down Expand Up @@ -36,10 +40,10 @@ def setUp(self):
self.model_loader.register(load_py_module_attr)

def test_python_import(self):
graph = ConjunctiveGraph()
graph = Dataset()
graph.parse(data=PYTHON_MODEL, format="json-ld")

shacl_g = ConjunctiveGraph()
shacl_g = Dataset()
shacl_g.parse(URL_MM_PYTHON_SHACL, format="turtle")
conforms, _, report_text = pyshacl.validate(
graph,
Expand Down

0 comments on commit ba7c343

Please sign in to comment.