Skip to content

FAILED test/test_js/test_js_target.py::test_js_target #294

@santiagorr

Description

@santiagorr

Hi there!

When trying to package pyshacl for Debian, I am getting failures with six tests:

...
=========================== short test summary info ============================
FAILED test/test_js/test_js_constraint_component.py::test_js_constraint_component - pyshacl.errors.ConstraintLoadError: A Custom Constraint must include one of a SPARQLConstraintComponent validator or a JSConstraint validator.
For reference, see https://www.w3.org/TR/shacl/#constraint-components-validators
FAILED test/test_js/test_js_constraint_path_component.py::test_js_constraint_path_component - pyshacl.errors.ConstraintLoadError: A Custom Constraint must include one of a SPARQLConstraintComponent validator or a JSConstraint validator.
For reference, see https://www.w3.org/TR/shacl/#constraint-components-validators
FAILED test/test_js/test_js_function.py::test_js_function - assert not True
FAILED test/test_js/test_js_rules.py::test_js_rules - pyshacl.errors.RuleLoadError: when using sh:rule, the Rule must be defined as either a TripleRule or SPARQLRule.
For reference, see https://www.w3.org/TR/shacl-af/#rules-syntax
FAILED test/test_js/test_js_target.py::test_js_target - KeyError: 'type'
FAILED test/test_js/test_js_target_type.py::test_js_target_type - pyshacl.errors.ShapeLoadError: None of these types match a TargetType: http://datashapes.org/sh/tests/js/target/jsTargetType-001.test#PeopleBornInCountryTarget
For reference, see https://www.w3.org/TR/shacl-af/#SPARQLTargetType
============ 6 failed, 362 passed, 21 warnings in 88.58s (0:01:28) =============
...

This is the report for test_js_target.py::test_js_target https://salsa.debian.org/python-team/packages/pyshacl/-/jobs/7443344#L1768:

________________________________ test_js_target ________________________________
    def test_js_target():
        s1 = Graph().parse(data=shapes_graph, format="turtle")
        g1 = Graph().parse(data=data_graph, format="turtle")
>       conforms, result_graph, result_text = validate(g1, shacl_graph=s1, advanced=True, debug=True, js=True)
test/test_js/test_js_target.py:78: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pyshacl/entrypoints.py:178: in validate
    conforms, report_graph, report_text = validator.run()
pyshacl/validator.py:315: in run
    _is_conform, _reports = s.validate(executor, g, focus=on_focus_nodes)
pyshacl/shape.py:655: in validate
    focus_set = self.focus_nodes(target_graph, debug=executor.debug)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <Shape p=False node=http://datashapes.org/sh/tests/js/target/jsTarget-001.test#TestShape>
data_graph = <Graph identifier=Nbec805ee01fb4bd2998da9c544325afe (<class 'rdflib.graph.Graph'>)>
debug = True
    def focus_nodes(self, data_graph, debug=False):
        """
        The set of focus nodes for a shape may be identified as follows:
    
        specified in a shape using target declarations
        specified in any constraint that references a shape in parameters of shape-expecting constraint parameters (e.g. sh:node)
        specified as explicit input to the SHACL processor for validating a specific RDF term against a shape
        :return:
        """
        t1 = 0.0
        if debug:
            t1 = perf_counter()
        (target_nodes, target_classes, implicit_classes, target_objects_of, target_subjects_of) = self.target()
        if self._advanced:
            advanced_targets = self.advanced_target()
        else:
            advanced_targets = False
        found_node_targets = set()
        # Just add _all_ target_nodes to the set,
        # they don't need to actually exist in the graph
        found_node_targets.update(iter(target_nodes))
        target_classes = set(target_classes)
        target_classes.update(set(implicit_classes))
        found_target_instances = set()
        for tc in target_classes:
            s = data_graph.subjects(RDF_type, tc)
            found_target_instances.update(s)
            subc = data_graph.transitive_subjects(RDFS_subClassOf, tc)
            for subclass in iter(subc):
                if subclass == tc:
                    continue
                s1 = data_graph.subjects(RDF_type, subclass)
                found_target_instances.update(s1)
        found_node_targets.update(found_target_instances)
        found_target_subject_of = set()
        for s_of in target_subjects_of:
            subs = {s for s, o in data_graph.subject_objects(s_of)}
            found_target_subject_of.update(subs)
        found_node_targets.update(found_target_subject_of)
        found_target_object_of = set()
        for o_of in target_objects_of:
            objs = {o for s, o in data_graph.subject_objects(o_of)}
            found_target_object_of.update(objs)
        found_node_targets.update(found_target_object_of)
        if advanced_targets:
            for at_node, at in advanced_targets.items():
>               if at['type'] == SH_SPARQLTarget:
E               KeyError: 'type'
pyshacl/shape.py:365: KeyError

Full log can be found at: https://salsa.debian.org/python-team/packages/pyshacl/-/jobs/7443344

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions