Ejemplo n.º 1
0
 def test_no_directory(self):
     path = self.__files.dir + '_does_not_exist'
     dbs, diagnostics = db.databases_from_directory(reactor, path)
     self.assertEqual([], dbs.keys())
     self.assertEqual(1, len(diagnostics))
     self.assertEqual(path, diagnostics[0][0])
     self.assertIn('Error opening database directory', str(diagnostics[0][1]))
Ejemplo n.º 2
0
 def add_directory(self, path):
     self._config._not_finished()
     path = str(path)
     dbs, path_diagnostics = databases_from_directory(self.__reactor, path)
     self.__read_only_databases.update(dbs)
     for d in path_diagnostics:
         log.msg('%s: %s' % d)
Ejemplo n.º 3
0
 def test_no_directory(self):
     path = self.__temp_dir + '_does_not_exist'
     dbs, diagnostics = db.databases_from_directory(reactor, path)
     self.assertEqual([], dbs.keys())
     self.assertEqual(1, len(diagnostics))
     self.assertEqual(path, diagnostics[0][0])
     self.assertIn('Error opening database directory', str(diagnostics[0][1]))
Ejemplo n.º 4
0
 def add_directory(self, path):
     self._config._not_finished()
     path = str(path)
     dbs, path_diagnostics = databases_from_directory(self.__reactor, path)
     self.__read_only_databases.update(dbs)
     for d in path_diagnostics:
         log.msg('%s: %s' % d)
Ejemplo n.º 5
0
    def __init__(self, config, reactor):
        self._config = config
        self.__reactor = reactor

        self.__read_only_databases, diagnostics = databases_from_directory(
            self.__reactor, sibpath(__file__, 'data/dbs/'))
        if len(diagnostics) > 0:
            raise ConfigException(diagnostics)
Ejemplo n.º 6
0
 def __init__(self, config, reactor):
     self._config = config
     self.__reactor = reactor
     
     self.__read_only_databases, diagnostics = databases_from_directory(self.__reactor,
         os.path.join(os.path.dirname(__file__), 'data/dbs/'))
     if len(diagnostics) > 0:
         raise ConfigException(diagnostics)
Ejemplo n.º 7
0
 def __init__(self, config, reactor, log):
     self._config = config
     self.__reactor = reactor
     self.__log = log
     
     self.__read_only_databases, diagnostics = databases_from_directory(
         self.__reactor,
         sibpath(__file__, 'data/dbs/'))
     if len(diagnostics) > 0:
         raise ConfigException(diagnostics)
Ejemplo n.º 8
0
 def test_1(self):
     self.__files.create({
         'a.csv': textwrap.dedent('''\
              Name,Frequency
              a,1
         '''),
         'not-a-csv': '',
     })
     dbs, diagnostics = db.databases_from_directory(reactor, self.__files.dir)
     self.assertEqual([], diagnostics)
     self.assertEqual(['a.csv'], dbs.keys())
Ejemplo n.º 9
0
 def test_1(self):
     with open(os.path.join(self.__temp_dir, 'a.csv'), 'w') as f:
         f.write(textwrap.dedent('''\
             Name,Frequency
             a,1
         '''))
     with open(os.path.join(self.__temp_dir, 'not-a-csv'), 'w') as f:
         pass
     dbs, diagnostics = db.databases_from_directory(reactor, self.__temp_dir)
     self.assertEqual([], diagnostics)
     self.assertEqual(['a.csv'], dbs.keys())
Ejemplo n.º 10
0
 def test_1(self):
     self.__files.create({
         'a.csv': textwrap.dedent('''\
              Name,Frequency
              a,1
         '''),
         'not-a-csv': '',
     })
     dbs, diagnostics = db.databases_from_directory(reactor, self.__files.dir)
     self.assertEqual([], diagnostics)
     self.assertEqual(['a.csv'], list(dbs.keys()))
Ejemplo n.º 11
0
 def test_1(self):
     with open(os.path.join(self.__temp_dir, 'a.csv'), 'w') as f:
         f.write(
             textwrap.dedent('''\
             Name,Frequency
             a,1
         '''))
     with open(os.path.join(self.__temp_dir, 'not-a-csv'), 'w') as f:
         pass
     dbs, diagnostics = db.databases_from_directory(reactor,
                                                    self.__temp_dir)
     self.assertEqual([], diagnostics)
     self.assertEqual(['a.csv'], dbs.keys())
Ejemplo n.º 12
0
 def add_directory(self, path):
     self._config._not_finished()
     path = str(path)
     dbs, path_diagnostics = databases_from_directory(self.__reactor, path)
     self.__read_only_databases.update(dbs)
     self.__report(path_diagnostics)
Ejemplo n.º 13
0
 def add_directory(self, path):
     self._config._not_finished()
     path = str(path)
     dbs, path_diagnostics = databases_from_directory(self.__reactor, path)
     self.__read_only_databases.update(dbs)
     self.__report(path_diagnostics)