コード例 #1
0
 def test_delete_link_for_sanity(self):
     '''
     Test deletion...
     '''
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     workflow.delete_entity(self.link1, self.registry)
     self.assertFalse(self.link1 in self.src_entity.links)
     self.assertFalse(self.link1 in self.registry.get_resources())
コード例 #2
0
 def test_create_resource_link_ids_for_sanity(self):
     '''
     Test creation...
     '''
     # Check if an id get's set for the link...
     self.link1.identifier = None
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     self.assertTrue(self.link1.identifier is not None)
コード例 #3
0
 def test_create_resource_link_ids_for_sanity(self):
     '''
     Test creation...
     '''
     # Check if an id get's set for the link...
     self.link1.identifier = None
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     self.assertTrue(self.link1.identifier is not None)
コード例 #4
0
 def test_delete_link_for_sanity(self):
     '''
     Test deletion...
     '''
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     workflow.delete_entity(self.link1, self.registry)
     self.assertFalse(self.link1 in self.src_entity.links)
     self.assertFalse(self.link1 in self.registry.get_resources())
コード例 #5
0
 def test_delete_resource_for_sanity(self):
     '''
     Test deletion...
     '''
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     workflow.delete_entity(self.src_entity, self.registry)
     # ensure that both the resource and it's links are removed...
     self.assertFalse(self.src_entity in self.registry.get_resources())
     self.assertFalse(self.link1 in self.registry.get_resources())
コード例 #6
0
 def test_delete_resource_for_sanity(self):
     '''
     Test deletion...
     '''
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     workflow.delete_entity(self.src_entity, self.registry)
     # ensure that both the resource and it's links are removed...
     self.assertFalse(self.src_entity in self.registry.get_resources())
     self.assertFalse(self.link1 in self.registry.get_resources())
コード例 #7
0
 def test_create_resource_for_sanity(self):
     '''
     Test creation...
     '''
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     # id needs to be set
     self.assertEqual(self.src_entity.identifier, '/foo/src')
     # entity needs to be available
     self.assertTrue(self.src_entity in self.registry.get_resources())
     # link entity needs to be available...
     self.assertTrue(self.link1 in self.registry.get_resources())
     self.assertTrue(len(self.src_entity.links) == 1)
コード例 #8
0
 def test_create_resource_for_sanity(self):
     '''
     Test creation...
     '''
     workflow.create_entity('/foo/src', self.src_entity, self.registry)
     # id needs to be set
     self.assertEqual(self.src_entity.identifier, '/foo/src')
     # entity needs to be available
     self.assertTrue(self.src_entity in self.registry.get_resources())
     # link entity needs to be available...
     self.assertTrue(self.link1 in self.registry.get_resources())
     self.assertTrue(len(self.src_entity.links) == 1)
コード例 #9
0
 def test_create_link_for_sanity(self):
     '''
     Test creation...
     '''
     link2 = Link(None, self.link_kind, [], self.src_entity,
                  self.trg_entity)
     workflow.create_entity('/link/2', link2, self.registry)
     # id needs to be set
     self.assertEqual(link2.identifier, '/link/2')
     # entity needs to be available
     self.assertTrue(link2 in self.registry.get_resources())
     # link needs to be added to the src entity
     self.assertTrue(link2 in self.src_entity.links)
     self.assertTrue(len(self.src_entity.links) == 2)
コード例 #10
0
 def test_create_link_for_sanity(self):
     '''
     Test creation...
     '''
     link2 = Link(None, self.link_kind, [], self.src_entity,
                  self.trg_entity)
     workflow.create_entity('/link/2', link2, self.registry)
     # id needs to be set
     self.assertEqual(link2.identifier, '/link/2')
     # entity needs to be available
     self.assertTrue(link2 in self.registry.get_resources())
     # link needs to be added to the src entity
     self.assertTrue(link2 in self.src_entity.links)
     self.assertTrue(len(self.src_entity.links) == 2)
コード例 #11
0
ファイル: web.py プロジェクト: carriercomm/pyssf
    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))
コード例 #12
0
ファイル: web.py プロジェクト: carriercomm/pyssf
    def put(self, key):
        if key in self.registry.get_resource_keys():
            # replace...
            try:
                old = self.registry.get_resource(key)
                new = self.parse_entity()

                workflow.replace_entity(old, new, self.registry)

                self.render_entity(old)
            except AttributeError as attr:
                raise HTTPError(400, str(attr))
        else:
            # create...
            try:
                entity = self.parse_entity()

                workflow.create_entity(key, entity, self.registry)

                self.response(201, self.registry.get_default_type(),
                              {'Location': self.request.protocol
                                           + '://' + self.request.host + key})
            except AttributeError as attr:
                raise HTTPError(400, str(attr))