Skip to content

FAILED test/test_js/test_js_target_type.py::test_js_target_type #295

@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_type.py::test_js_target_type https://salsa.debian.org/python-team/packages/pyshacl/-/jobs/7443344#L1858 :

_____________________________ test_js_target_type ______________________________
    def test_js_target_type():
        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_type.py:119: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
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)
pyshacl/shape.py:333: in focus_nodes
    advanced_targets = self.advanced_target()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <Shape p=False node=http://datashapes.org/sh/tests/js/target/jsTargetType-001.test#USCitizenShape>
    def advanced_target(self):
        custom_targets = set(self.sg.objects(self.node, SH_target))
        result_set = dict()
        if self.sg.js_enabled:
            use_JSTarget: Union[bool, Type] = True
        else:
            use_JSTarget = False
    
        for c in custom_targets:
            ct = dict()
            selects = list(self.sg.objects(c, SH_select))
            has_select = len(selects) > 0
            fn_names = list(self.sg.objects(c, SH_jsFunctionName))
            has_fnname = len(fn_names) > 0
            is_types = set(self.sg.objects(c, RDF_type))
            if has_select or (SH_SPARQLTarget in is_types):
                ct['type'] = SH_SPARQLTarget
                SPARQLQueryHelper = get_query_helper_cls()
                qh = SPARQLQueryHelper(self, c, selects[0], deactivated=self._deactivated)
                qh.collect_prefixes()
                ct['qh'] = qh
            elif has_fnname or (SH_JSTarget in is_types):
                if use_JSTarget:
                    JST = getattr(module, "JSTarget", None)
                    if not JST:
                        # Lazy-import JS-Target to prevent RDFLib import error
                        from pyshacl.extras.js.target import JSTarget as JST
    
                        setattr(module, "JSTarget", JST)
                    ct['type'] = SH_JSTarget
                    ct['targeter'] = JST(self.sg, c)
                else:
                    #  Found JSTarget, but JS is not enabled in PySHACL. Ignore this target.
                    pass
            else:
                found_tt = None
                for t in is_types:
                    try:
                        found_tt = self.sg.get_shacl_target_type(t)
                        break
                    except LookupError:
                        continue
                if not found_tt:
                    msg = "None of these types match a TargetType: {}".format(" ".join(is_types))
>                   raise ShapeLoadError(msg, "https://www.w3.org/TR/shacl-af/#SPARQLTargetType")
E                   pyshacl.errors.ShapeLoadError: None of these types match a TargetType: http://datashapes.org/sh/tests/js/target/jsTargetType-001.test#PeopleBornInCountryTarget
E                   For reference, see https://www.w3.org/TR/shacl-af/#SPARQLTargetType
pyshacl/shape.py:309: ShapeLoadError 

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