Ejemplo n.º 1
0
    def test_delete_from_collection_for_sanity(self):
        '''
        Check if the delete functionalities are implemented correctly.
        '''
        res1 = Resource('/foo/1', self.kind, [self.mixin], [])
        res2 = Resource('/foo/2', self.kind, [self.mixin], [])

        self.registry.add_resource('/foo/1', res1)
        self.registry.add_resource('/foo/2', res2)

        workflow.delete_from_collection(self.mixin, [res2], self.registry)
        self.assertTrue(self.mixin not in res2.mixins)
        self.assertTrue(self.mixin in res1.mixins)
Ejemplo n.º 2
0
    def test_delete_from_collection_for_sanity(self):
        '''
        Check if the delete functionalities are implemented correctly.
        '''
        res1 = Resource('/foo/1', self.kind, [self.mixin], [])
        res2 = Resource('/foo/2', self.kind, [self.mixin], [])

        self.registry.add_resource('/foo/1', res1)
        self.registry.add_resource('/foo/2', res2)

        workflow.delete_from_collection(self.mixin, [res2], self.registry)
        self.assertTrue(self.mixin not in res2.mixins)
        self.assertTrue(self.mixin in res1.mixins)
Ejemplo n.º 3
0
    def delete(self, key):
        if key == '' or key[-1] != '/':
            key += '/'
        if len(self.parse_entities()) == 0:
            # delete entities
            entities = workflow.get_entities_under_path(key, self.registry)
            for entity in entities:
                workflow.delete_entity(entity, self.registry)

            self.response(200, self.registry.get_default_type(), None)
        elif len(self.parse_entities()) > 0:
            # remove from collection
            try:
                mixin = self.registry.get_category(key)
                entities = self.parse_entities()
                workflow.delete_from_collection(mixin, entities, self.registry)

                self.response(200, self.registry.get_default_type(), None)
            except AttributeError as attr:
                raise HTTPError(400, str(attr))