Example #1
0
    def test_assemblies_post_ref_rel_uris(self, PlanHandler, AssemblyHandler,
                                          resp_mock, request_mock):
        hand_get = PlanHandler.return_value.get
        hand_get.return_value = fakes.FakePlan()

        hand_create_from_plan = AssemblyHandler.return_value.create_from_plan
        fake_assembly = fakes.FakeAssembly()
        hand_create_from_plan.return_value = fake_assembly

        cntrl = assemblies.AssembliesController()

        # test reference to CAMP plan relative to assemblies
        ref_object = {'plan_uri':
                      '../plans/24e3974c-195d-4a6a-96b0-7924ed3c742a'}
        request_mock.content_type = 'application/json'
        request_mock.body = json.dumps(ref_object)

        resp = cntrl.post()
        self.assertIsNotNone(resp)
        self.assertEqual(201, resp_mock.status)
        self.assertIsNotNone(resp_mock.location)
        self.assertEqual(fake_assembly.name, resp['name'])

        # test reference to Solum plan relative to assemblies
        ref_object = {'plan_uri':
                      '../../../v1/plans/24e3974c-195d-4a6a-96b0-7924ed3c742a'}
        request_mock.content_type = 'application/json'
        request_mock.body = json.dumps(ref_object)

        resp = cntrl.post()
        self.assertIsNotNone(resp)
        self.assertEqual(201, resp_mock.status)
        self.assertIsNotNone(resp_mock.location)
        self.assertEqual(fake_assembly.name, resp['name'])

        # test reference to CAMP plan relative to root
        ref_object = {'plan_uri':
                      '/camp/v1_1/plans/24e3974c-195d-4a6a-96b0-7924ed3c742a'}
        request_mock.content_type = 'application/json'
        request_mock.body = json.dumps(ref_object)

        resp = cntrl.post()
        self.assertIsNotNone(resp)
        self.assertEqual(201, resp_mock.status)
        self.assertIsNotNone(resp_mock.location)
        self.assertEqual(fake_assembly.name, resp['name'])

        # test reference to Solum plan relative to root
        ref_object = {'plan_uri':
                      '/v1/plans/24e3974c-195d-4a6a-96b0-7924ed3c742a'}
        request_mock.content_type = 'application/json'
        request_mock.body = json.dumps(ref_object)

        resp = cntrl.post()
        self.assertIsNotNone(resp)
        self.assertEqual(201, resp_mock.status)
        self.assertIsNotNone(resp_mock.location)
        self.assertEqual(fake_assembly.name, resp['name'])
Example #2
0
    def test_assemblies_post_ref_empty_json(self, PlanHandler, AssemblyHandler,
                                            resp_mock, request_mock):
        # a Content-Type of 'application/json' indicates that the user is
        # providing a JSON object that references either a plan or a PDP
        request_mock.content_type = 'application/json'
        request_mock.body = '{}'

        assemblies.AssembliesController().post()
        self.assertEqual(400, resp_mock.status)
Example #3
0
    def test_assemblies_post_no_content_type(self, PlanHandler,
                                             AssemblyHandler, resp_mock,
                                             request_mock):
        # creating an assembly requires a Content-Type so the CAMP impl
        # can figure out which mechanism the user wants
        request_mock.content_type = None

        assemblies.AssembliesController().post()
        self.assertEqual(415, resp_mock.status)
Example #4
0
    def test_assemblies_post_ref_bad_rel_uri(self, PlanHandler,
                                             AssemblyHandler, resp_mock,
                                             request_mock):
        # a Content-Type of 'application/json' indicates that the user is
        # providing a JSON object that references either a plan or a PDP
        ref_object = {'plan_uri':
                      '../fooble/24e3974c-195d-4a6a-96b0-7924ed3c742a'}
        request_mock.content_type = 'application/json'
        request_mock.body = json.dumps(ref_object)

        assemblies.AssembliesController().post()
        self.assertEqual(400, resp_mock.status)
Example #5
0
    def test_assemblies_get(self, PlanHandler, AssemblyHandler, resp_mock,
                            request_mock):
        hand_get_all = AssemblyHandler.return_value.get_all
        fake_assembly = fakes.FakeAssembly()
        hand_get_all.return_value = [fake_assembly]

        resp = assemblies.AssembliesController().get()
        self.assertIsNotNone(resp)
        self.assertEqual(200, resp_mock.status)
        self.assertIsNotNone(resp['result'].assembly_links)
        assembly_links = resp['result'].assembly_links
        self.assertEqual(1, len(assembly_links))
        self.assertEqual(fake_assembly.name, assembly_links[0].target_name)
Example #6
0
class Controller(rest.RestController):
    """CAMP API version 1.1 controller root."""

    assemblies = assemblies.AssembliesController()
    attribute_definitions = (
        attribute_definitions.AttributeDefinitionsController())
    extensions = extensions.ExtensionsController()
    formats = formats.FormatsController()
    parameter_definitions = (
        parameter_definitions.ParameterDefinitionsController())
    plans = plans.PlansController()
    platform = platform.PlatformController()
    services = services.ServicesController()
    type_definitions = type_definitions.TypeDefinitionsController()