def test_update_collection_for_sanity(self): ''' Check if the update functionalities are implemented correctly. ''' res1 = Resource('/foo/target', self.kind, [self.mixin], []) res2 = Resource('/foo/target', self.kind, [], []) workflow.update_collection(self.mixin, [res1], [res2], self.registry) self.assertTrue(self.mixin in res1.mixins) self.assertTrue(self.mixin in res2.mixins)
def post(self, key): if key == '' or key[-1] != '/': key += '/' if len(self.get_arguments('action')) > 0: # action try: action = self.parse_action() entities = workflow.get_entities_under_path(key, self.registry) for entity in entities: workflow.action_entity(entity, action, self.registry) self.response(200, self.registry.get_default_type(), None) except AttributeError as attr: raise HTTPError(400, str(attr)) elif len(self.parse_entities()) == 0: # create resource (&links) try: entity = self.parse_entity() workflow.create_entity(workflow.create_id(entity.kind), entity, self.registry) self.response(201, self.registry.get_default_type(), {'Location': self.request.protocol + '://' + self.request.host + entity.identifier}) except AttributeError as attr: raise HTTPError(400, str(attr)) elif len(self.parse_entities()) > 0: # update try: mixin = self.registry.get_category(key) new_entities = self.parse_entities() old_entities = workflow.get_entities_under_path(key, self.registry) workflow.update_collection(mixin, old_entities, new_entities, self.registry) self.response(200, self.registry.get_default_type(), None) except AttributeError as attr: raise HTTPError(400, str(attr))