Exemplo n.º 1
0
 def test_get_read_collection_path(self):
     path = get_read_collection_path(get_collection_class(IMyEntity),
                                     CsvMime, directory=self._data_dir)
     self.assert_false(path is None)
     tmp_dir = tempfile.mkdtemp()
     tmp_path = get_read_collection_path(get_collection_class(IMyEntity),
                                         CsvMime, directory=tmp_dir)
     self.assert_true(tmp_path is None)
Exemplo n.º 2
0
 def test_get_read_collection_path(self, data_dir, class_configurator):
     class_configurator.begin()
     try:
         reg = class_configurator.registry
         orig_data_dir = os.path.join(data_dir, 'original')
         coll_cls = reg.getUtility(IMyEntity, name='collection-class')
         path = get_read_collection_path(coll_cls, CsvMime,
                                         directory=orig_data_dir)
         assert not path is None
         tmp_dir = tempfile.mkdtemp()
         tmp_path = get_read_collection_path(coll_cls, CsvMime,
                                             directory=tmp_dir)
         assert tmp_path is None
     finally:
         class_configurator.end()
Exemplo n.º 3
0
 def test_get_read_collection_path(self, data_dir, class_configurator):
     class_configurator.begin()
     try:
         reg = class_configurator.registry
         orig_data_dir = os.path.join(data_dir, 'original')
         coll_cls = reg.getUtility(IMyEntity, name='collection-class')
         path = get_read_collection_path(coll_cls,
                                         CsvMime,
                                         directory=orig_data_dir)
         assert not path is None
         tmp_dir = tempfile.mkdtemp()
         tmp_path = get_read_collection_path(coll_cls,
                                             CsvMime,
                                             directory=tmp_dir)
         assert tmp_path is None
     finally:
         class_configurator.end()
Exemplo n.º 4
0
 def __load_entities(self, entity_class):
     coll_cls = get_collection_class(entity_class)
     fn = get_read_collection_path(coll_cls, self._config['content_type'],
                                   directory=self._config['directory'])
     if not fn is None:
         url = 'file://%s' % fn
         coll = load_collection_from_url(coll_cls, url,
                                         content_type=
                                             self._config['content_type'])
         ents = [mb.get_entity() for mb in coll]
     else:
         ents = []
     return ents