Skip to content

Commit

Permalink
Fix put (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob committed Dec 9, 2022
1 parent 6e44a22 commit 34fde7f
Show file tree
Hide file tree
Showing 12 changed files with 243 additions and 276 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.2
5.0.3
447 changes: 206 additions & 241 deletions obasparql/query_manager.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions obasparql/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Query(Enum):
GET_ALL = ("get_all")


EMBED_OPTION = "@always"
JSONLD = 'json-ld'

XSD_DATATYPES = ["decimal", "float", "double", "integer", "positiveInteger", "negativeInteger", "nonPositiveInteger",
"nonNegativeInteger", "long", "int", "short", "byte", "unsignedLong", "unsignedInt", "unsignedShort",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ six==1.16.0
urllib3==1.26.12
validators==0.20.0
webencodings==0.5.1
Werkzeug==2.2.2
starlette==0.20.4
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"requests>=2.20.0",
"simplejson==3.17.6",
"six>=1.11.0",
"urllib3>=1.26.5",
"urllib3<1.27,>=1.21.1 ",
"webencodings==0.5.1",
"werkzeug>=0.15.3",
"starlette==0.20.4",
"PyLD>=2.0.3",
]
)
9 changes: 3 additions & 6 deletions tests/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

path = Path(__file__).parent.parent.parent

model_catalog_endpoint = "https://endpoint.mint.isi.edu/dataset"
model_catalog_endpoint = "https://endpoint.mint.isi.edu/modelcatalog"
model_catalog_graph_base = "http://endpoint.mint.isi.edu/modelCatalog-1.8.0/data/"
model_catalog_prefix = "https://w3id.org/okn/i/mint/"
model_catalog_queries = path / "tests/model_catalog/queries/"
model_catalog_context = path / "tests/model_catalog/contexts/"

# dev endpoint version
model_catalog_endpoint_dev = model_catalog_endpoint
model_catalog_graph_base_dev = model_catalog_graph_base
model_catalog_endpoint_dev = model_catalog_endpoint
model_catalog_graph_base_dev = model_catalog_graph_base
model_catalog_prefix_dev = "https://w3id.org/okn/i/mint/"
model_catalog_queries_dev = path / "tests/model_catalog_dev/queries/"
model_catalog_context_dev = path / "tests/model_catalog_dev/contexts/"
Expand All @@ -20,6 +20,3 @@
dbpedia_prefix = "http://dbpedia.org/resource"
dbpedia_queries = path / "tests/dbpedia/queries/"
dbpedia_context = path / "tests/dbpedia/contexts/"



3 changes: 2 additions & 1 deletion tests/test_dispatch_sparql_query_dbpedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging
import unittest
from typing import Dict
from obasparql.query_manager import QueryManager, QUERIES_TYPES
from obasparql.query_manager import QueryManager
from obasparql.static import QUERIES_TYPES
from obasparql.utils import generate_uri
from tests.settings import *

Expand Down
3 changes: 2 additions & 1 deletion tests/test_dispatch_sparql_query_model_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from typing import Dict


from obasparql.query_manager import QueryManager, QUERIES_TYPES, QUERY_TYPE_GET_ONE_USER
from obasparql.query_manager import QueryManager
from obasparql.static import QUERIES_TYPES, QUERY_TYPE_GET_ONE_USER
from obasparql.utils import generate_uri
from tests.settings import *

Expand Down
13 changes: 7 additions & 6 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import json
import unittest
import logging.config
from typing import Dict

from obasparql.utils import generate_uri
import unittest
from obasparql.query_manager import QueryManager, QUERIES_TYPES, QUERY_TYPE_GET_ONE_USER

from obasparql.static import QUERY_TYPE_GET_ONE_USER
from obasparql import QueryManager
from tests.settings import *

Expand Down Expand Up @@ -41,18 +40,20 @@ def test_frame_author(self):
resource_uri = "https://w3id.org/okn/i/mint/CYCLES"
query_type = QUERY_TYPE_GET_ONE_USER

#grlc args
# grlc args
request_args: Dict[str, str] = {
"resource": resource_uri,
"g": graph_user
}
response = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=request_args)
response = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=request_args)
self.assertTrue(response)
for author in response["author"]:
self.assertIsInstance(author, dict)
for author in response["hasContactPerson"]:
self.assertIsInstance(author, dict)
assert 'operatingSystems' in response


if __name__ == '__main__':
unittest.main()
16 changes: 8 additions & 8 deletions tests/test_query_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from typing import Dict


from obasparql.query_manager import QueryManager, QUERIES_TYPES, QUERY_TYPE_GET_ONE_USER
from obasparql.query_manager import QueryManager
from obasparql.static import QUERIES_TYPES, QUERY_TYPE_GET_ONE_USER
from obasparql.utils import generate_uri
from tests.settings import *

Expand All @@ -20,7 +21,6 @@ def setUp(self):
named_graph_base=model_catalog_graph_base,
uri_prefix=model_catalog_prefix)


def test_obtain_query_get_one_user(self):
"""
Test to obtain one resource by the uri
Expand All @@ -36,8 +36,8 @@ def test_obtain_query_get_one_user(self):
"g": graph_user
}

resource = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=request_args)
resource = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=request_args)

self.assertTrue(resource)

Expand All @@ -56,9 +56,9 @@ def test_obtain_query_get_one_user_region_case(self):
"g": graph_user
}

resource = self.query_manager.obtain_query(query_directory=owl_class_name,
owl_class_uri=owl_class_uri, query_type=query_type,
request_args=request_args)
resource = self.query_manager.run_query_get(query_directory=owl_class_name,
owl_class_uri=owl_class_uri, query_type=query_type,
request_args=request_args)

self.assertEqual(resource_uri, resource["id"])

Expand Down Expand Up @@ -104,7 +104,7 @@ def test_dispatch_sparqlquery_model_catalog(self):
query_template = getattr(self.query_manager, query_directory)[query_type]

results = self.query_manager.dispatch_sparql_query(raw_sparql_query=query_template,
request_args=request_args)
request_args=request_args)
# prefixes, triples = self.query_manager.convert_json_to_triples(results)
self.assertIsNotNone(json.loads(results))

Expand Down
8 changes: 4 additions & 4 deletions tests/test_query_model_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_get_all_with_pagination(self):
"page": 1
}

results = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
results = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=grlc_request_args)

def test_get_all_with_pagination_dataset(self):
Expand All @@ -54,7 +54,7 @@ def test_get_all_with_pagination_dataset(self):
"g": self.username,
}

results = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
results = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=grlc_request_args)

def test_get_one(self):
Expand All @@ -71,7 +71,7 @@ def test_get_one(self):
"g": self.username
}

resource = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
resource = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=request_args)
self.assertIn("ModelConfiguration", resource['type'])
self.assertEqual(resource['id'], resource_uri)
Expand All @@ -91,7 +91,7 @@ def test_get_one_setup_custom(self):
"g": self.username
}

resource = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=resource_type_uri,
resource = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=resource_type_uri,
query_type=query_type, request_args=request_args)
self.assertEqual(resource["id"], resource_uri)

Expand Down
10 changes: 5 additions & 5 deletions tests/test_query_model_catalog_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_get_all_with_pagination(self):
"page": 1
}

results = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
results = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=grlc_request_args)
assert(results)
assert(results[0]['hasComponentLocation'])
Expand All @@ -58,7 +58,7 @@ def test_get_all_with_pagination_dataset(self):
"g": self.usergraph,
}

results = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
results = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=grlc_request_args)
assert(results)

Expand All @@ -77,7 +77,7 @@ def test_get_one_parameter(self):
"g": self.usergraph
}

resource = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
resource = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=request_args)
self.assertIn("Parameter", resource['type'][0])
self.assertIn("position", resource)
Expand All @@ -97,7 +97,7 @@ def test_get_one(self):
"g": self.usergraph
}

resource = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
resource = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=owl_class_uri,
query_type=query_type, request_args=request_args)
self.assertIn("ModelConfiguration", resource['type'])
self.assertEqual(resource["id"], resource_uri)
Expand All @@ -117,7 +117,7 @@ def test_get_one_setup_custom(self):
"g": self.usergraph
}

resource = self.query_manager.obtain_query(query_directory=owl_class_name, owl_class_uri=resource_type_uri,
resource = self.query_manager.run_query_get(query_directory=owl_class_name, owl_class_uri=resource_type_uri,
query_type=query_type, request_args=request_args)
self.assertEqual(resource["id"], resource_uri)

Expand Down

0 comments on commit 34fde7f

Please sign in to comment.