Ejemplo n.º 1
0
 def test_add_parent(self):
     # Adding a parent should mutate the parents on self and the children on the parent
     communication = Competency(identifier='123', name='communication', categories=['social skills'])
     listening = Competency(identifier='456', name='listening', categories=['social skills'])
     communication.add_parent(listening)
     assert listening in communication.parents
     assert communication in listening.children
Ejemplo n.º 2
0
    def test_add_competency_merge(self):
        # Should be able to add an competency that already exists, and it will merge the attributes
        # Should be able to add a competency to an ontology
        first_child = Competency(identifier='123', name='writing blog posts')
        parent_competency = Competency(identifier='12', name='communication')
        first_child.add_parent(parent_competency)
        ontology = CompetencyOntology()
        ontology.add_competency(first_child)
        ontology.add_competency(parent_competency)

        parent_competency = Competency(identifier='12', name='communication')
        second_child = Competency(identifier='124', name='public speaking')
        second_child.add_parent(parent_competency)
        ontology.add_competency(second_child)
        ontology.add_competency(parent_competency)

        assert len(ontology.competencies) == 3
        assert len(list(ontology.filter_by(lambda edge: edge.competency.identifier == '12').competencies)[0].children) == 2