Exemplo n.º 1
0
def test_simple_concept_to_rdf_should_return_skos_concept():
    with open('./tests/concept.json') as json_file:
        data = json.load(json_file)
        _concept = data['concept']
    concept = Concept()
    concept.identifier = _concept['identifier']
    concept.term = _concept['term']
    concept.definition = Definition(_concept['definition'])
    concept.alternativformulering = AlternativFormulering(
        _concept['alternativformulering'])
    concept.publisher = _concept['publisher']
    concept.contactpoint = Contact(_concept['contactpoint'])

    g1 = Graph()
    g1.parse(data=concept.to_rdf(), format='turtle')
    # _dump_turtle(g1)
    g2 = Graph().parse("tests/concept.ttl", format='turtle', encoding='utf-8')

    _isomorphic = isomorphic(g1, g2)
    if not _isomorphic:
        # _dump_diff(g1, g2)
        pass
    assert _isomorphic
Exemplo n.º 2
0
def test_concept_to_rdf_should_return_skos_concept():
    with open('./tests/completeconcept.json') as json_file:
        data = json.load(json_file)
        _concept = data['concept']
    concept = Concept()
    concept.identifier = _concept['identifier']
    concept.term = _concept['term']
    concept.alternativeterm = _concept['alternativeterm']
    concept.hiddenterm = _concept['hiddenterm']
    concept.definition = Definition(_concept['definition'])
    concept.alternativformulering = AlternativFormulering(
        _concept['alternativformulering'])
    concept.publisher = _concept['publisher']
    concept.contactpoint = Contact(_concept['contactpoint'])
    concept.subject = _concept['subject']
    concept.modified = _concept['modified']
    concept.example = _concept['example']
    concept.bruksområde = _concept['bruksområde']
    concept.validinperiod = _concept['validinperiod']
    concept.modified = _concept['modified']
    # --
    concept.related = AssociativeRelation(_concept['related'])
    for ac in _concept['related']['associatedconcepts']:
        concept.related.associatedconcepts.append(ac)
    # --
    concept.generalizes = GenericRelation(_concept['generalizes'])
    for gc in _concept['generalizes']['genericconcepts']:
        concept.generalizes.genericconcepts.append(gc)
    # --
    concept.hasPart = PartitiveRelation(_concept['hasPart'])
    for pc in _concept['hasPart']['partconcepts']:
        concept.hasPart.partconcepts.append(pc)
    # --
    for c in _concept['seeAlso']:
        seeAlsoConcept = Concept()
        seeAlsoConcept.identifier = c
        concept.seeAlso.append(seeAlsoConcept)
    # --
    for c in _concept['replaces']:
        replacesConcept = Concept()
        replacesConcept.identifier = c
        concept.replaces.append(replacesConcept)
    # --
    for c in _concept['replacedBy']:
        replacedByConcept = Concept()
        replacedByConcept.identifier = c
        concept.replacedBy.append(replacedByConcept)
    # --

    g1 = Graph()
    g1.parse(data=concept.to_rdf(), format='turtle')
    _dump_turtle(g1)
    g2 = Graph().parse("tests/completeconcept.ttl",
                       format='turtle',
                       encoding='utf-8')

    _isomorphic = isomorphic(g1, g2)
    if not _isomorphic:
        _dump_diff(g1, g2)
        pass
    assert _isomorphic