Example #1
0
 def test_repo_has_loaded_entities(self, resource_repo):
     default_agg = resource_repo.get_aggregate(IMyEntity)
     assert len(list(default_agg.iterator())) == 0
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get('CUSTOM_MEMORY_WITH_CACHE_LOADER')
     agg = repo.get_aggregate(IMyEntity)
     assert len(list(agg.iterator())) == 1
Example #2
0
 def test_repo_has_loaded_entities(self, resource_repo):
     default_agg = resource_repo.get_aggregate(IMyEntity)
     assert len(list(default_agg.iterator())) == 0
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get('CUSTOM_MEMORY_WITH_CACHE_LOADER')
     agg = repo.get_aggregate(IMyEntity)
     assert len(list(agg.iterator())) == 1
Example #3
0
 def test_init_no_name(self, class_configurator):
     class_configurator.begin()
     try:
         repo_mgr = get_repository_manager()
         repo = repo_mgr.new(REPOSITORY_TYPES.MEMORY)
         assert repo.name.startswith(REPOSITORY_TYPES.MEMORY)
     finally:
         class_configurator.end()
Example #4
0
 def test_manager(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.MEMORY)
     self.assert_raises(ValueError, repo_mgr.set, repo)
     with self.assert_raises(ValueError) as cm:
         repo_mgr.new('foo', 'bar')
     exc_msg = 'Unknown repository type.'
     self.assert_equal(cm.exception.message, exc_msg)
Example #5
0
 def test_manager(self, resource_repo):
     repo_mgr = get_repository_manager()
     with pytest.raises(ValueError):
         repo_mgr.set(resource_repo)
     with pytest.raises(ValueError) as cm:
         repo_mgr.new('foo', 'bar')
     exc_msg = 'Unknown repository type'
     assert str(cm.value).startswith(exc_msg)
Example #6
0
 def test_init_no_name(self, class_configurator):
     class_configurator.begin()
     try:
         repo_mgr = get_repository_manager()
         repo = repo_mgr.new(REPOSITORY_TYPES.MEMORY)
         assert repo.name.startswith(REPOSITORY_TYPES.MEMORY)
     finally:
         class_configurator.end()
Example #7
0
 def test_manager(self, resource_repo):
     repo_mgr = get_repository_manager()
     with pytest.raises(ValueError):
         repo_mgr.set(resource_repo)
     with pytest.raises(ValueError) as cm:
         repo_mgr.new('foo', 'bar')
     exc_msg = 'Unknown repository type'
     assert str(cm.value).startswith(exc_msg)
 def test_manager(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.MEMORY)
     self.assert_raises(ValueError, repo_mgr.set, repo)
     with self.assert_raises(ValueError) as cm:
         repo_mgr.new('foo', 'bar')
     exc_msg = 'Unknown repository type.'
     self.assert_equal(cm.exception.message, exc_msg)
Example #9
0
 def test_manager(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.MEMORY)
     self.assert_raises(ValueError, repo_mgr.set, repo)
     with self.assert_raises(ValueError) as cm:
         repo_mgr.new('foo', 'bar')
     exc_msg = 'Unknown repository type'
     self.assert_true(str(cm.exception).startswith(exc_msg))
Example #10
0
 def test_set_collection_parent_fails(self):
     self.config.add_resource(IFoo, FooMember, FooEntity, expose=False)
     coll = create_staging_collection(IFoo)
     srvc = get_service()
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.MEMORY)
     with self.assert_raises(ValueError) as cm:
         repo.set_collection_parent(coll, srvc)
     self.assert_true(cm.exception.message.startswith('No root collect'))
 def test_set_collection_parent_fails(self):
     self.config.add_resource(IFoo, FooMember, FooEntity, expose=False)
     coll = create_staging_collection(IFoo)
     srvc = get_service()
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.MEMORY)
     with self.assert_raises(ValueError) as cm:
         repo.set_collection_parent(coll, srvc)
     self.assert_true(cm.exception.message.startswith('No root collect'))
Example #12
0
 def test_init(self, config):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.NO_SQL)
     self.assert_true(IRepository.providedBy(repo)) # pylint: disable=E1101
     # Test initialization through config.
     tmp_name = 'TMP'
     config.add_nosql_repository(tmp_name)
     repo = repo_mgr.get(tmp_name)
     assert IRepository.providedBy(repo) # pylint: disable=E1101
Example #13
0
def wrn_vw_app_creator(app_creator):
    repo_mgr = get_repository_manager()
    repo_mgr.initialize_all()
    app_creator.config.add_collection_view(FooCollection,
                                           view=UserMessagePostCollectionView,
                                           request_method=RequestMethods.POST)
    app_creator.config.add_member_view(FooMember,
                                       view=UserMessagePutMemberView,
                                       request_method=RequestMethods.PUT)
    yield app_creator
Example #14
0
def wrn_vw_app_creator(app_creator):
    repo_mgr = get_repository_manager()
    repo_mgr.initialize_all()
    app_creator.config.add_collection_view(FooCollection,
                                           view=UserMessagePostCollectionView,
                                           request_method=RequestMethods.POST)
    app_creator.config.add_member_view(FooMember,
                                       view=UserMessagePutMemberView,
                                       request_method=RequestMethods.PUT)
    yield app_creator
Example #15
0
 def test_repo(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.MEMORY)
     # Access configuration
     repo.configure(messaging_enable=False)
     self.assert_false(repo.configuration['messaging_enable'])
     # Create a clone and check if slice is the same, but ID is different.
     for meth in (repo.get_collection, repo.get_aggregate):
         acc1 = meth(IMyEntity)
         acc2 = meth(IMyEntity)
         self.assert_not_equal(id(acc1), id(acc2))
 def test_repo(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.MEMORY)
     # Access configuration
     repo.configure(messaging_enable=False)
     self.assert_false(repo.configuration['messaging_enable'])
     # Create a clone and check if slice is the same, but ID is different.
     for meth in (repo.get_collection, repo.get_aggregate):
         acc1 = meth(IMyEntity)
         acc2 = meth(IMyEntity)
         self.assert_not_equal(id(acc1), id(acc2))
Example #17
0
 def set_up(self):
     FunctionalTestCase.set_up(self)
     self.config.load_zcml(self.config_file_name)
     # We have to call this again to initialize the newly created SYSTEM
     # repo.
     repo_mgr = get_repository_manager()
     repo_mgr.initialize_all()
     self.config.add_collection_view(FooCollection,
                                     view=UserMessagePostCollectionView,
                                     request_method=RequestMethods.POST)
     self.config.add_member_view(FooMember,
                                 view=UserMessagePutMemberView,
                                 request_method=RequestMethods.PUT)
Example #18
0
 def set_up(self):
     FunctionalTestCase.set_up(self)
     self.config.load_zcml(self.config_file_name)
     # We have to call this again to initialize the newly created SYSTEM
     # repo.
     repo_mgr = get_repository_manager()
     repo_mgr.initialize_all()
     self.config.add_collection_view(FooCollection,
                                     view=UserMessagePostCollectionView,
                                     request_method='POST')
     self.config.add_member_view(FooMember,
                                 view=UserMessagePutMemberView,
                                 request_method='PUT')
 def set_up(self):
     _PlantScribeResourcesBaseTestCase.set_up(self)
     #
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.RDB)
     data_dir = os.path.join(os.path.dirname(__file__), 'data')
     for coll_name, coll_cls in \
             (('customer', get_collection_class(ICustomer)),
              ('project', get_collection_class(IProject)),
              ('site', get_collection_class(ISite)),
              ('species', get_collection_class(ISpecies)),
              ('incidence', get_collection_class(IIncidence)),
              ):
         url = 'file://%s' % os.path.join(data_dir,
                                          '%s-collection.csv' % coll_name)
         repo.load_representation(coll_cls, url,
                                  content_type=CsvMime, resolve_urls=True)
Example #20
0
 def set_up(self):
     _PlantScribeResourcesBaseTestCase.set_up(self)
     #
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.RDB)
     data_dir = os.path.join(os.path.dirname(__file__), 'data')
     for coll_name, coll_cls in \
             (('customer', get_collection_class(ICustomer)),
              ('project', get_collection_class(IProject)),
              ('site', get_collection_class(ISite)),
              ('species', get_collection_class(ISpecies)),
              ('incidence', get_collection_class(IIncidence)),
              ):
         url = 'file://%s' % os.path.join(data_dir,
                                          '%s-collection.csv' % coll_name)
         repo.load_representation(coll_cls,
                                  url,
                                  content_type=CsvMime,
                                  resolve_urls=True)
Example #21
0
 def test_configure(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.FILE_SYSTEM)
     self.assert_raises(ValueError, repo.configure, foo='bar')
Example #22
0
 def test_repo_has_loaded_entities(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get('CUSTOM_MEMORY_WITH_CACHE_LOADER')
     agg = repo.get_aggregate(IMyEntity)
     self.assert_equal(len(list(agg.iterator())), 1)
Example #23
0
 def test_init_no_name(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.new(REPOSITORY_TYPES.MEMORY)
     self.assert_true(repo.name.startswith(REPOSITORY_TYPES.MEMORY))
 def test_configure(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get(REPOSITORY_TYPES.FILE_SYSTEM)
     self.assert_raises(ValueError, repo.configure, foo='bar')
 def test_repo_has_loaded_entities(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.get('CUSTOM_MEMORY_WITH_CACHE_LOADER')
     agg = repo.get_aggregate(IMyEntity)
     self.assert_equal(len(list(agg.iterator())), 1)
 def test_init_no_name(self):
     repo_mgr = get_repository_manager()
     repo = repo_mgr.new(REPOSITORY_TYPES.MEMORY)
     self.assert_true(repo.name.startswith(REPOSITORY_TYPES.MEMORY))