def upgrade(self): etag = generate_etag() Printer.start_test("Update plan") # CHECK: Plan upgrade succeeds (status, response) = self.client.perform_request( "subscriptions/%s/cloudservices/%s/resources/%s/%s" % ( self.config["subscription_id"], self.config["cloud_service_name"], self.config["resource_type"], self.config["resource_name"]), 'PUT', xmlutil.xml_for_create_resource( plan=self.config['upgrade_plan'], resource_type=self.config['resource_type'], promotion_code=self.config['promo_code'], etag=etag ), validate_xml=True ) if status in [200, 201]: Printer.success("Upgrade Resource succeeded.") Printer.info("Checking XML") else: Printer.error("Upgrade Resource failed with HTTP status code %s" % status) return t = xmlutil.get_subtree_from_xml_string(response) self._validate_resource_response(etag, t) Printer.info("Checking if new plan is %s" % self.config['upgrade_plan']) self._check_node_value(t, './{0}Plan', self.config['upgrade_plan'])
def upgrade(self): etag = generate_etag() Printer.start_test("Update plan") # CHECK: Plan upgrade succeeds (status, response) = self.client.perform_request( "subscriptions/%s/cloudservices/%s/resources/%s/%s" % (self.config["subscription_id"], self.config["cloud_service_name"], self.config["resource_type"], self.config["resource_name"]), 'PUT', xmlutil.xml_for_create_resource( plan=self.config['upgrade_plan'], resource_type=self.config['resource_type'], promotion_code=self.config['promo_code'], etag=etag), validate_xml=True) if status in [200, 201]: Printer.success("Upgrade Resource succeeded.") Printer.info("Checking XML") else: Printer.error("Upgrade Resource failed with HTTP status code %s" % status) return t = xmlutil.get_subtree_from_xml_string(response) self._validate_resource_response(etag, t) Printer.info("Checking if new plan is %s" % self.config['upgrade_plan']) self._check_node_value(t, './{0}Plan', self.config['upgrade_plan'])
def test_create_resource_fails_on_subscription_that_has_not_been_enabled( self): xml = xmlutil.xml_for_create_resource(promotion_code="SomeCode", intrinsic_settings="") result = requests.post( "http://0.0.0.0:5000/subscriptions/%s/cloudservices/%s/resources/%s/%s" % ("2", "mycloudservice", "cloudkeys", "foobar"), xml) assert result.status_code == 404
def do_create_resource(self): xml = xmlutil.xml_for_create_resource(promotion_code="SomeCode",intrinsic_settings="") result = requests.put("%s/subscriptions/%s/cloudservices/%s/resources/%s/%s" % ( self.test_config["connection_uri"], self.test_config["subscription_id"], self.test_config["cloud_service_name"], self.test_config["resource_type"], self.test_config["resource_name"]), xml) return result
def do_create_resource(self): xml = xmlutil.xml_for_create_resource(promotion_code="SomeCode", intrinsic_settings="") result = requests.put( "%s/subscriptions/%s/cloudservices/%s/resources/%s/%s" % (self.test_config["connection_uri"], self.test_config["subscription_id"], self.test_config["cloud_service_name"], self.test_config["resource_type"], self.test_config["resource_name"]), xml) return result
def create(self): etag = generate_etag() Printer.start_test("Create resource") (status, response) = self.client.perform_request( "subscriptions/%s/Events" % self.config["subscription_id"], "POST", xmlutil.xml_for_subscription_event( self.config["subscription_id"], self.config["resource_provider_namespace"], self.config["resource_type"], "Registered", ), ) # CHECK: Subscription Register event succeeds if status in [200, 201]: Printer.success("Subscription register event succeeded") else: Printer.error("Subscription register event failed with HTTP status code %s" % status) return # CHECK: Resource creation succeeds (status, response) = self.client.perform_request( "subscriptions/%s/cloudservices/%s/resources/%s/%s" % ( self.config["subscription_id"], self.config["cloud_service_name"], self.config["resource_type"], self.config["resource_name"], ), "PUT", xmlutil.xml_for_create_resource( plan=self.config["purchase_plan"], resource_type=self.config["resource_type"], promotion_code=self.config["promo_code"], etag=etag, ), ) if status in [200, 201]: Printer.success("Resource creation succeeded") Printer.info("Checking XML") else: Printer.error("Resource creation event failed with HTTP status code %s" % status) t = xmlutil.get_subtree_from_xml_string(response) self._validate_resource_response(etag, t)
def create(self): etag = generate_etag() Printer.start_test("Create resource") (status, response) = self.client.perform_request( "subscriptions/%s/Events" % self.config['subscription_id'], 'POST', xmlutil.xml_for_subscription_event( self.config["subscription_id"], self.config["resource_provider_namespace"], self.config["resource_type"], "Registered")) # CHECK: Subscription Register event succeeds if status in [200, 201]: Printer.success("Subscription register event succeeded") else: Printer.error( "Subscription register event failed with HTTP status code %s" % status) return # CHECK: Resource creation succeeds (status, response) = self.client.perform_request( "subscriptions/%s/cloudservices/%s/resources/%s/%s" % (self.config["subscription_id"], self.config["cloud_service_name"], self.config["resource_type"], self.config["resource_name"]), 'PUT', xmlutil.xml_for_create_resource( plan=self.config['purchase_plan'], resource_type=self.config['resource_type'], promotion_code=self.config['promo_code'], etag=etag)) if status in [200, 201]: Printer.success("Resource creation succeeded") Printer.info("Checking XML") else: Printer.error( "Resource creation event failed with HTTP status code %s" % status) t = xmlutil.get_subtree_from_xml_string(response) self._validate_resource_response(etag, t)
def test_create_resource_fails_on_subscription_that_has_not_been_enabled(self): xml = xmlutil.xml_for_create_resource(promotion_code="SomeCode",intrinsic_settings="") result = requests.post("http://0.0.0.0:5000/subscriptions/%s/cloudservices/%s/resources/%s/%s" % ("2", "mycloudservice", "cloudkeys", "foobar"), xml) assert result.status_code == 404