Skip to content
Snippets Groups Projects
Commit b36ee6a6 authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Check for empty or None variables as well

parent 5b66f383
No related branches found
No related tags found
1 merge request!1Main
......@@ -21,20 +21,20 @@ class TestObjectCount(unittest.TestCase):
def runTest(self):
# Modules
self.assertCount(
"""SELECT DISTINCT ?mod WHERE {
?mod a :Module .
"""SELECT * WHERE {
?subj a :Module .
?mod :id ?id .
?mod :index ?index .
?mod :titre ?titre .
?subj :id ?id .
?subj :index ?index .
?subj :titre ?titre .
MINUS { ?mod a :SousPartie }
MINUS { ?subj a :SousPartie }
}""",
(9, 6, 9 + 6),
)
# SousParties
self.assertCount(
"""SELECT DISTINCT ?subj WHERE {
"""SELECT * WHERE {
?subj a :SousPartie .
?subj :id ?id .
......@@ -45,7 +45,7 @@ class TestObjectCount(unittest.TestCase):
)
# Activités
self.assertCount(
"""SELECT DISTINCT ?subj WHERE {
"""SELECT * WHERE {
?subj a :Activite .
?subj :id ?id .
......@@ -64,6 +64,16 @@ class TestObjectCount(unittest.TestCase):
"""
res = self.graph.query(query)
count = len(res)
# Check that variables bound to Literals are not empty or None
for binding in res.bindings:
for var, val in binding.items():
if isinstance(val, Literal):
self.assertFalse(
val.eq(Literal("")), f"Empty value: ?{var} = '{val}'"
)
self.assertFalse(
val.eq(Literal("None")), f"None value: ?{var} = '{val}'"
)
versions = ("macao_12", "macao_3", "full")
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment