コード例 #1
0
    def setUp(self):
        super().setUp()
        self.test_plan = Plan(
            id='testplan', name='testing plan', description='plan for testing',
            metadata=None, free=True, bindable=False
        )
        self.test_service = ServiceType(
            id='test',
            name='test_svc',
            short_name='TS',
            description='this is a test service',
            bindable=False,
            tags=['test', 'tester'],
            metadata=None, requires=[],
            plan_updateable=False, plans=[self.test_plan],
            dashboard_client=None)

        path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
        with open(path + "/manifests/docker-compose.yml", "r") as mani_file:
            mani = mani_file.read()

        with open(path + '/manifests/test_endpoints.json', 'r') as ep_file:
            ep = ep_file.read()

        self.test_manifest = Manifest(
            id='test', plan_id=self.test_plan.id, service_id=self.test_service.id,
            manifest_type='dummy', manifest_content=mani, endpoints=json.loads(ep)
        )
コード例 #2
0
 def model_sql_to_model(model_sql: PlanSQL) -> Plan:
     model = Plan()
     ''' STRINGS '''
     model.name = model_sql.name
     model.id = model_sql.id_name
     model.description = model_sql.description
     ''' BOOLEANS '''
     model.bindable = model_sql.bindable
     model.free = model_sql.free
     ''' OBJECTS '''
     model.metadata = PlanMetadataAdapter.from_blob(model_sql.metadata)
     return model
コード例 #3
0
 def sample_model(name='plan1') -> Plan:
     model = Plan()
     ''' STRINGS '''
     model.name = name
     model.id = name
     model.description = name
     ''' BOOLEANS '''
     model.free = True
     model.bindable = False
     ''' OBJECTS '''
     model.metadata = PlanMetadata(display_name='metadata1')
     return model
コード例 #4
0
    def setUp(self):
        super().setUp()

        self.store = STORE
        self.instance_id = 'this_is_a_test_instance'

        self.test_plan = Plan(
            id='testplan', name='testing plan', description='plan for testing',
            metadata=None, free=True, bindable=False
        )

        self.test_service = ServiceType(
            id='test-svc', name='test_svc',
            description='this is a test service',
            bindable=False,
            tags=['test', 'tester'],
            metadata=None, requires=[],
            plan_updateable=False, plans=[self.test_plan],
            dashboard_client=None)

        self.store.add_service(self.test_service)
        print('Service registration content of:\n {content}'.format(content=json.dumps(self.test_service)))

        path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
        with open(path + "/manifests/docker-compose.yml", "r") as mani_file:
            mani = mani_file.read()

        with open(path + '/manifests/test_endpoints.json', 'r') as ep_file:
            ep = ep_file.read()

        # if os.environ.get('DOCKER_TESTS', 'NO') == 'YES':
        #     self.test_manifest = Manifest(
        #         id='test-mani', plan_id=self.test_plan.id, service_id=self.test_service.id,
        #         manifest_type='docker-compose', manifest_content=mani, endpoints=json.loads(ep)
        #     )
        # else:
        self.test_manifest = Manifest(
            id='test-mani', plan_id=self.test_plan.id, service_id=self.test_service.id,
            manifest_type='dummy', manifest_content=mani, endpoints=json.loads(ep)
        )

        self.store.add_manifest(self.test_manifest)
        print('Manifest registration content of:\n {content}'.format(content=json.dumps(self.test_manifest)))
    def setUp(self):
        super().setUp()
        sql_host = os.environ.get('ESM_SQL_HOST',
                                  os.environ.get('ET_EDM_MYSQL_HOST', ''))
        if sql_host:
            STORE.set_up()

        self.store = STORE
        if len(self.store.get_service_instance()) > 0:
            raise Exception(
                'This shouldnt happen - the store should be empty on each run!'
            )

        self.instance_id = 'this_is_a_test_instance'
        self.binding_id = 'this_is_a_test_instance_binding'

        self.test_plan = Plan(id='testplan',
                              name='testing plan',
                              description='plan for testing',
                              metadata=None,
                              free=True,
                              bindable=False)

        self.test_service = ServiceType(id='test-svc',
                                        name='test_svc',
                                        description='this is a test service',
                                        bindable=True,
                                        tags=['test', 'tester'],
                                        metadata=None,
                                        requires=[],
                                        plan_updateable=False,
                                        plans=[self.test_plan],
                                        dashboard_client=None)

        self.store.add_service(self.test_service)
        print('Service registration content of:\n {content}'.format(
            content=json.dumps(self.test_service)))

        path = os.path.dirname(
            os.path.abspath(inspect.getfile(inspect.currentframe())))
        with open(path + MANIFEST, "r") as mani_file:
            mani = mani_file.read()

        with open(path + '/manifests/test_endpoints.json', 'r') as ep_file:
            ep = ep_file.read()

        if os.getenv('DOCKER_TESTS', 'NO') == 'YES':
            m_type = 'docker-compose'
        else:
            m_type = 'dummy'

        self.test_manifest = Manifest(id='test-mani',
                                      plan_id=self.test_plan.id,
                                      service_id=self.test_service.id,
                                      manifest_type=m_type,
                                      manifest_content=mani,
                                      endpoints=json.loads(ep))
        self.store.add_manifest(self.test_manifest)
        print('Manifest registration content of:\n {content}'.format(
            content=json.dumps(self.test_manifest)))

        self.response = self._send_service_request()
        self._assert200(self.response)