Esempio n. 1
0
 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
Esempio n. 2
0
    def test_filter_by(self):
        # Should be able to take an ontology and filter it by the edges, returning a new sub-ontology
        ontology = CompetencyOntology()
        comm = Competency(identifier='123',
                          name='communication',
                          categories=['social skills'])
        python = Competency(identifier='999',
                            name='python',
                            categories=['Technologies'])
        math = Competency(identifier='111',
                          name='mathematics',
                          categories=['Knowledge'])
        science = Competency(identifier='222',
                             name='science',
                             categories=['Knowledge'])

        civil_engineer = Occupation(identifier='123', name='Civil Engineer')
        ontology.add_competency(comm)
        ontology.add_competency(python)
        ontology.add_competency(math)
        ontology.add_competency(science)
        ontology.add_occupation(civil_engineer)
        ontology.add_edge(occupation=civil_engineer, competency=math)
        ontology.add_edge(occupation=civil_engineer, competency=science)

        tech_ontology = ontology.filter_by(
            lambda edge: 'Technologies' in edge.competency.categories)
        assert tech_ontology.competencies == {python}
        assert len(tech_ontology.occupations) == 0

        civil_engineer_ontology = ontology.filter_by(
            lambda edge: edge.occupation == civil_engineer)
        assert civil_engineer_ontology.competencies == {math, science}
        assert civil_engineer_ontology.occupations == {civil_engineer}
Esempio n. 3
0
 def test_equivalence(self):
     # Two competencies with the same id should be equivalent
     competency = Competency(identifier='123',
                             name='communication',
                             categories=['social skills'])
     competency_two = Competency(identifier='123',
                                 name='communication',
                                 categories=['social skills'])
     assert competency == competency_two
Esempio n. 4
0
 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': [],
     }
Esempio n. 5
0
 def test_add_competency(self):
     # Should be able to add a competency to an ontology
     competency = Competency(identifier='123', name='communication', categories=['social skills'])
     ontology = CompetencyOntology()
     ontology.add_competency(competency)
     assert len(ontology.competencies) == 1
     assert competency in ontology.competencies
Esempio n. 6
0
    def ontology(self):
        ontology = CompetencyOntology(name='Test Ontology')
        comm = Competency(identifier='123', name='communication', categories=['social skills'])
        python = Competency(identifier='999', name='python', categories=['Technologies'])
        math = Competency(identifier='111', name='mathematics', categories=['Knowledge'])
        science = Competency(identifier='222', name='science', categories=['Knowledge'])

        civil_engineer = Occupation(identifier='123', name='Civil Engineer')
        ontology.add_competency(comm)
        ontology.add_competency(python)
        ontology.add_competency(math)
        ontology.add_competency(science)
        ontology.add_occupation(civil_engineer)
        ontology.add_edge(occupation=civil_engineer, competency=math)
        ontology.add_edge(occupation=civil_engineer, competency=science)
        return ontology
Esempio n. 7
0
 def test_create(self):
     # Should be able to create an edge with a competency and occupation
     competency = Competency(identifier='123', name='communication', categories=['social skills'])
     occupation = Occupation(identifier='456', name='Civil Engineer')
     edge = CompetencyOccupationEdge(competency=competency, occupation=occupation)
     assert edge.competency == competency
     assert edge.occupation == occupation
Esempio n. 8
0
 def test_create(self):
     # Should be able to create a competency with the necessary inputs
     competency = Competency(identifier='123',
                             name='communication',
                             categories=['social skills'])
     assert competency.identifier == '123'
     assert competency.name == 'communication'
     assert competency.categories[0] == 'social skills'
Esempio n. 9
0
 def test_add(self):
     framework = CompetencyFramework(
         name='fundamentals_of_nothing',
         description='Fundamentals of Nothing',
     )
     competency = Competency(identifier='1', name='Doing Things', competencyText='The ability to do things')
     framework.add(competency)
     assert len(framework) == 1
Esempio n. 10
0
 def test_create(self):
     competency = Competency(identifier='1',
                             name='Doing Things',
                             competencyText='The ability to do things')
     framework = CompetencyFramework(name='fundamentals_of_nothing',
                                     description='Fundamentals of Nothing',
                                     competencies=[competency])
     assert len(framework) == 1
     assert framework['1'].name == 'Doing Things'
Esempio n. 11
0
 def test_add_edge(self):
     # Should be able to add an edge between an occupation and a competency to an ontology
     occupation = Occupation(identifier='456', name='Civil Engineer')
     competency = Competency(identifier='123', name='communication', categories=['social skills'])
     ontology = CompetencyOntology()
     ontology.add_edge(competency=competency, occupation=occupation)
     assert competency in ontology.competencies
     assert occupation in ontology.occupations
     assert len([edge for edge in ontology.edges if edge.occupation == occupation and edge.competency == competency]) == 1
Esempio n. 12
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
Esempio n. 13
0
 def test_jsonld(self):
     competency = Competency(identifier='111', name='communication', categories=['social skills'])
     occupation = Occupation(identifier='123', name='Civil Engineer')
     edge = CompetencyOccupationEdge(competency=competency, occupation=occupation)
     assert edge.jsonld_full == {
         '@type': 'CompetencyOccupationEdge',
         '@id': 'competency=111&occupation=123',
         'competency': {
             '@type': 'Competency',
             '@id': '111'
         },
         'occupation': {
             '@type': 'Occupation',
             '@id': '123'
         }
     }
Esempio n. 14
0
    def test_fromjsonld(self):
        jsonld_input = {
            '@type': 'CompetencyOccupationEdge',
            '@id': 'competency=111&occupation=123',
            'competency': {
                '@type': 'Competency',
                '@id': '111'
            },
            'occupation': {
                '@type': 'Occupation',
                '@id': '123'
            }
        }

        competency = Competency(identifier='111')
        occupation = Occupation(identifier='123')
        target_edge = CompetencyOccupationEdge(competency=competency, occupation=occupation)

        edge = CompetencyOccupationEdge.from_jsonld(jsonld_input)
        assert edge == target_edge
Esempio n. 15
0
    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