コード例 #1
0
    def publish_module(self, api_auth):
        # Get path of the module for which metadata was added
        publish_url = fixture.url + self.path_for_module
        print("\n API end point used for publish request: " + publish_url)
        payload = {
            ":operation": "pant:publish",
            "locale": "en_US",
            "variant": self.variant
        }

        print("Payload: ", payload)
        time.sleep(10)
        publish_module_request = self.api_auth.post(
            publish_url, data=payload, headers={'Accept': 'application/json'})
        time.sleep(10)
        check_that("The publish request was successful",
                   publish_module_request.status_code, equal_to(200))

        # Check if the publish request response returns "url" for Customer Portal: CCS-3860
        cp_url_returned = publish_module_request.json()["location"]
        check_that("Publish module response contains The Customer Portal URL",
                   cp_url_returned,
                   contains_string(fixture.cp_url + "documentation"))

        response = api_auth.get(self.request_url)
        # Check that the node has been marked as released
        check_that("The published module now has a 'released' node",
                   response.json()["en_US"]["variants"][self.variant],
                   has_entry("released"))

        self.module_uuid = utilities.fetch_uuid(fixture.url,
                                                self.path_for_module,
                                                self.variant, api_auth)
        published_module_url = fixture.url + "api/module/variant.json/" + self.module_uuid
        print("published module url: \n" + published_module_url)
        lcc.log_info("Published Module api endpoint: %s" %
                     published_module_url)
        data_from_published_module = api_auth.get(published_module_url)
        check_that(
            "The /api/module/variant.json/<module_uuid> endpoint for a published module",
            data_from_published_module.status_code, equal_to(200))

        # print("Response from published module API endpoint: \n" + str(data_from_published_module.content))
        check_that("The response is ",
                   data_from_published_module.json()["message"],
                   equal_to("Module Found"))
        check_that("The title of the module ",
                   data_from_published_module.json()["module"]["title"],
                   contains_string(module_title_prefix))
        check_that("The status of the module ",
                   data_from_published_module.json()["module"]["status"],
                   equal_to("published"))
        check_that("The body of the module",
                   data_from_published_module.json()["module"]["body"],
                   is_not_none())
コード例 #2
0
    def verify_assembly_content(self, api_auth, setup_test_products):
        # Publishing module included in assembly
        self.variant = utilities.read_variant_name_from_pantheon2config()
        lcc.log_info(str(self.variant))
        self.variant = str(self.variant)
        self.path_for_module = utilities.select_nth_item_from_search_results(
            0, fixture.url, module_title_prefix + " Include", api_auth)
        if "/assemblies" in self.path_for_module:
            self.path_for_module = utilities.select_nth_item_from_search_results(
                2, fixture.url, module_title_prefix, api_auth)
        res, product_name_uri = utilities.add_metadata(fixture.url,
                                                       self.path_for_module,
                                                       self.variant,
                                                       api_auth,
                                                       setup_test_products,
                                                       content_type="module")
        utilities.publish_content(fixture.url, self.path_for_module,
                                  self.variant, api_auth)

        module_uuid = utilities.fetch_uuid(fixture.url, self.path_for_module,
                                           self.variant, api_auth)
        published_module_url = fixture.url + "api/module/variant.json/" + module_uuid
        published_module_relative_url = "api/module/variant.json/" + module_uuid
        print("published module url: \n" + published_module_url)
        lcc.log_info("Published Module api endpoint: %s" %
                     published_module_url)
        data_from_published_module = api_auth.get(published_module_url)
        print(data_from_published_module.json())

        self.path_for_assembly = utilities.select_nth_item_from_search_results(
            0, fixture.url, assembly_prefix, api_auth)
        if "/modules" in self.path_for_assembly:
            self.path_for_assembly = utilities.select_nth_item_from_search_results(
                1, fixture.url, assembly_prefix, api_auth)
        res, product_name_uri = utilities.add_metadata(fixture.url,
                                                       self.path_for_assembly,
                                                       self.variant,
                                                       api_auth,
                                                       setup_test_products,
                                                       content_type="assembly")
        # print(res.content)
        utilities.publish_content(fixture.url, self.path_for_assembly,
                                  self.variant, api_auth)

        assembly_uuid = utilities.fetch_uuid(fixture.url,
                                             self.path_for_assembly,
                                             self.variant, api_auth)
        published_assembly_url = fixture.url + "api/assembly/variant.json/" + assembly_uuid
        print("published assembly url: \n" + published_assembly_url)
        lcc.log_info("Published Assembly api endpoint: %s" %
                     published_assembly_url)
        data_from_published_assembly = api_auth.get(published_assembly_url)
        print(data_from_published_assembly.content)
        check_that(
            "The /api/assembly/variant.json/<assembly_uuid> endpoint for a published assembly",
            data_from_published_assembly.status_code, equal_to(200))

        # print("Response from published assembly API endpoint: \n" + str(data_from_published_assembly.content))
        check_that("The response is ",
                   data_from_published_assembly.json()["message"],
                   equal_to("Assembly Found"))
        check_that("The title of the assembly ",
                   data_from_published_assembly.json()["assembly"]["title"],
                   contains_string(assembly_prefix))
        check_that("The status of the assembly ",
                   data_from_published_assembly.json()["assembly"]["status"],
                   equal_to("published"))
        # check_that("The uuid of the assembly", data_from_published_assembly.json()["assembly"]["uuid"],
        #            equal_to(assembly_uuid))
        check_that("The uuid of the assembly",
                   data_from_published_assembly.json()["assembly"]["uuid"],
                   equal_to(assembly_uuid))
        check_that(
            "The abstract of the assembly",
            data_from_published_assembly.json()["assembly"]["description"],
            equal_to(constants.assembly_abstract))
        keywords = constants.assembly_searchkeywords.split(',')
        print(keywords)
        all_of(
            check_that(
                "Search keywords",
                data_from_published_assembly.json()["assembly"]
                ["search_keywords"], has_items(keywords)))
        check_that(
            "The assembly type",
            data_from_published_assembly.json()["assembly"]["content_type"],
            equal_to("assembly"))
        # date_published and #date_modified test pending
        path = self.path_for_assembly.split("repositories/")[1]
        path = path + "/en_US/variants/" + self.variant
        check_that(
            "The assembly url fragment",
            data_from_published_assembly.json()["assembly"]
            ["assembly_url_fragment"], equal_to(path))
        check_that(
            "The view_uri",
            data_from_published_assembly.json()["assembly"]["view_uri"],
            equal_to(fixture.cp_url + "documentation/en-us/" +
                     product_name_uri + "/" + constants.product_version_uri +
                     "/guide/" + assembly_uuid))
        check_that(
            "The revision_id",
            data_from_published_assembly.json()["assembly"]["revision_id"],
            equal_to("released"))
        # print(data_from_published_assembly.json()["assembly"]["products"][0]["product_name"])
        check_that(
            "The product name url",
            data_from_published_assembly.json()["assembly"]["products"][0]
            ["product_url_fragment"], equal_to(product_name_uri))
        check_that(
            "The product version",
            data_from_published_assembly.json()["assembly"]["products"][0]
            ["product_version"], equal_to(constants.product_version))
        lcc.log_info("Modules included from the API response: %s" %
                     str(data_from_published_assembly.json()["assembly"]
                         ["modules_included"]))
        number_of_modules_included = len(data_from_published_assembly.json()
                                         ["assembly"]["modules_included"])
        check_that("Number of Modules included", number_of_modules_included,
                   greater_than_or_equal_to(1))
        relative_url = []
        for i in range(number_of_modules_included):
            print(data_from_published_assembly.json()["assembly"]
                  ["modules_included"][i]["relative_url"])
            relative_url.append(data_from_published_assembly.json()["assembly"]
                                ["modules_included"][i]["relative_url"])
            check_that(
                "Modules included",
                data_from_published_assembly.json()["assembly"]
                ["modules_included"][i],
                all_of(has_entry("canonical_uuid"), has_entry("level_offset"),
                       has_entry("module_uuid"), has_entry("title"),
                       has_entry("url"), has_entry("pantheon_env"),
                       has_entry("relative_url")))
            check_that(
                "Modules included-> pantheon_env",
                data_from_published_assembly.json()["assembly"]
                ["modules_included"][i]["pantheon_env"], equal_to(env))
        print(*relative_url)
        check_that("Relative url to", relative_url,
                   has_item("/" + published_module_relative_url))
        lcc.log_info(
            "hasPart from the API response: %s" %
            str(data_from_published_assembly.json()["assembly"]["hasPart"]))
        number_of_modules_hasPart = len(
            data_from_published_assembly.json()["assembly"]["hasPart"])
        check_that("Number of Modules in hasPart", number_of_modules_hasPart,
                   greater_than_or_equal_to(1))
        relative_url1 = []
        for i in range(number_of_modules_hasPart):
            print(data_from_published_assembly.json()["assembly"]["hasPart"][i]
                  ["relative_url"])
            relative_url1.append(data_from_published_assembly.json()
                                 ["assembly"]["hasPart"][i]["relative_url"])
            check_that(
                "hasPart section ",
                data_from_published_assembly.json()["assembly"]["hasPart"][i],
                all_of(has_entry("canonical_uuid"), has_entry("level_offset"),
                       has_entry("module_uuid"), has_entry("title"),
                       has_entry("url"), has_entry("pantheon_env"),
                       has_entry("relative_url")))
            any_of(
                check_that(
                    "hasPart-> pantheon_env",
                    data_from_published_assembly.json()["assembly"]["hasPart"]
                    [i]["pantheon_env"], equal_to(env)))
        print(*relative_url1)
        check_that("Relative url to", relative_url1,
                   has_item("/" + published_module_relative_url))
コード例 #3
0
    def verify_assembly_content_ext_proxy(self, api_auth):
        assembly_uuid = utilities.fetch_uuid(fixture.url,
                                             self.path_for_assembly,
                                             self.variant, api_auth)
        published_assembly_url = fixture.external_proxy_url + "assembly/variant.json/" + assembly_uuid
        print("published assembly url: \n" + published_assembly_url)
        lcc.log_info("Published Assembly api endpoint: %s" %
                     published_assembly_url)
        data_from_published_assembly = api_auth.get(published_assembly_url,
                                                    proxies=proxies)
        print(data_from_published_assembly.content)
        check_that(
            "The /api/assembly/variant.json/<assembly_uuid> endpoint for a published assembly",
            data_from_published_assembly.status_code, equal_to(200))

        # print("Response from published assembly API endpoint: \n" + str(data_from_published_assembly.content))
        check_that("The response is ",
                   data_from_published_assembly.json()["message"],
                   equal_to("Assembly Found"))
        check_that("The title of the assembly ",
                   data_from_published_assembly.json()["assembly"]["title"],
                   contains_string(assembly_prefix))
        check_that("The status of the assembly ",
                   data_from_published_assembly.json()["assembly"]["status"],
                   equal_to("published"))
        # check_that("The uuid of the assembly", data_from_published_assembly.json()["assembly"]["uuid"],
        #            equal_to(assembly_uuid))
        check_that("The uuid of the assembly",
                   data_from_published_assembly.json()["assembly"]["uuid"],
                   equal_to(assembly_uuid))
        check_that(
            "The abstract of the assembly",
            data_from_published_assembly.json()["assembly"]["description"],
            equal_to(constants.assembly_abstract))
        keywords = constants.assembly_searchkeywords.split(',')
        print(keywords)
        all_of(
            check_that(
                "Search keywords",
                data_from_published_assembly.json()["assembly"]
                ["search_keywords"], has_items(keywords)))
        check_that(
            "The assembly type",
            data_from_published_assembly.json()["assembly"]["content_type"],
            equal_to("assembly"))
        # date_published and #date_modified test pending
        path = self.path_for_assembly.split("repositories/")[1]
        path = path + "/en_US/variants/" + self.variant
        check_that(
            "The assembly url fragment",
            data_from_published_assembly.json()["assembly"]
            ["assembly_url_fragment"], equal_to(path))
        check_that(
            "The revision_id",
            data_from_published_assembly.json()["assembly"]["revision_id"],
            equal_to("released"))
        check_that(
            "The product version",
            data_from_published_assembly.json()["assembly"]["products"][0]
            ["product_version"], equal_to(constants.product_version))
        lcc.log_info("Modules included from the API response: %s" %
                     str(data_from_published_assembly.json()["assembly"]
                         ["modules_included"]))
        number_of_modules_included = len(data_from_published_assembly.json()
                                         ["assembly"]["modules_included"])
        check_that("Number of Modules included", number_of_modules_included,
                   greater_than_or_equal_to(1))
        relative_url = []
        for i in range(number_of_modules_included):
            print(data_from_published_assembly.json()["assembly"]
                  ["modules_included"][i]["relative_url"])
            relative_url.append(data_from_published_assembly.json()["assembly"]
                                ["modules_included"][i]["relative_url"])
            check_that(
                "Modules included",
                data_from_published_assembly.json()["assembly"]
                ["modules_included"][i],
                all_of(has_entry("canonical_uuid"), has_entry("level_offset"),
                       has_entry("module_uuid"), has_entry("title"),
                       has_entry("url"), has_entry("pantheon_env"),
                       has_entry("relative_url")))
            check_that(
                "Modules included-> pantheon_env",
                data_from_published_assembly.json()["assembly"]
                ["modules_included"][i]["pantheon_env"], equal_to(env))
        lcc.log_info(
            "hasPart from the API response: %s" %
            str(data_from_published_assembly.json()["assembly"]["hasPart"]))
        number_of_modules_hasPart = len(
            data_from_published_assembly.json()["assembly"]["hasPart"])
        check_that("Number of Modules in hasPart", number_of_modules_hasPart,
                   greater_than_or_equal_to(1))
        relative_url1 = []
        for i in range(number_of_modules_hasPart):
            print(data_from_published_assembly.json()["assembly"]["hasPart"][i]
                  ["relative_url"])
            relative_url1.append(data_from_published_assembly.json()
                                 ["assembly"]["hasPart"][i]["relative_url"])
            check_that(
                "hasPart section ",
                data_from_published_assembly.json()["assembly"]["hasPart"][i],
                all_of(has_entry("canonical_uuid"), has_entry("level_offset"),
                       has_entry("module_uuid"), has_entry("title"),
                       has_entry("url"), has_entry("pantheon_env"),
                       has_entry("relative_url")))
            any_of(
                check_that(
                    "hasPart-> pantheon_env",
                    data_from_published_assembly.json()["assembly"]["hasPart"]
                    [i]["pantheon_env"], equal_to(env)))
コード例 #4
0
    def verify_module_content(self, api_auth, setup_test_products):
        #publishing related assembly
        self.variant = utilities.read_variant_name_from_pantheon2config()
        lcc.log_info(str(self.variant))
        self.variant = str(self.variant)
        lcc.log_info(
            "In order to verify content for a module, publishing a related assembly..."
        )
        self.path_for_assembly = utilities.select_nth_item_from_search_results(
            0, fixture.url, assembly_title_prefix, api_auth)

        if "/modules" in self.path_for_assembly:
            self.path_for_assembly = utilities.select_nth_item_from_search_results(
                1, fixture.url, assembly_title_prefix, api_auth)

        res, product_name_uri = utilities.add_metadata(fixture.url,
                                                       self.path_for_assembly,
                                                       self.variant,
                                                       api_auth,
                                                       setup_test_products,
                                                       content_type="assembly")
        check_that("Edit metadata request response for the above assembly",
                   res.status_code, equal_to(200))
        lcc.log_info("Edit metadata response content: %s" % str(res.content))

        publish_req_assembly = utilities.publish_content(
            fixture.url, self.path_for_assembly, self.variant, api_auth)
        check_that("Expect the above assembly to be published, response code ",
                   publish_req_assembly.status_code, equal_to(200))
        lcc.log_info("Publish assembly response content: %s" %
                     str(publish_req_assembly.content))

        assembly_uuid = utilities.fetch_uuid(fixture.url,
                                             self.path_for_assembly,
                                             self.variant, api_auth)
        published_assembly_url = fixture.url + "api/assembly/variant.json/" + assembly_uuid
        published_assembly_relative_url = "api/assembly/variant.json/" + assembly_uuid
        print("published assembly url: \n" + published_assembly_url)
        lcc.log_info("Published Assembly api endpoint: %s" %
                     published_assembly_url)
        data_from_published_assembly = api_auth.get(published_assembly_url)

        self.path_for_module = utilities.select_nth_item_from_search_results(
            0, fixture.url, module_prefix, api_auth)
        if "/assemblies" in self.path_for_module:
            self.path_for_module = utilities.select_nth_item_from_search_results(
                1, fixture.url, module_prefix, api_auth)
        res, product_name_uri = utilities.add_metadata(fixture.url,
                                                       self.path_for_module,
                                                       self.variant,
                                                       api_auth,
                                                       setup_test_products,
                                                       content_type="module")
        lcc.log_info(
            "Publishing a module now to test for included content: %s" %
            self.path_for_module)

        publish_req_module = utilities.publish_content(fixture.url,
                                                       self.path_for_module,
                                                       self.variant, api_auth)

        check_that("Module has been published ",
                   publish_req_module.status_code, equal_to(200))
        module_uuid = utilities.fetch_uuid(fixture.url, self.path_for_module,
                                           self.variant, api_auth)
        published_module_url = fixture.url + "api/module/variant.json/" + module_uuid
        # print("published module url: \n" + published_module_url)
        lcc.log_info("Published Module api endpoint: %s" %
                     published_module_url)
        data_from_published_module = api_auth.get(published_module_url)
        check_that(
            "The /api/module/variant.json/<module_uuid> endpoint for a published module",
            data_from_published_module.status_code, equal_to(200))

        # print("Response from published module API endpoint: \n" + str(data_from_published_module.content))
        check_that("The response is ",
                   data_from_published_module.json()["message"],
                   equal_to("Module Found"))
        check_that("The title of the module ",
                   data_from_published_module.json()["module"]["title"],
                   contains_string(module_prefix))
        check_that("The status of the module ",
                   data_from_published_module.json()["module"]["status"],
                   equal_to("published"))
        check_that("The variant uuid of the module",
                   data_from_published_module.json()["module"]["variant_uuid"],
                   equal_to(module_uuid))
        check_that("The uuid of the module",
                   data_from_published_module.json()["module"]["uuid"],
                   equal_to(module_uuid))
        check_that("The abstract of the module",
                   data_from_published_module.json()["module"]["description"],
                   is_not_none())
        keywords = constants.searchKeywords.split(',')
        print(keywords)
        check_that(
            "Search keywords",
            data_from_published_module.json()["module"]["search_keywords"],
            has_items(keywords))
        check_that("The module type",
                   data_from_published_module.json()["module"]["content_type"],
                   equal_to("module"))
        #date_published and #date_modified test pending
        path = self.path_for_module.split("repositories/")[1]
        path = path + "/en_US/variants/" + self.variant
        check_that(
            "The module url fragment",
            data_from_published_module.json()["module"]["module_url_fragment"],
            equal_to(path))
        check_that(
            "The view_uri",
            data_from_published_module.json()["module"]["view_uri"],
            equal_to(fixture.cp_url + "documentation/en-us/" +
                     product_name_uri + "/" + constants.product_version_uri +
                     "/topic/" + module_uuid))

        check_that("The revision_id",
                   data_from_published_module.json()["module"]["revision_id"],
                   equal_to("released"))
        # print(data_from_published_module.json()["module"]["products"][0]["product_name"])
        check_that(
            "The product name url",
            data_from_published_module.json()["module"]["products"][0]
            ["product_url_fragment"], equal_to(product_name_uri))
        check_that(
            "The product version",
            data_from_published_module.json()["module"]["products"][0]
            ["product_version"], equal_to(constants.product_version))
        lcc.log_info("Included in guides from the API response: %s" % str(
            data_from_published_module.json()["module"]["included_in_guides"]))
        count = len(
            data_from_published_module.json()["module"]["included_in_guides"])
        check_that("Number of guides included in", count,
                   greater_than_or_equal_to(1))
        relative_url = []
        for i in range(count):
            print(data_from_published_module.json()["module"]
                  ["included_in_guides"][i]["relative_url"])
            relative_url.append(data_from_published_module.json()["module"]
                                ["included_in_guides"][i]["relative_url"])
            check_that(
                "Included in guides",
                data_from_published_module.json()["module"]
                ["included_in_guides"][i]["title"],
                contains_string(assembly_title_prefix)
                or contains_string(assembly_prefix))
            check_that(
                "Included in guides data",
                data_from_published_module.json()["module"]
                ["included_in_guides"][i],
                all_of(has_entry("title"), has_entry("uuid"), has_entry("url"),
                       has_entry("view_uri"), has_entry("relative_url"),
                       has_entry("pantheon_env")))
            check_that(
                "Included in guides-> pantheon_env",
                data_from_published_module.json()["module"]
                ["included_in_guides"][i]["pantheon_env"], equal_to(env))
        print(*relative_url)
        check_that("Relative url to", relative_url,
                   has_item("/" + published_assembly_relative_url))
        is_part_of_content = data_from_published_module.json(
        )["module"]["isPartOf"]
        lcc.log_info("Is part of content from the API response: %s " %
                     str(is_part_of_content))
        is_part_of_count = len(
            data_from_published_module.json()["module"]["isPartOf"])
        check_that("Is part of count", is_part_of_count,
                   greater_than_or_equal_to(1))
        relative_url1 = []
        for i in range(is_part_of_count):
            print(data_from_published_module.json()["module"]["isPartOf"][i]
                  ["relative_url"])
            relative_url1.append(data_from_published_module.json()["module"]
                                 ["isPartOf"][i]["relative_url"])
            check_that(
                "Is part of",
                data_from_published_module.json()["module"]["isPartOf"][i]
                ["title"],
                contains_string(assembly_title_prefix)
                or contains_string(assembly_prefix))
            check_that(
                "isPartOf data",
                data_from_published_module.json()["module"]["isPartOf"][i],
                all_of(has_entry("title"), has_entry("uuid"), has_entry("url"),
                       has_entry("view_uri"), has_entry("relative_url"),
                       has_entry("pantheon_env")))
            check_that(
                "isPartOf-> pantheon_env",
                data_from_published_module.json()["module"]["isPartOf"][i]
                ["pantheon_env"], equal_to(env))
        print(*relative_url1)
        check_that("Relative url to", relative_url1,
                   has_item("/" + published_assembly_relative_url))

        time.sleep(10)
        # Test to verify external proxy url, pantheon URL and CP url resolve image assets correctly
        proxies = {
            "http": proxy_server,
            "https": proxy_server,
        }
        body = data_from_published_module.json()["module"]["body"]
        src = collect(body, {"Path": ["img", "src", []]})
        path = (src["Path"]).lstrip("/")
        print(cp_url + path)
        resp1 = requests.get(cp_url + path, proxies=proxies)
        print(cp_pantheon_url + path)
        resp2 = requests.get(cp_pantheon_url + path, proxies=proxies)
        print(proxy_url + path)
        resp3 = requests.get(proxy_url + path, proxies=proxies)

        check_that("Imageassets for url behind akamai", resp1.status_code,
                   equal_to(200))
        check_that("Imageassets for Pantheon url", resp2.status_code,
                   equal_to(200))
        check_that("Imageassets for external proxy url", resp3.status_code,
                   equal_to(200))
コード例 #5
0
    def verify_module_content_ext_proxy(self, api_auth, setup_test_products):
        module_uuid = utilities.fetch_uuid(fixture.url, self.path_for_module,
                                           self.variant, api_auth)
        published_module_url = fixture.external_proxy_url + "module/variant.json/" + module_uuid
        # print("published module url: \n" + published_module_url)
        lcc.log_info("Published Module api endpoint: %s" %
                     published_module_url)
        data_from_published_module = api_auth.get(published_module_url,
                                                  proxies=proxies)
        check_that(
            "The /api/module/variant.json/<module_uuid> endpoint for a published module",
            data_from_published_module.status_code, equal_to(200))

        lcc.log_info("Response from published module API endpoint: \n" +
                     str(data_from_published_module.content))
        check_that("The response is ",
                   data_from_published_module.json()["message"],
                   equal_to("Module Found"))
        check_that("The title of the module ",
                   data_from_published_module.json()["module"]["title"],
                   contains_string(module_prefix))
        check_that("The status of the module ",
                   data_from_published_module.json()["module"]["status"],
                   equal_to("published"))
        check_that("The variant uuid of the module",
                   data_from_published_module.json()["module"]["variant_uuid"],
                   equal_to(module_uuid))
        check_that("The uuid of the module",
                   data_from_published_module.json()["module"]["uuid"],
                   equal_to(module_uuid))
        check_that("The abstract of the module",
                   data_from_published_module.json()["module"]["description"],
                   is_not_none())
        keywords = constants.searchKeywords.split(',')
        print(keywords)
        check_that(
            "Search keywords",
            data_from_published_module.json()["module"]["search_keywords"],
            has_items(keywords))
        check_that("The module type",
                   data_from_published_module.json()["module"]["content_type"],
                   equal_to("module"))
        # date_published and #date_modified test pending
        path = self.path_for_module.split("repositories/")[1]
        path = path + "/en_US/variants/" + self.variant
        check_that(
            "The module url fragment",
            data_from_published_module.json()["module"]["module_url_fragment"],
            equal_to(path))
        check_that("The revision_id",
                   data_from_published_module.json()["module"]["revision_id"],
                   equal_to("released"))
        check_that(
            "The product version",
            data_from_published_module.json()["module"]["products"][0]
            ["product_version"], equal_to(constants.product_version))
        lcc.log_info("Included in guides from the API response: %s" % str(
            data_from_published_module.json()["module"]["included_in_guides"]))
        count = len(
            data_from_published_module.json()["module"]["included_in_guides"])
        check_that("Number of guides included in", count,
                   greater_than_or_equal_to(1))
        relative_url = []
        for i in range(count):
            print(data_from_published_module.json()["module"]
                  ["included_in_guides"][i]["relative_url"])
            relative_url.append(data_from_published_module.json()["module"]
                                ["included_in_guides"][i]["relative_url"])
            check_that(
                "Included in guides",
                data_from_published_module.json()["module"]
                ["included_in_guides"][i]["title"],
                contains_string(assembly_title_prefix)
                or contains_string(assembly_prefix))
            check_that(
                "Included in guides data",
                data_from_published_module.json()["module"]
                ["included_in_guides"][i],
                all_of(has_entry("title"), has_entry("uuid"), has_entry("url"),
                       has_entry("view_uri"), has_entry("relative_url"),
                       has_entry("pantheon_env")))
            check_that(
                "Included in guides-> pantheon_env",
                data_from_published_module.json()["module"]
                ["included_in_guides"][i]["pantheon_env"], equal_to(env))
        is_part_of_content = data_from_published_module.json(
        )["module"]["isPartOf"]
        lcc.log_info("Is part of content from the API response: %s " %
                     str(is_part_of_content))
        is_part_of_count = len(
            data_from_published_module.json()["module"]["isPartOf"])
        check_that("Is part of count", is_part_of_count,
                   greater_than_or_equal_to(1))
        relative_url1 = []
        for i in range(is_part_of_count):
            print(data_from_published_module.json()["module"]["isPartOf"][i]
                  ["relative_url"])
            relative_url1.append(data_from_published_module.json()["module"]
                                 ["isPartOf"][i]["relative_url"])
            check_that(
                "Is part of",
                data_from_published_module.json()["module"]["isPartOf"][i]
                ["title"],
                contains_string(assembly_title_prefix)
                or contains_string(assembly_prefix))
            check_that(
                "isPartOf data",
                data_from_published_module.json()["module"]["isPartOf"][i],
                all_of(has_entry("title"), has_entry("uuid"), has_entry("url"),
                       has_entry("view_uri"), has_entry("relative_url"),
                       has_entry("pantheon_env")))
            check_that(
                "isPartOf-> pantheon_env",
                data_from_published_module.json()["module"]["isPartOf"][i]
                ["pantheon_env"], equal_to(env))
コード例 #6
0
    def verify_publish_assembly(self, api_auth):
        # print("variant: " + self.variant)
        payload = {
            ":operation": "pant:publish",
            "locale": "en_US",
            "variant": self.variant
        }
        # headers = {'content-type': "application/x-www-form-urlencoded"}
        # payload = json.dumps(payload)
        # payload = urlencode(payload)
        print("Payload: ", payload)
        publish_url = fixture.url + self.path_for_assembly
        lcc.log_info("API end point used for publish request: %s" %
                     publish_url)
        time.sleep(15)
        publish_request = api_auth.post(publish_url,
                                        data=payload,
                                        headers={'Accept': 'application/json'})
        lcc.log_info("Publish request response: \n %s" %
                     str(publish_request.content))
        time.sleep(10)
        check_that("The publish request is successful",
                   publish_request.status_code, equal_to(200))

        # Check if the publish request response returns "url" for Customer Portal: CCS-3860
        cp_url_returned = publish_request.json()["location"]
        check_that(
            "Publish assembly response contains The Customer Portal URL",
            cp_url_returned, contains_string(fixture.cp_url + "documentation"))

        req = api_auth.get(fixture.url + self.path_for_assembly + ".7.json")

        check_that("The status node in variants > variant >: ",
                   req.json()["en_US"]["variants"][self.variant],
                   has_entry("released"),
                   quiet=True)

        self.assembly_uuid = utilities.fetch_uuid(fixture.url,
                                                  self.path_for_assembly,
                                                  self.variant, api_auth)

        published_assembly_url = fixture.url + "api/assembly/variant.json/" + self.assembly_uuid
        print("published assembly url: \n" + published_assembly_url)
        lcc.log_info("Published Assembly api endpoint: %s" %
                     published_assembly_url)
        published_assembly_request = api_auth.get(published_assembly_url)
        check_that(
            "The /api/assembly/variant.json/<assembly_uuid> endpoint for a published assembly",
            published_assembly_request.status_code, equal_to(200))

        # print("Response from published assembly API endpoint: \n" + str(published_assembly_request.content))
        check_that("The response is ",
                   published_assembly_request.json()["message"],
                   equal_to("Assembly Found"))
        check_that("The title of the assembly ",
                   published_assembly_request.json()["assembly"]["title"],
                   contains_string(assembly_title_prefix))
        check_that("The status of the assembly ",
                   published_assembly_request.json()["assembly"]["status"],
                   equal_to("published"))
        check_that(
            "The content type of the assembly",
            published_assembly_request.json()["assembly"]["content_type"],
            equal_to("assembly"))
        check_that("The body of the assembly",
                   published_assembly_request.json()["assembly"]["body"],
                   is_not_none())