def test_cannot_create_the_same_offering_twice(self, context, api_service_admin_client): """ <b>Description:</b> Attempts to create offering twice via api service <b>Input data:</b> - Admin credentials <b>Expected results:</b> - It's not possible to create the same offering twice <b>Steps:</b> - Create the offering via api service and verify it's on the list - Try to create that offering again - Verify that catalog has not changed """ step("Create new offering") test_offering = ServiceOffering.create(context, client=api_service_admin_client) step("Check that the offering exists") catalog = ServiceOffering.get_list(client=api_service_admin_client) assert test_offering in catalog step("Try creating offering with name of an already existing offering") assert_raises_http_exception( ApiServiceHttpStatus.CODE_CONFLICT, ApiServiceHttpStatus.MSG_SERVICE_ALREADY_EXISTS.format( test_offering.label), ServiceOffering.create, context, label=test_offering.label, client=api_service_admin_client) step("Check that catalog has not changed") assert sorted(ServiceOffering.get_list( client=api_service_admin_client)) == sorted(catalog)
def offering_from_python_app(self, context, api_service_admin_client, sample_python_app): app = sample_python_app image = Application.get_image(app_inst_id=app.id, client=api_service_admin_client) offering_json = template_example.sample_python_app_offering offering_json['body'][0]['deployments'][0]['spec']['template']['spec']['containers'][0]['image'] = image offering = ServiceOffering.create(context, client=api_service_admin_client, template_body=offering_json['body']) service = ServiceInstance.create_with_name(context, offering_label=offering.label, plan_name=offering.service_plans[0].name) ServiceInstance.ensure_running(service, client=api_service_admin_client) return service
def offering_nats(self, class_context, api_service_admin_client): test_offering = ServiceOffering.create( class_context, template_body=template_example.nats_template["body"], client=api_service_admin_client) catalog_offerings = CatalogService.get_list() offering = next( (o for o in catalog_offerings if o.name == test_offering.label), None) assert offering is not None, "No such offering {}".format( test_offering.label) return offering
def test_create_and_delete_new_offering(self, context, api_service_admin_client): """ <b>Description:</b> Create and later remove offering via api service <b>Input data:</b> - Admin credentials <b>Expected results:</b> - It's possible to create offering - It's possible to remove the offering <b>Steps:</b> - Create the offering via api service - Verify the offering is on list - Verify it's possible to retrieve offering via id - Remove the offering - Verify the offering was removed """ step("Create new offering") test_offering = ServiceOffering.create(context, client=api_service_admin_client) step("Check that the new offering is in catalog") catalog = ServiceOffering.get_list(client=api_service_admin_client) assert test_offering in catalog step("Get the offering") offering = ServiceOffering.get(offering_id=test_offering.id, client=api_service_admin_client) assert test_offering == offering step("Delete the offering") test_offering.delete(client=api_service_admin_client) step("Check that the offering is no longer in catalog") catalog = ServiceOffering.get_list(client=api_service_admin_client) assert test_offering not in catalog step("Check that requesting the deleted offering returns an error") assert_raises_http_exception(ApiServiceHttpStatus.CODE_NOT_FOUND, ApiServiceHttpStatus.MSG_KEY_NOT_FOUND, test_offering.delete, client=api_service_admin_client, force=True)
def sample_service_from_template(class_context): log_fixture("Create new example service") sample_service = ServiceOffering.create(context=class_context) log_fixture("Check the service is ready") sample_service.ensure_ready() return sample_service