Ejemplo n.º 1
0
class Controller(object):
    """Version 1 API controller root."""

    plans = plan.PlansController()
    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()
    public = public.PublicController()
    infrastructure = infrastructure.InfrastructureController()

    @exception.wrap_wsme_controller_exception
    @wsme_pecan.wsexpose(Platform)
    def index(self):
        host_url = '%s/%s' % (pecan.request.host_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,
                        assemblies_uri='%s/assemblies' % host_url,
                        services_uri='%s/services' % host_url,
                        components_uri='%s/components' % host_url,
                        extensions_uri='%s/extensions' % host_url,
                        language_packs_uri='%s/language_packs' % host_url)
Ejemplo n.º 2
0
 def test_sensors_post_nodata(self, handler_mock, resp_mock, request_mock):
     request_mock.body = ''
     request_mock.content_type = 'application/json'
     handler_create = handler_mock.return_value.create
     handler_create.return_value = fakes.FakeSensor()
     ret_val = controller.SensorsController().post()
     self.assertEqual("Missing argument: \"data\"",
                      str(ret_val['faultstring']))
     self.assertEqual(400, resp_mock.status)
Ejemplo n.º 3
0
 def test_sensors_get_all(self, handler_mock, resp_mock, request_mock):
     hand_get_all = handler_mock.return_value.get_all
     fake_sensor = fakes.FakeSensor()
     hand_get_all.return_value = [fake_sensor]
     obj = controller.SensorsController()
     resp = obj.get_all()
     self.assertIsNotNone(resp)
     self.assertEqual(fake_sensor.name, resp['result'][0].name)
     self.assertEqual(fake_sensor.documentation,
                      resp['result'][0].documentation)
     self.assertEqual(fake_sensor.description,
                      resp['result'][0].description)
     self.assertEqual(fake_sensor.project_id, resp['result'][0].project_id)
     self.assertEqual(fake_sensor.uuid, resp['result'][0].uuid)
     hand_get_all.assert_called_with()
     self.assertEqual(200, resp_mock.status)
Ejemplo n.º 4
0
 def test_sensors_post(self, handler_mock, resp_mock,
                       request_mock, mock_policy):
     mock_policy.return_value = True
     json_update = {'value': '1234',
                    'name': 'test_name_changed',
                    'user_id': 'user_id',
                    'project_id': 'test_id',
                    'description': 'desc test',
                    'sensor_type': 'str',
                    'documentation': 'http://example.com/docs/blabla/',
                    'target_resource': 'http://example.com/target/'}
     request_mock.body = json.dumps(json_update)
     request_mock.content_type = 'application/json'
     handler_create = handler_mock.return_value.create
     handler_create.return_value = fakes.FakeSensor()
     obj = controller.SensorsController()
     obj.post(fakes.FakeSensor())
     self.assertEqual(201, resp_mock.status)
     handler_create.assert_called_once_with(json_update)
Ejemplo n.º 5
0
 def test_sensors_get_all(self, handler_mock, resp_mock, request_mock):
     obj = controller.SensorsController()
     resp = obj.get_all()
     self.assertIsNotNone(resp)
     self.assertEqual(200, resp_mock.status)
Ejemplo n.º 6
0
 def test_sensors_post(self, resp_mock, request_mock):
     obj = controller.SensorsController()
     obj.post(None)
     self.assertEqual(400, resp_mock.status)