Example #1
0
class TestOpener(unittest.TestCase):
    def setUp(self):
        self.opener = URItoFileOpener(PATH_MAP)
        self.manifest_file = open_data_file('rdfcore/Manifest.rdf')

    def test_is_opener_director(self):
        self.assert_(isinstance(self.opener, OpenerDirector))

    def test_open_with_handler_returns_file(self):
        manifest_file = self.opener.open(TESTS['Manifest.rdf'])
        self.assertEqual(manifest_file.read(), self.manifest_file.read())

    def test_open_without_handler_returns_none(self):
        opener = URItoFileOpener()
        manifest_file = opener.open(TESTS['Manifest.rdf'])
        self.assertEqual(manifest_file, None)
Example #2
0
class TestOpener(unittest.TestCase):
    def setUp(self):
        self.opener = URItoFileOpener(PATH_MAP)
        self.manifest_file = open_data_file('rdfcore/Manifest.rdf')

    def test_is_opener_director(self):
        self.assert_(isinstance(self.opener, OpenerDirector))

    def test_open_with_handler_returns_file(self):
        manifest_file = self.opener.open(TESTS['Manifest.rdf'])
        self.assertEqual(manifest_file.read(), self.manifest_file.read())

    def test_open_without_handler_returns_none(self):
        opener = URItoFileOpener()
        manifest_file = opener.open(TESTS['Manifest.rdf'])
        self.assertEqual(manifest_file, None)
Example #3
0
 def test_open_without_handler_returns_none(self):
     opener = URItoFileOpener()
     manifest_file = opener.open(TESTS['Manifest.rdf'])
     self.assertEqual(manifest_file, None)
Example #4
0
 def setUp(self):
     self.opener = URItoFileOpener(PATH_MAP)
     self.manifest_file = open_data_file('rdfcore/Manifest.rdf')
Example #5
0
import os.path
from urllib.request import OpenerDirector

from rdf.namespace import Namespace
from rdf.testcases.opener import URItoFileOpener


def get_data_path(filename):
    return os.path.join(os.path.dirname(__file__), 'data', filename)


def open_data_file(filename, mode='r'):
    return open(get_data_path(filename), mode)


class NullOpener(OpenerDirector):
    def open(self, *args, **kwargs):
        raise IOError


EX = Namespace('http://example.org/')
TESTS = Namespace('http://www.w3.org/2000/10/rdf-tests/rdfcore/')

PATH_MAP = {TESTS: get_data_path('rdfcore')}
TEST_OPENER = URItoFileOpener(PATH_MAP)
NULL_OPENER = NullOpener()
Example #6
0
 def test_open_with_unmatched_uri_raises_exception(self):
     opener = URItoFileOpener({})
     self.assertRaises(URLError, self.doc.open, opener)
Example #7
0
 def test_open_without_handler_returns_none(self):
     opener = URItoFileOpener()
     manifest_file = opener.open(TESTS['Manifest.rdf'])
     self.assertEqual(manifest_file, None)
Example #8
0
 def setUp(self):
     self.opener = URItoFileOpener(PATH_MAP)
     self.manifest_file = open_data_file('rdfcore/Manifest.rdf')