コード例 #1
0
	def do_register_subscription(self):
		xml = xmlutil.xml_for_subscription_event(self.test_config["subscription_id"], "Registered")
		result = requests.post("%s/subscriptions/%s/Events" % (
				self.test_config["connection_uri"],
				self.test_config["subscription_id"]),
			xml)
		return result
コード例 #2
0
 def do_register_subscription(self):
     xml = xmlutil.xml_for_subscription_event(
         self.test_config["subscription_id"], "Registered")
     result = requests.post(
         "%s/subscriptions/%s/Events" %
         (self.test_config["connection_uri"],
          self.test_config["subscription_id"]), xml)
     return result
コード例 #3
0
    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)
コード例 #4
0
    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)