# -*- coding: utf-8 -*- import unittest from rdflib.graph import ConjunctiveGraph from rdflib.parser import StringInputSource import textwrap import pytest prefix = textwrap.dedent( """\ @prefix nie: . @prefix nfo: . @prefix nco: . @prefix nmo: . @prefix ncal: . @prefix nexif: . @prefix nid3: . @prefix dc: . @prefix nmm: . @prefix 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 + "" + 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 + "" + meta2), format="n3" )