Пример #1
0
 def test_apps_post_no_data(self, AppHandler, resp_mock, request_mock,
                            mock_img):
     request_mock.body = ''
     request_mock.content_type = 'application/json'
     request_mock.security_context = None
     app.AppsController().post()
     self.assertEqual(400, resp_mock.status)
Пример #2
0
 def test_apps_get_all(self, AppHandler, resp_mock, request_mock):
     hand_get = AppHandler.return_value.get_all
     fake_app = fakes.FakeApp()
     hand_get.return_value = [fake_app]
     resp = app.AppsController().get_all()
     self.assertIsNotNone(resp)
     self.assertEqual(200, resp_mock.status)
     hand_get.assert_called_with()
Пример #3
0
 def test_apps_post_no_app_name(self, AppHandler, resp_mock, request_mock,
                                mock_img):
     json_create = {'name': '',
                    'languagepack': 'fakelp'}
     request_mock.body = json.dumps(json_create)
     request_mock.content_type = 'application/json'
     request_mock.security_context = None
     hand_create = AppHandler.return_value.create
     fake_app = objects.registry.App(**json_create)
     hand_create.return_value = fake_app
     app.AppsController().post()
     self.assertEqual(400, resp_mock.status)
Пример #4
0
 def test_apps_post(self, AppHandler, resp_mock, request_mock):
     json_create = {'name': 'fakeapp', 'languagepack': 'fakelp'}
     request_mock.body = json.dumps(json_create)
     request_mock.content_type = 'application/json'
     request_mock.security_context = None
     hand_create = AppHandler.return_value.create
     fake_app = objects.registry.App(**json_create)
     hand_create.return_value = fake_app
     app.AppsController().post()
     self.assertTrue(hand_create.called)
     created_app = hand_create.call_args[0][0]
     self.assertEqual(created_app['name'], json_create['name'])
     self.assertEqual(201, resp_mock.status)
Пример #5
0
 def test_apps_post_lp_not_found(self, AppHandler, resp_mock, request_mock,
                                 mock_img):
     json_create = {'name': 'fakeapp',
                    'languagepack': 'fakelp'}
     fi = fakes.FakeImage()
     not_found = exception.ResourceNotFound(name='lp', id='fakelp')
     mock_img.get_lp_by_name_or_uuid.side_effect = not_found
     mock_img.return_value = fi
     request_mock.body = json.dumps(json_create)
     request_mock.content_type = 'application/json'
     request_mock.security_context = None
     hand_create = AppHandler.return_value.create
     fake_app = objects.registry.App(**json_create)
     hand_create.return_value = fake_app
     ret = app.AppsController().post()
     expected = 'The Languagepack fakelp could not be found.'
     self.assertEqual(expected, ret['faultstring'])
Пример #6
0
class Controller(object):
    """Version 1 API controller root."""

    plans = plan.PlansController()
    apps = app.AppsController()
    assemblies = assembly.AssembliesController()
    services = service.ServicesController()
    components = component.ComponentsController()
    extensions = extension.ExtensionsController()
    operations = operation.OperationsController()
    sensors = sensor.SensorsController()
    language_packs = language_pack.LanguagePacksController()
    pipelines = pipeline.PipelinesController()
    triggers = trigger.TriggerController()
    infrastructure = infrastructure.InfrastructureController()

    @exception.wrap_wsme_pecan_controller_exception
    @wsme_pecan.wsexpose(Platform)
    def index(self):
        base_url = pecan.request.application_url.rstrip('/')
        host_url = '%s/%s' % (base_url, 'v1')
        return Platform(uri=host_url,
                        name='solum',
                        type='platform',
                        description='solum native implementation',
                        implementation_version=version.version_string(),
                        plans_uri='%s/plans' % host_url,
                        apps_uri='%s/apps' % host_url,
                        assemblies_uri='%s/assemblies' % host_url,
                        services_uri='%s/services' % host_url,
                        components_uri='%s/components' % host_url,
                        extensions_uri='%s/extensions' % host_url,
                        operations_uri='%s/operations' % host_url,
                        sensors_uri='%s/sensors' % host_url,
                        language_packs_uri='%s/language_packs' % host_url,
                        pipelines_uri='%s/pipelines' % host_url,
                        triggers_uri='%s/triggers' % host_url,
                        infrastructure_uri='%s/infrastructure' % host_url)