Exemplo n.º 1
0
 def test_read_from_file_success(self):
     """ Read configuration from a JSON file """
     try:
         d = Data.open("tests/test.conf")
         self.assertEqual("test_value", d["test_variable"])
     except Exception:
         self.fail("test.conf should exist and be valid JSON")
Exemplo n.º 2
0
 def test_read_from_file_success(self):
     """ Read configuration from a JSON file """
     try:
         d = Data.open("tests/test.conf")
         self.assertEqual("test_value", d["test_variable"])
     except Exception:
         self.fail("test.conf should exist and be valid JSON")
Exemplo n.º 3
0
    def _conf(self):
        from PyOpenWorm.data import Data
        dat = getattr(self, '_dat', None)
        if not dat or self._dat_file != self.config_file:
            dat = Data.open(self.config_file)
            stored_conf = dat.get('rdf.store_conf', None)

            if stored_conf and not isabs(stored_conf):
                dat['rdf.store_conf'] = abspath(pth_join(self.basedir, stored_conf))
            dat.init_database()
            self._dat = dat
            self._dat_file = self.config_file
        return dat
Exemplo n.º 4
0
    def _conf(self):
        from PyOpenWorm.data import Data
        dat = getattr(self, '_dat', None)
        if not dat or self._dat_file != self.config_file:
            dat = Data.open(self.config_file)
            stored_conf = dat.get('rdf.store_conf', None)

            if stored_conf and not isabs(stored_conf):
                dat['rdf.store_conf'] = abspath(
                    pth_join(self.basedir, stored_conf))
            dat.init_database()
            self._dat = dat
            self._dat_file = self.config_file
        return dat
Exemplo n.º 5
0
 def setUp(self):
     # Set do_logging to True if you like walls of text
     self.TestConfig = Data.open(TEST_CONFIG)
     td = '__tempdir__'
     z = self.TestConfig['rdf.store_conf']
     if z.startswith(td):
         x = z[len(td):]
         h = tempfile.mkdtemp()
         self.TestConfig['rdf.store_conf'] = h + x
     self.delete_dir()
     self.connection = PyOpenWorm.connect(conf=self.TestConfig, do_logging=False)
     self.context = Context(ident='http://example.org/test-context',
                            conf=self.TestConfig)
     typ = type(self)
     if hasattr(typ, 'ctx_classes'):
         if isinstance(dict, typ.ctx_classes):
             self.ctx = self.context(typ.ctx_classes)
         else:
             self.ctx = self.context({x.__name__: x for x in typ.ctx_classes})
Exemplo n.º 6
0
 def test_read_from_file_fail(self):
     """ Fail on attempt to read configuration from a non-JSON file """
     with self.assertRaises(ValueError):
         Data.open("tests/test_data/bad_test.conf")
Exemplo n.º 7
0
 def test_read_from_file_fail(self):
     """ Fail on attempt to read configuration from a non-JSON file """
     with self.assertRaises(ValueError):
         Data.open("tests/test_data/bad_test.conf")