1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# -*- coding: utf-8 -*-
import unittest
from rdflib.graph import ConjunctiveGraph
from rdflib.parser import StringInputSource
import textwrap
import pytest
prefix = textwrap.dedent(
"""\
@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
@prefix nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> .
@prefix nco: <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#> .
@prefix nmo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#> .
@prefix ncal: <http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#> .
@prefix nexif: <http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#> .
@prefix nid3: <http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#> .
@prefix dc: <http://dublincore.org/documents/2010/10/11/dces/#> .
@prefix nmm: <http://library.gnome.org/devel/ontology/unstable/nmm-classes.html#> .
@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
"""
)
meta = textwrap.dedent(
"""\
a nfo:PaginatedTextDocument ;
nie:title "SV Meldung" ;
nco:creator [ a nco:Contact ;
nco:fullname "nikratio"] ;
nie:contentCreated "2011-08-10T20:12:38Z" ;
dc:format "application/pdf" ;
nie:description "()" ;
nao:hasTag ?tag1 ;
nfo:pageCount 1 ;
nie:plainTextContent "%s" .
} } WHERE { {
?tag1 a nao:Tag ; nao:prefLabel "()" .
"""
)
test_string1 = """\
Betriebsnummer der Einzugsstelle:\nKnappschaft\n980 0000 6\nWICHTIGES DOKUMENT - SORGFÄLTIG AUFBEWAHREN!\n """
@pytest.mark.xfail(reason="Known issue with newlines in text")
def test1():
meta1 = meta.encode("utf-8") % test_string1.encode("utf-8")
graph = ConjunctiveGraph()
graph.parse(
StringInputSource(prefix + "<http://example.org/>" + meta1), format="n3"
)
test_string2 = """\
Betriebsnummer der Einzugsstelle:
Knappschaft
980 0000 6
WICHTIGES DOKUMENT - SORGFÄLTIG AUFBEWAHREN!
"""
@pytest.mark.xfail(reason="Known issue with newlines in text")
def test2():
meta2 = meta.encode("utf-8") % test_string2.encode("utf-8")
graph = ConjunctiveGraph()
graph.parse(
StringInputSource(prefix + "<http://example.org/>" + meta2), format="n3"
)
|