def test_add_child(self): # Adding a child should mutate the children on self and the parents on the child communication = Competency(identifier='123', name='communication', categories=['social skills']) listening = Competency(identifier='456', name='listening', categories=['social skills']) listening.add_child(communication) assert listening in communication.parents assert communication in listening.children
def test_jsonld(self): # The jsonld version of a competency should include all parent/child links, using the jsonld id communication = Competency(identifier='123', name='communication', categories=['social skills']) listening = Competency(identifier='456', name='listening', categories=['social skills']) listening.add_child(communication) assert listening.jsonld_full == { '@type': 'Competency', '@id': '456', 'name': 'listening', 'competencyCategory': ['social skills'], 'hasChild': [{'@type': 'Competency', '@id': '123'}], 'isChildOf': [], }
def test_from_jsonld(self): jsonld_input = { '@type': 'Competency', '@id': '456', 'name': 'listening', 'competencyCategory': ['social skills'], 'hasChild': [{'@type': 'Competency', '@id': '123'}], 'isChildOf': [], 'extra_kwarg': 'extra_value' } target_competency = Competency(identifier='456', name='listening', categories=['social skills'], extra_kwarg='extra_value') target_competency.add_child(Competency(identifier='123')) competency = Competency.from_jsonld(jsonld_input) assert competency == target_competency