コード例 #1
0
ファイル: test_document.py プロジェクト: exogen/python-rdf
class TestRDFXMLDocument(TestDocument):
    def setUp(self):
        self.doc = Document(TEST['RDF-XML-Document'],
                            TESTS['datatypes/test001.rdf'])
        self.file = open_data_file('rdfcore/datatypes/test001.rdf')
        self.reader = RDFXMLReader()
        super().setUp()

    def test_has_type(self):
        self.assertEqual(self.doc.type, TEST['RDF-XML-Document'])

    def test_has_uri(self):
        self.assertEqual(self.doc.uri,
                         TESTS['datatypes/test001.rdf'])

    def test_open_with_unmatched_uri_raises_exception(self):
        opener = URItoFileOpener({})
        self.assertRaises(URLError, self.doc.open, opener)

    def test_open_opens_referenced_file(self):
        self.assertEqual(self.doc.open(TEST_OPENER).read(), self.file.read())

    def test_read_yields_triples_from_file(self):
        self.assertEqual(set(self.doc.read(TEST_OPENER)),
                         set(self.reader.read(self.file)))
コード例 #2
0
class TestNTriplesDocument(TestDocument):
    def setUp(self):
        self.doc = Document(TEST['NT-Document'],
                            TESTS['datatypes-intensional/test002.nt'])
        self.file = open_data_file('rdfcore/datatypes-intensional/test002.nt')
        self.reader = NTriplesReader()
        super().setUp()

    def test_has_type(self):
        self.assertEqual(self.doc.type, TEST['NT-Document'])

    def test_has_uri(self):
        self.assertEqual(self.doc.uri,
                         TESTS['datatypes-intensional/test002.nt'])

    def test_open_with_unmatched_uri_raises_exception(self):
        opener = URItoFileOpener({})
        self.assertRaises(URLError, self.doc.open, opener)

    def test_open_opens_referenced_file(self):
        self.assertEqual(self.doc.open(TEST_OPENER).read(), self.file.read())

    def test_read_yields_triples_from_file(self):
        self.assertSameElements(self.doc.read(TEST_OPENER),
                                self.reader.read(self.file))
コード例 #3
0
ファイル: test_document.py プロジェクト: exogen/python-rdf
class TestNTriplesDocument(TestDocument):
    def setUp(self):
        self.doc = Document(TEST['NT-Document'],
                            TESTS['datatypes-intensional/test002.nt'])
        self.file = open_data_file('rdfcore/datatypes-intensional/test002.nt')
        self.reader = NTriplesReader()
        super().setUp()

    def test_has_type(self):
        self.assertEqual(self.doc.type, TEST['NT-Document'])

    def test_has_uri(self):
        self.assertEqual(self.doc.uri,
                         TESTS['datatypes-intensional/test002.nt'])

    def test_open_with_unmatched_uri_raises_exception(self):
        opener = URItoFileOpener({})
        self.assertRaises(URLError, self.doc.open, opener)

    def test_open_opens_referenced_file(self):
        self.assertEqual(self.doc.open(TEST_OPENER).read(), self.file.read())

    def test_read_yields_triples_from_file(self):
        self.assertSameElements(self.doc.read(TEST_OPENER),
                                self.reader.read(self.file))
コード例 #4
0
class TestRDFXMLDocument(TestDocument):
    def setUp(self):
        self.doc = Document(TEST['RDF-XML-Document'],
                            TESTS['datatypes/test001.rdf'])
        self.file = open_data_file('rdfcore/datatypes/test001.rdf')
        self.reader = RDFXMLReader()
        super().setUp()

    def test_has_type(self):
        self.assertEqual(self.doc.type, TEST['RDF-XML-Document'])

    def test_has_uri(self):
        self.assertEqual(self.doc.uri, TESTS['datatypes/test001.rdf'])

    def test_open_with_unmatched_uri_raises_exception(self):
        opener = URItoFileOpener({})
        self.assertRaises(URLError, self.doc.open, opener)

    def test_open_opens_referenced_file(self):
        self.assertEqual(self.doc.open(TEST_OPENER).read(), self.file.read())

    def test_read_yields_triples_from_file(self):
        self.assertEqual(set(self.doc.read(TEST_OPENER)),
                         set(self.reader.read(self.file)))