Beispiel #1
0
 def test_set_collection_parent_fails(self, class_configurator,
                                      resource_repo):
     class_configurator.add_resource(IFoo, FooMember, FooEntity,
                                     expose=False)
     coll = create_staging_collection(IFoo)
     srvc = get_service()
     with pytest.raises(ValueError) as cm:
         resource_repo.set_collection_parent(coll, srvc)
     assert str(cm.value).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'))
Beispiel #3
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'))
Beispiel #4
0
 def test_set_collection_parent_fails(self, class_configurator,
                                      resource_repo):
     class_configurator.add_resource(IFoo,
                                     FooMember,
                                     FooEntity,
                                     expose=False)
     coll = create_staging_collection(IFoo)
     srvc = get_service()
     with pytest.raises(ValueError) as cm:
         resource_repo.set_collection_parent(coll, srvc)
     assert str(cm.value).startswith('No root collect')
Beispiel #5
0
 def __make_parent_and_link(self):
     # FIXME: This is more elaborate than it should be - to make URL
     #        generation work, we have to manually set the parent of the
     #        root collection and create a dummy request.
     coll = get_root_collection(IMyEntity)
     svc = get_service()
     coll.__parent__ = svc
     ent = MyEntity(id=0)
     mb = coll.create_member(ent)
     # Make a dummy request.
     url = self._get_app_url()
     req = DummyRequest(application_url=url, host_url=url,
                        path_url=url, url=url,
                        registry=self.config.registry)
     mb_url = resource_to_url(mb, request=req)
     return mb, mb_url
Beispiel #6
0
 def __make_parent_and_link(self):
     # FIXME: This is more elaborate than it should be - to make URL
     #        generation work, we have to manually set the parent of the
     #        root collection and create a dummy request.
     coll = get_root_collection(IMyEntity)
     svc = get_service()
     coll.__parent__ = svc
     ent = MyEntity(id=0)
     mb = coll.create_member(ent)
     # Make a dummy request.
     url = self._get_app_url()
     req = DummyRequest(application_url=url, host_url=url,
                        path_url=url, url=url,
                        registry=self.config.registry)
     mb_url = resource_to_url(mb, request=req)
     return mb, mb_url
Beispiel #7
0
 def test_put_member_warning_exception(self, wrn_vw_app_creator):
     root = get_service()
     # Need to start the service manually - no request root has been set
     # yet.
     root.start()
     coll = root['foos']
     mb = FooMember(FooEntity(id=0))
     coll.add(mb)
     transaction.commit()
     path = '/'.join((self.path, '0'))
     # First PUT - get back a 307.
     res1 = wrn_vw_app_creator.put(path, params='foo name', status=307)
     assert res1.body.startswith(b'307 Temporary Redirect')
     # Second PUT to redirection location - get back a 200.
     resubmit_location1 = res1.headers['Location']
     res2 = wrn_vw_app_creator.put(resubmit_location1,
                                   params='foo name',
                                   status=200)
     assert not res2 is None
Beispiel #8
0
 def test_put_member_warning_exception(self):
     root = get_service()
     # Need to start the service manually - no request root has been set
     # yet.
     root.start()
     coll = root['foos']
     mb = FooMember(FooEntity(id=0))
     coll.add(mb)
     transaction.commit()
     path = '/'.join((self.path, '0'))
     # First PUT - get back a 307.
     res1 = self.app.put(path,
                         params='foo name',
                         status=307)
     self.assert_true(res1.body.startswith(b'307 Temporary Redirect'))
     # Second PUT to redirection location - get back a 200.
     resubmit_location1 = res1.headers['Location']
     res2 = self.app.put(resubmit_location1, params='foo name',
                         status=200)
     self.assert_true(not res2 is None)
Beispiel #9
0
 def set_up(self):
     ResourceTestCase.set_up(self)
     self.srv = get_service()
Beispiel #10
0
 def set_up(self):
     ResourceTestCase.set_up(self)
     self.srv = get_service()
Beispiel #11
0
 def __call__(self, request):
     if self.__root is None:
         # Start the service.
         self.__root = get_service()
         self.__root.start()
     return self.__root
Beispiel #12
0
 def is_nested(self):
     return not self.__parent__ is get_service()