示例#1
0
 def instance(self, context, sample_service):
     step("Create an instance")
     instance = ServiceInstance.create(context, offering_id=sample_service.id,
                                       plan_id=sample_service.service_plans[0]["entity"]["id"])
     step("Ensure that instance is running")
     instance.ensure_running()
     return instance
示例#2
0
 def test_cannot_create_instance_as_user_from_different_org(
         self, context, marketplace_offerings, test_user_clients, role):
     client = test_user_clients[role]
     org = "DIFFERENT_ORG"
     errors = []
     for offering in marketplace_offerings:
         offering_id = offering.id
         plan_id = offering.service_plans[0].id
         step("Try to create {} service instance".format(offering.label))
         with pytest.raises(UnexpectedResponseError) as e:
             # TODO org not supported yet
             ServiceInstance.create(context,
                                    offering_id=offering_id,
                                    plan_id=plan_id,
                                    org=org,
                                    client=client)
         if e is None or e.value.status != HttpStatus.CODE_FORBIDDEN:
             errors.append(
                 "Service '{}' failed to respond with given error status.".
                 format(offering.label))
     assert_no_errors(errors)
示例#3
0
    def test_cannot_remove_service_with_instance(self, context, sample_service,
                                                 test_user_clients, role):
        """
        <b>Description:</b>
        Try to delete a service offering with created service instance.

        <b>Input data:</b>
        1. user client
        2. sample service offering

        <b>Expected results:</b>
        Test passes when service offering cannot be deleted.

        <b>Steps:</b>
        1. Create service instance.
        2. Ensure that instance is running.
        3. Try to delete service offering.
        4. Check that platform returns a 405 http status code
        and message that service offering with instance cannot be deleted.
        """
        client = test_user_clients[role]
        offering_id = sample_service.id
        plan_id = sample_service.service_plans[0].id

        step("Create an instance")
        instance = ServiceInstance.create(context,
                                          offering_id=offering_id,
                                          plan_id=plan_id,
                                          client=client)

        step("Ensure that instance is running")
        instance.ensure_running()

        step("Check that service instance is present")
        assert_in_with_retry(instance,
                             ServiceInstance.get_list,
                             name=instance.name)

        step("Attempt to delete public service with instance")
        assert_raises_http_exception(
            HttpStatus.CODE_FORBIDDEN,
            HttpStatus.MSG_CANNOT_REMOVE_SERVICE_WITH_INSTANCE,
            sample_service.delete)