class test_help_documentation():
    driver = lcc.inject_fixture("driver_obj")

    @lcc.test("Verify that help documentation is displayed")
    def help_doc(self):
        try:
            utilities.wait(2)
            utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_SEARCH_PAGE_LINK_TEXT)
            utilities.page_reload(self.driver)
            utilities.wait(1)
            utilities.click_element(self.driver, By.CSS_SELECTOR, locators.HELP_ICON_CLASS_NAME)
            utilities.click_element(self.driver, By.LINK_TEXT, locators.USER_GUIDE_LINK_TEXT)
            utilities.wait(2)
            utilities.switch_to_latest_tab(self.driver)
            lcc.log_info(self.driver.current_url)
            check_that("page url", self.driver.current_url, contains_string(constants.help_user_guide_url))
            title_of_user_guide = utilities.find_shadow_dom_element(self.driver,
                                                                    locators.TITLE_OF_USER_GUIDE_CSS,
                                                                    locators.USER_GUIDE_PARENT_CSS).text
            check_that("title of the page", title_of_user_guide, contains_string("Help"))
        except (TimeoutException, NoSuchElementException) as e:
            lcc.log_error(e)
        finally:
            self.driver.close()
            utilities.switch_to_first_tab(self.driver)
Ejemplo n.º 2
0
class test_login(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    @lcc.test(
        "Verify that user is able to login successfully and the username is displayed on top right"
    )
    def verify_login_success(self):
        # 'driver' param is the webdriver object that is being called from 'setup' fixture and used through the scope
        # of the session.
        username = base.config_reader('login', 'username')
        logged_in_user = login_page.get_logged_in_username(self.driver)
        lcc.log_info("Logged in username: %s" % logged_in_user)
        assert_that("Logged in username is visible",
                    logged_in_user,
                    contains_string(username),
                    quiet=False)
Ejemplo n.º 3
0
class test_search:
    api_auth = lcc.inject_fixture("api_auth")

    @lcc.test(
        "Verify that the recently uploaded modules are present in search results: %s"
        % module_title_prefix)
    def search(self, api_auth):
        lcc.log_info("Making a search request for prefix: API test module")
        search_endpoint = fixture.url + "pantheon/internal/modules.json?search=" + module_title_prefix
        lcc.log_info(str(search_endpoint))
        search_request = api_auth.get(search_endpoint)
        search_results = search_request.json()
        number_of_results = search_results["size"]
        lcc.log_info(str(search_request.json()))
        check_that("The search request should be successful",
                   search_request.status_code, equal_to(200))
        check_that(
            "Number of search results should be >= %s as per the test data; " %
            number_of_modules, int(number_of_results),
            greater_than_or_equal_to(int(number_of_results)))
Ejemplo n.º 4
0
class test_product:

    api_auth = lcc.inject_fixture("api_auth")
    path_to_product = fixture.url + "content/products/" + product_name_uri

    @lcc.test(
        "Verify if the product is created successfully and check for: uuid, name, sling:resourceType,"
        " jcr:primaryType")
    def verify_product_info(self, api_auth):
        lcc.log_info("Test Product node being created at: %s" %
                     self.path_to_product)
        create_product_payload = {
            "name": product_name,
            "description": "Test product Setup description",
            "sling:resourceType": "pantheon/product",
            "jcr:primaryType": "pant:product",
            "locale": "en-US",
            "urlFragment": product_name_uri
        }

        # Hit the api for create product
        response = self.api_auth.post(self.path_to_product,
                                      data=create_product_payload)
        check_that("The Product is created successfully", response.status_code,
                   any_of(equal_to(201), equal_to(200)))

        # Hit the api to get id of created product
        get_product_id_endpoint = self.path_to_product + ".json"
        product_id_request = api_auth.get(get_product_id_endpoint)
        check_that("%s API status code" % get_product_id_endpoint,
                   product_id_request.status_code, equal_to(200))
        product_id = product_id_request.json()
        lcc.log_info("Response for product creation: %s" % str(product_id))
        check_that("Product uuid", product_id["jcr:uuid"], is_not_none())
        check_that("sling:resourceType", product_id["sling:resourceType"],
                   equal_to("pantheon/product"))
        check_that("jcr:primaryType", product_id["jcr:primaryType"],
                   equal_to("pant:product"))
        check_that("product name", product_id["name"], equal_to(product_name))

    @lcc.test(
        "Verify  that product version is created successfully and check for: uuid, name, sling:resourceType,"
        " jcr:primaryType")
    def verify_product_version_info(self, api_auth):
        path_to_version = self.path_to_product + "/versions/{}".format(
            constants.product_version)
        lcc.log_info(
            "Product version being created for the above product: %s" %
            path_to_version)

        create_version_payload = {
            "name": constants.product_version,
            "sling:resourceType": "pantheon/productVersion",
            "jcr:primaryType": "pant:productVersion",
            "urlFragment": constants.product_version_uri
        }

        # Hit the api for create version for the above product
        response = self.api_auth.post(path_to_version,
                                      data=create_version_payload)
        check_that("The Product version is created successfully",
                   response.status_code, any_of(equal_to(201), equal_to(200)))

        # Hit the api to get id of product version
        path_to_product_id = self.path_to_product + "/versions/" + constants.product_version + ".json"
        product_version_id_req = api_auth.get(path_to_product_id)
        check_that("%s API status code" % path_to_product_id,
                   product_version_id_req.status_code, equal_to(200))
        product_version_id = product_version_id_req.json()
        check_that("Product version uuid", product_version_id["jcr:uuid"],
                   is_not_none())
        check_that("sling:resourceType",
                   product_version_id["sling:resourceType"],
                   equal_to("pantheon/productVersion"))
        check_that("jcr:primaryType", product_version_id["jcr:primaryType"],
                   equal_to("pant:productVersion"))
        check_that("product version", product_version_id["name"],
                   equal_to(constants.product_version))

    def teardown_suite(self):
        lcc.log_info(
            "Deleting test products created as a part of the tests.. ")
        path_to_new_product_node = fixture.url + "bin/cpm/nodes/node.json/content/products/" + product_name_uri
        lcc.log_info("Test Product node being deleted at: %s" %
                     path_to_new_product_node)
        response1 = requests.delete(path_to_new_product_node,
                                    auth=(fixture.admin_username,
                                          fixture.admin_auth))
        check_that("Test product version created was deleted successfully",
                   response1.status_code, equal_to(200))
class test_bulk_operations(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    @lcc.test('Verify user can bulk add metadata for modules')
    # @lcc.disabled()
    def modules_bulk_edit_metadata(self):
        utilities.click_element(self.driver, By.LINK_TEXT,
                                locators.MENU_SEARCH_PAGE_LINK_TEXT)
        utilities.page_reload(self.driver)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_titles(self.driver,
                                       constants.bulk_operations_modules)
        poll(lambda: len(
            utilities.find_elements_by_css_selector(self.driver, locators.
                                                    MODULES_LIST_CSS)) == 4,
             ignore_exceptions=[NoSuchElementException],
             timeout=5,
             step=0.5)
        utilities.click_element(self.driver, By.XPATH,
                                locators.MODULES_SELECT_ALL_TITLE_XPATH)
        bulk_edit_metadata = utilities.find_element(
            self.driver, By.XPATH, locators.BULK_EDIT_METADATA_XPATH)
        bulk_publish = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                              locators.BULK_PUBLISH_CSS)
        bulk_unpublish = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                                locators.BULK_UNPUBLISH_CSS)
        check_that("Edit metadata button is enabled after selecting modules",
                   bulk_edit_metadata.get_attribute("aria-disabled"),
                   equal_to("false"))
        check_that("Publish button is enabled after selecting modules",
                   bulk_publish.get_attribute("aria-disabled"),
                   equal_to("false"))
        check_that("Unpublish button is enabled after selecting modules",
                   bulk_unpublish.get_attribute("aria-disabled"),
                   equal_to("false"))
        bulk_edit_metadata.click()
        check_that(
            "Edit metadata modal title",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.EDIT_METADATA_MODAL_TITLE),
            equal_to("Edit Metadata"))
        check_that(
            "Count of selected titles",
            utilities.get_text(self.driver, By.ID,
                               locators.SELECTED_MODULES_COUNT_ID),
            contains_string("4"))
        search_beta_page.add_bulk_metadata(self.driver)
        poll(lambda: utilities.get_text(self.driver, By.CSS_SELECTOR, locators.
                                        PROGRESS_SUCCESS_STATUS) == "100%",
             ignore_exceptions=[NoSuchElementException],
             timeout=20,
             step=1)
        utilities.wait(3)
        utilities.click_element(self.driver, By.XPATH,
                                locators.VIEW_DETAILS_LINK)
        utilities.wait(3)
        modules_updated = utilities.find_elements_by_css_selector(
            self.driver, locators.UPDATED_TITLES_LIST_CSS)
        check_that("Count of successfully updated modules",
                   len(modules_updated), equal_to(4))
        check_that(
            "Skipped modules section text",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.SKIPPED_TITLE_LIST_CSS),
            equal_to("n/a"))
        check_that(
            "Failed modules section text",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.FAILED_TITLES_LIST_CSS),
            equal_to("n/a"))
        utilities.click_element(self.driver, By.XPATH,
                                locators.CLOSE_DETAILS_XPATH)
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.CLOSE_STATUS_ALERT)

    @lcc.test('Verify user can bulk publish modules')
    # @lcc.disabled()
    def modules_bulk_publish(self):
        poll(lambda: len(
            utilities.find_elements_by_css_selector(self.driver, locators.
                                                    MODULES_LIST_CSS)) == 4,
             ignore_exceptions=[NoSuchElementException],
             timeout=5,
             step=0.5)
        utilities.click_element(self.driver, By.XPATH,
                                locators.MODULES_SELECT_ALL_TITLE_XPATH)
        bulk_publish = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                              locators.BULK_PUBLISH_CSS)
        bulk_publish.click()
        check_that(
            "Confirmation modal title",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODAL_TITLE_CSS), equal_to("Publish"))
        check_that(
            "Count of modules being published",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.TITLES_FOR_PUBLISH_CSS),
            contains_string("4"))
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.CONFIRM_BUTTON_CSS)
        poll(lambda: utilities.get_text(self.driver, By.CSS_SELECTOR, locators.
                                        PROGRESS_SUCCESS_STATUS) == "100%",
             ignore_exceptions=[NoSuchElementException],
             timeout=20,
             step=1)
        utilities.click_element(self.driver, By.XPATH,
                                locators.VIEW_DETAILS_LINK)
        modules_updated = utilities.find_elements_by_css_selector(
            self.driver, locators.UPDATED_TITLES_LIST_CSS)
        check_that("Count of successfully updated modules",
                   len(modules_updated), equal_to(4))
        check_that(
            "Skipped modules section text",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.SKIPPED_TITLE_LIST_CSS),
            equal_to("n/a"))
        check_that(
            "Failed modules section text",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.FAILED_TITLES_LIST_CSS),
            equal_to("n/a"))
        utilities.click_element(self.driver, By.XPATH,
                                locators.CLOSE_DETAILS_XPATH)
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.CLOSE_STATUS_ALERT)

    @lcc.test('Verify user can bulk unpublish modules')
    # @lcc.disabled()
    def modules_bulk_unpublish(self):
        poll(lambda: len(
            utilities.find_elements_by_css_selector(self.driver, locators.
                                                    MODULES_LIST_CSS)) == 4,
             ignore_exceptions=[NoSuchElementException],
             timeout=5,
             step=0.5)
        utilities.wait(3)
        utilities.click_element(self.driver, By.XPATH,
                                locators.MODULES_SELECT_ALL_TITLE_XPATH)
        utilities.wait(3)
        # Deselect first title
        utilities.click_element(self.driver, By.XPATH,
                                locators.FIRST_MODULE_CHECKBOX_XPATH)
        utilities.wait(2)
        bulk_unpublish = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                                locators.BULK_UNPUBLISH_CSS)
        bulk_unpublish.click()
        check_that(
            "Confirmation modal title",
            utilities.get_text(self.driver,
                               By.CSS_SELECTOR, locators.MODAL_TITLE_CSS),
            equal_to("Unpublish"))
        check_that(
            "Count of modules being unpublished",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.TITLES_FOR_UNPUBLISH_CSS),
            contains_string("3"))
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.CONFIRM_BUTTON_CSS)
        poll(lambda: utilities.get_text(self.driver, By.CSS_SELECTOR, locators.
                                        PROGRESS_SUCCESS_STATUS) == "100%",
             ignore_exceptions=[NoSuchElementException],
             timeout=20,
             step=1)
        utilities.click_element(self.driver, By.XPATH,
                                locators.VIEW_DETAILS_LINK)
        modules_updated = utilities.find_elements_by_css_selector(
            self.driver, locators.UPDATED_TITLES_LIST_CSS)
        check_that("Count of successfully updated modules",
                   len(modules_updated), equal_to(3))
        check_that(
            "Failed modules section text",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.FAILED_TITLES_LIST_CSS),
            equal_to("n/a"))
        utilities.click_element(self.driver, By.XPATH,
                                locators.CLOSE_DETAILS_XPATH)
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.CLOSE_STATUS_ALERT)

    @lcc.test('Verify cannot edit metadata for published document')
    # @lcc.disabled()
    def published_title_add_metadata(self):
        utilities.click_element(self.driver, By.XPATH,
                                locators.FIRST_MODULE_CHECKBOX_XPATH)
        utilities.wait(2)
        bulk_edit_metadata = utilities.find_element(
            self.driver, By.XPATH, locators.BULK_EDIT_METADATA_XPATH)
        bulk_edit_metadata.click()
        utilities.wait(2)
        search_beta_page.add_bulk_metadata(self.driver)
        utilities.wait(2)
        check_that(
            "Alert message displayed when trying to add metadata to published title",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.ALERT_TITLE_CSS),
            equal_to(constants.error_message_on_edit_metadata))
        utilities.click_element(self.driver, By.XPATH,
                                locators.CLOSE_DETAILS_XPATH)
        utilities.wait(15)
        lcc.log_info("End of tests, executing teardown")
class test_assembly_content:
    api_auth = lcc.inject_fixture("api_auth")

    path_for_assembly = ""
    request_url = ""

    @lcc.test("Verify response of assembly variant api for pantheon endpoints")
    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))

    @lcc.test("Verify response of assembly variant api behind akamai")
    def verify_assembly_content_behind_akamai(self, 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,
                                                    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)))

    @lcc.test("Verify response of assembly variant api for external proxy API")
    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)))
Ejemplo n.º 7
0
    class MySuite:
        fixt1 = lcc.inject_fixture()

        @lcc.test("sometest")
        def sometest(self):
            marker.append(self.fixt1)
class test_module_content:
    api_auth = lcc.inject_fixture("api_auth")

    path_for_module = ""
    request_url = ""

    @lcc.test(
        "Verify response of module variant api also verify external proxy url, pantheon URL and CP url resolve imageassets correctly"
    )
    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))

    @lcc.test("Verify response of module variant api behind akamai")
    def verify_module_content_behind_akamai_endpoints(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.behind_akamai_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,
                                                  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))

    @lcc.test("Verify response of module variant api for external proxy API")
    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))
Ejemplo n.º 9
0
class test_publish_module(Screenshot):
    driver = lcc.inject_fixture("driver_obj")
    first_pub_date_details_page = ""
    last_pub_date_details_page = ""

    # updated_date_view_page = ""
    # published_date_view_page = ""

    @lcc.test(
        "Verify that warning is displayed for publish module with no product metadata"
    )
    def no_product_info_publish_module(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # # Click on the title if it is displayed on the first page
        utilities.wait(5)
        # search_page.search_for_module_and_click(self.driver, constants.unpublished_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(self.driver,
                                                 constants.unpublished_module)
        utilities.wait(5)
        tooltip_icon = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                              locators.NO_URL_TOOLTIP_ICON)
        check_that("No url tooltip icon is displayed",
                   tooltip_icon.is_displayed(), is_true())
        utilities.click_element(self.driver, By.ID,
                                locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID)
        check_that(
            "Button contains text",
            utilities.get_text(self.driver, By.ID,
                               locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID),
            contains_string("Publish"))

    @lcc.test(
        "Verify that user is able to successfully publish module with product metadata added, also checks for Pre-live URL functionality"
    )
    @lcc.depends_on('test_edit_metadata.edit_metadata_successfully')
    def publish_module(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # search_page.search_for_module_and_click(self.driver, constants.module_to_be_published)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.module_to_be_published)
        utilities.wait(10)

        pre_live_url = utilities.find_element(self.driver, By.LINK_TEXT,
                                              "Pre-live Customer Portal URL")
        print(pre_live_url.get_attribute('href'))
        check_that("Pre-live URL link is displayed",
                   pre_live_url.is_displayed(), is_true())
        copy_pre_live_url = utilities.find_element(self.driver, By.LINK_TEXT,
                                                   "Copy pre-live URL")
        check_that("Copy Pre-live URL is displayed",
                   copy_pre_live_url.is_displayed(), is_true())

        utilities.click_element(self.driver, By.ID,
                                locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID)
        utilities.wait(20)
        print("Clicked publish")
        # The page needs a refresh because of an existing bug about the "View on Customer Portal not appearing"
        self.driver.refresh()
        utilities.find_element(self.driver, By.PARTIAL_LINK_TEXT,
                               "View on Customer Portal")
        check_that(
            "Button contains text",
            utilities.get_text(self.driver, By.ID,
                               locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID),
            contains_string("Unpublish"))
        check_that(
            "Button contains text",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS),
            contains_string("Preview"))
        check_that(
            "Copy permanent url link is displayed",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.COPY_URL_LINK_CSS),
            contains_string(constants.copy_url_link))
        check_that(
            "View on portal link is displayed",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.VIEW_ON_PORTAL_LINK_CSS),
            contains_string(constants.view_on_portal_link))

        # get UPLOADED date in variable and covert into desired format- (DD Month YYYY)
        self.first_pub_date_details_page = (utilities.get_text(
            self.driver, By.CSS_SELECTOR,
            locators.FIRST_PUB_DATE_MODULE_PAGE_CSS))
        lcc.log_info("captured 1st published date from module info page : " +
                     self.first_pub_date_details_page)

        # get published date in variable and convert into desired format-(DD Month YYYY)
        self.last_pub_date_details_page = (utilities.get_text(
            self.driver, By.CSS_SELECTOR,
            locators.LAST_PUB_DATE_MODULE_PAGE_CSS))
        lcc.log_info("captured last published date from module info page : " +
                     test_publish_module.last_pub_date_details_page)

        # adding checks if the module is displayed on the UI
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.VIEW_ON_PORTAL_LINK_CSS)
        utilities.wait(5)
        try:
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(10)
            check_that("View on Portal URL path", self.driver.current_url,
                       contains_string(constants.view_on_portal_page_url))
        except (TimeoutException, StaleElementReferenceException,
                NoSuchElementException) as e:
            lcc.log_error("Element could not be located!!!")
            lcc.log_error(e)
        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    @lcc.test("Verify product info on view page")
    def product_info_on_view_page(self):
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS)
        try:
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(2)
            product_name = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_NAME_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text
            check_that("Product name reflected on view page", product_name,
                       contains_string(constants.product_name))
            product_version = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_VERSION_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text
            check_that("Product version reflected on view page",
                       product_version,
                       contains_string(constants.product_version))
            updated_date_view_page = utilities.find_shadow_dom_element(
                self.driver, locators.UPDATED_DATE_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text.strip("Updated ")
            check_that("updated date reflected on view page",
                       updated_date_view_page,
                       contains_string(self.first_pub_date_details_page))
            published_date_view_page = utilities.find_shadow_dom_element(
                self.driver, locators.PUBLISHED_DATE_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text.strip("Published ")
            check_that("published date reflected on view page",
                       published_date_view_page,
                       contains_string(self.last_pub_date_details_page))
            legal_notice = utilities.find_shadow_dom_element(
                self.driver, locators.LEGAL_NOTICE_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS)
            check_that(
                "legal notice is displayed at the bottom of preview page",
                legal_notice.text,
                contains_string("Legal Notices for Trademarks"))
            legal_notice_href = legal_notice.get_attribute("href")
            check_that("verify legal notice link", legal_notice_href,
                       contains_string(constants.legal_notice_link))

        except (TimeoutException, StaleElementReferenceException,
                NoSuchElementException) as e:
            lcc.log_error("Element could not be located!!!")
            lcc.log_error(e)
        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    @lcc.test("Verify info on customer portal")
    def product_info_on_customer_portal(self):
        utilities.wait(5)
        utilities.page_reload(self.driver)
        utilities.click_element(self.driver, By.PARTIAL_LINK_TEXT,
                                "View on Customer Portal")
        try:
            utilities.wait(5)
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(6)
            updated_date_on_portal = utilities.find_shadow_dom_element(
                self.driver, locators.UPDATED_DATE_ON_PORTAL_CSS,
                locators.MODULE_BODY_ON_PORTAL_CSS).get_attribute(
                    "textContent")
            check_that("updated date reflected on view page",
                       updated_date_on_portal,
                       contains_string(self.first_pub_date_details_page))
            published_date_on_portal = utilities.find_shadow_dom_element(
                self.driver, locators.PUBLISHED_DATE_ON_PORTAL_CSS,
                locators.MODULE_BODY_ON_PORTAL_CSS).get_attribute(
                    "textContent")
            check_that("published date reflected on view page",
                       published_date_on_portal,
                       contains_string(self.last_pub_date_details_page))
        except (TimeoutException, StaleElementReferenceException,
                NoSuchElementException) as e:
            lcc.log_error(
                "Some problem accessing the Customer Portal, please check.")
            lcc.log_error(e)
        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    def teardown_suite(self):
        response = unpublish_module(self, constants.module_to_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code", response.status_code,
                   equal_to(200))
        lcc.log_info(
            "Module published for above test is unpublished successfully..")
Ejemplo n.º 10
0
class test_assembly_edit_publish:
    api_auth = lcc.inject_fixture("api_auth")
    global product_id

    @lcc.test(
        "Verify that authenticated user can edit metadata for an assembly successfully also verify response of pre-live URL before and after adding metadata"
    )
    def verify_edit_metadata(self, setup_test_products, api_auth):
        self.variant = utilities.read_variant_name_from_pantheon2config()
        lcc.log_info(str(self.variant))
        self.variant = str(self.variant)
        self.path_for_assembly = utilities.select_nth_item_from_search_results(
            1, fixture.url, assembly_title_prefix, api_auth)

        edit_metadata_url = fixture.url + self.path_for_assembly + "/en_US/variants/" + \
                            self.variant + "/draft/metadata"
        lcc.log_info("Edit metadata request for assembly at : %s " %
                     edit_metadata_url)
        cp_url_path = fixture.url + self.path_for_assembly + "/en_US/variants/" + self.variant + ".url.json"
        print(cp_url_path)
        lcc.log_info("Checking Get CP URL api")
        resp = self.api_auth.get(cp_url_path)
        print(resp.json())
        check_that("Get CP url response", resp.json(),
                   has_entry("type", "ERROR"))
        check_that(
            "Get CP url response", resp.json(),
            has_entry(
                "url",
                "Document does not have associated product/version metadata."))

        # Fetch the product id from fixtures/fixtures.py, the test product and version was created as a setup step.
        product_id, product_name_uri = setup_test_products

        payload = {
            "productVersion": product_id,
            "documentUsecase": constants.assembly_documentusecase,
            "urlFragment": constants.assembly_urlfragment,
            "searchKeywords": constants.assembly_searchkeywords
        }
        # payload = urlencode(payload)
        print("Payload::", payload)
        # headers = {'content-type': "application/x-www-form-urlencoded"}
        edit_metadata_request = self.api_auth.post(edit_metadata_url,
                                                   data=payload)
        print(edit_metadata_request)
        time.sleep(10)
        check_that("Edit metadata request to be successful",
                   edit_metadata_request.status_code, equal_to(200))
        request_url = fixture.url + self.path_for_assembly + ".7.json"

        #check that metadata has been added successfully.
        response = self.api_auth.get(request_url)
        metadata_response = response.json()["en_US"]["variants"][
            self.variant]["draft"]["metadata"]
        check_that("The edit metadata request was successful",
                   edit_metadata_request.status_code,
                   any_of(equal_to(200), equal_to(201)))
        check_that("The product version has been updated successfully",
                   metadata_response["productVersion"], equal_to(product_id))
        check_that("The document use case has been updated successfully",
                   metadata_response["documentUsecase"],
                   equal_to(constants.assembly_documentusecase))
        check_that("The search keywords have been updated successfully",
                   metadata_response["searchKeywords"],
                   equal_to(constants.assembly_searchkeywords))
        check_that("The URL fragment has been updated successfully",
                   metadata_response["urlFragment"],
                   equal_to(constants.assembly_urlfragment))

        resp = self.api_auth.get(cp_url_path)
        print(resp.json())
        url_test = cp_url + "documentation/en-us/" + product_name_uri + "/" + constants.product_version_uri + "/guide/"
        check_that("Get CP url response", resp.json(),
                   has_entry("type", "PRELIVE"))
        check_that("Get CP url response", resp.json(), has_entry("url"))
        check_that("Get CP URL response",
                   resp.json()["url"], contains_string(url_test))

    @lcc.test(
        "Verify that the user can publish an assembly successfully and check for /api/assembly/variant.json/"
        "<assembly_uuid> endpoint")
    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())
        #add a check for date_published, search_keywords, etc.

    @lcc.test(
        "Verify that acknowledgement was received from Hydra on publishing assembly"
    )
    def ack_status_check(self, api_auth):
        self.request_url = fixture.url + self.path_for_assembly + ".10.json"
        response = api_auth.get(self.request_url)
        time.sleep(60)
        #calling the get request twice
        response = api_auth.get(self.request_url)
        lcc.log_info("Checking for ack_status at url: %s" %
                     str(self.request_url))
        check_that(
            "The published assembly now has a released node with ack_status node ",
            response.json()["en_US"]["variants"][self.variant]["released"],
            has_entry("ack_status"))
        lcc.log_info("Ack status node response: %s" %
                     str(response.json()["en_US"]["variants"][self.variant]
                         ["released"]["ack_status"]))
        check_that(
            "The published assembly has a successful message from Hydra",
            response.json()["en_US"]["variants"][self.variant]["released"]
            ["ack_status"]["pant:message"],
            equal_to("Solr call for index was successful"))

        check_that(
            "The published assembly has a successful ACK from Hydra",
            response.json()["en_US"]["variants"][self.variant]["released"]
            ["ack_status"]["pant:status"], equal_to("SUCCESSFUL"))

    @lcc.test(
        "Verify that the assembly was indexed in Solr in docv2 collection")
    def verify_solr_docv2_indexing_assembly(self):
        # Reusing the module id fetched in the above test
        time.sleep(15)
        solr_request_url = fixture.solr_url + "solr/docv2/select?indent=on&q=id:" + self.assembly_uuid + "&wt=json"
        lcc.log_info("Checking docv2 collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        time.sleep(10)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The assembly is indexed in docv2 collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(1))
        check_that("The content type",
                   solr_request_json["response"]["docs"][0]["content_type"][0],
                   equal_to("assembly"))
        check_that("The uri", solr_request_json["response"]["docs"][0]["uri"],
                   equal_to(self.assembly_uuid))

    @lcc.disabled()
    @lcc.test(
        "Verify if the assembly is available for search in access collection")
    def verify_solr_access_collection_assembly(self):
        time.sleep(40)
        solr_request_url = fixture.solr_url + "solr/access/select?indent=on&q=id:" + self.assembly_uuid + "&wt=json"
        lcc.log_info("Checking access collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        time.sleep(10)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The assembly is indexed in access collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(1))
        #add more checks here.
        check_that("The content type source ",
                   solr_request_json["response"]["docs"][0]["source"],
                   equal_to("assembly"))

    @lcc.test(
        "Verify that the assembly is successfully unpublished, Hydra sends an ACK"
    )
    def unpublish_assembly(self, api_auth):
        unpublish_url = fixture.url + self.path_for_assembly
        lcc.log_info("Unpublishing the assembly: %s" % unpublish_url)
        payload = {
            ":operation": "pant:unpublish",
            "locale": "en_US",
            "variant": self.variant
        }
        unpublish_assembly_request = self.api_auth.post(
            unpublish_url,
            data=payload,
            headers={'Accept': 'application/json'})
        time.sleep(12)
        check_that("Unpublish request status code",
                   unpublish_assembly_request.status_code, equal_to(200))

        # Check if the unpublish request response does not return "url" for Customer Portal: CCS-3860
        cp_url_returned = unpublish_assembly_request.json()["location"]
        check_that(
            "UnPublish Assembly response does not contain The Customer Portal URL",
            cp_url_returned,
            not_(contains_string(fixture.cp_url + "documentation")))
        time.sleep(20)
        response = api_auth.get(self.request_url)
        lcc.log_info("Checking for ack_status at url after unpublish: %s" %
                     str(self.request_url))
        check_that(
            "The unpublished assembly now has a draft node with ack_status node ",
            response.json()["en_US"]["variants"][self.variant]["draft"],
            has_entry("ack_status"))
        lcc.log_info("Ack status node response: %s" %
                     str(response.json()["en_US"]["variants"][self.variant]
                         ["draft"]["ack_status"]))
        # this is a place holder check
        check_that(
            "The unpublished assembly has a successful message from Hydra",
            response.json()["en_US"]["variants"][self.variant]["draft"]
            ["ack_status"]["pant:message"],
            equal_to("Solr call for delete was successful"))

        check_that(
            "The unpublished assembly has a successful ACK from Hydra",
            response.json()["en_US"]["variants"][self.variant]["draft"]
            ["ack_status"]["pant:status"], equal_to("SUCCESSFUL"))

    @lcc.test(
        "Verify if the assembly is successfully removed from docv2 collection")
    def removed_from_docv2_Solr(self):
        time.sleep(15)
        solr_request_url = fixture.solr_url + "solr/docv2/select?indent=on&q=id:" + self.assembly_uuid + "&wt=json"
        lcc.log_info("Checking docv2 collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        time.sleep(5)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The assembly is removed from docv2 collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(0))

    @lcc.disabled()
    @lcc.test(
        "Verify is the assembly is successfully removed from access collection in Solr"
    )
    def removed_from_access_Solr(self):
        lcc.log_info(
            "Checking if the assembly is removed from search results, access collection"
        )
        time.sleep(20)
        solr_request_url = fixture.solr_url + "solr/access/select?indent=on&q=id:" + self.assembly_uuid + "&wt=json"
        lcc.log_info("Checking access collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The assembly is removed from access collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(0))
class test_new_draft(Screenshot):
    driver = lcc.inject_fixture("driver_obj")
    now = datetime.now(timezone.utc)
    print("Now::", now)
    now_plus_15 = now + timedelta(minutes=15)
    now_minus_15 = now - timedelta(minutes=15)
    print("Range::", now_minus_15, "--", now_plus_15)
    flag = False

    def check_date_in_range(self, date):
        flag = False
        if (self.now_minus_15 <= date <= self.now_plus_15):
            flag = True
            print("date-time::", date)
        return flag

    def setup_suite(self):
        utilities.wait(5)
        # Navigate to search page
        # Select repo and search for the assembly
        # Add metadata and publish the assembly using api endpoints and wait for the unpublish button to display
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # search_page.search_for_module_and_click(self.driver, constants.published_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.assembly_new_draft_version)
        display_module_page.add_metadata_and_publish(self.driver)
        utilities.wait_for_element(self.driver, By.ID,
                                   locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID)
        # Navigate to search page
        # Select repo and search for the module
        # Add metadata and publish the module using api endpoints and wait for the unpublish button to display
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        # search_page.search_for_module_and_click(self.driver, constants.published_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.module_new_draft_version)
        display_module_page.add_metadata_and_publish(self.driver)
        utilities.wait_for_element(self.driver, By.ID,
                                   locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID)

    @lcc.test("Upload the repo via uploader script 2nd time")
    def upload_repo_again(self):
        lcc.log_info("Uploaded the repo again")
        os.chdir(fixture.project_dir_git)
        repo = Repo(fixture.project_dir_git)
        git = repo.git
        git.checkout("at-uploader2")
        subprocess.check_call(
            ('pantheon --user={} --password={} --server={} push'.format(
                uploader_username, uploader_password, url)),
            shell=True)
        # search_page.search_for_module_and_click(self.driver, constants.published_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.assembly_new_draft_version + " 2")
        check_that(
            "Draft card is displayed",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.DRAFT_CARD).is_displayed(),
            is_true())
        check_that(
            "Published card is displayed",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.PUBLISHED_CARD).is_displayed(),
            is_true())

        # Modify the datetime string to be in same format as datetime.now()
        draft_date1 = (utilities.find_element(
            self.driver, By.CSS_SELECTOR,
            locators.UPLOAD_TIME_ON_DRAFT_CARD).text)
        draft_date2 = draft_date1.split("GMT")
        pub_date1 = (utilities.find_element(
            self.driver, By.CSS_SELECTOR,
            locators.UPLOAD_TIME_ON_PUBLISHED_CARD).text)
        pub_date2 = pub_date1.split("GMT")
        print("Date time now::", self.now)
        draft_date = datetime.strptime(draft_date2[0].strip(),
                                       '%a %b %d %Y %H:%M:%S')
        draft_date = draft_date.replace(tzinfo=pytz.utc)
        pub_date = datetime.strptime(pub_date2[0].strip(),
                                     '%a %b %d %Y %H:%M:%S')
        pub_date = pub_date.replace(tzinfo=pytz.utc)
        print("Type of date is now::", draft_date)
        lcc.log_info("pub_date::%s" % pub_date)
        lcc.log_info("draft_date::%s" % draft_date)

        check_that(
            "Draft text displayed on card",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.DRAFT_CARD_TITLE), equal_to("Draft"))
        check_that(
            "Published text displayed on card",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.PUBLISHED_CARD_TITLE),
            equal_to("Published"))
        check_that("Draft upload date in expected range",
                   self.check_date_in_range(draft_date), is_true())
        check_that("Uploaded date for published card in expected range",
                   self.check_date_in_range(pub_date), is_true())
        check_that(
            "Uploaded date for published card should be less than draft uploaded date",
            pub_date < draft_date, is_true())
        draft_card = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                            locators.DRAFT_CARD)
        published_card = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                                locators.PUBLISHED_CARD)
        check_that(
            "Add metadata link present of draft card",
            draft_card.find_element(
                By.XPATH, locators.ADD_METADATA_BUTTON_XPATH).is_displayed(),
            is_true())
        check_that(
            "Add metadata link present of published card",
            published_card.find_element(
                By.XPATH, locators.ADD_METADATA_BUTTON_XPATH).is_displayed(),
            is_true())
        check_that(
            "Preview link present of draft card",
            draft_card.find_element(
                By.CSS_SELECTOR,
                locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS).is_displayed(),
            is_true())
        check_that(
            "Preview link present of published card",
            published_card.find_element(
                By.CSS_SELECTOR,
                locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS).is_displayed(),
            is_true())
        check_that(
            "Publish button displayed on draft card",
            draft_card.find_element(
                By.ID,
                locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID).is_displayed(),
            is_true())
        check_that(
            "Unpublish button displayed on published card",
            published_card.find_element(
                By.ID,
                locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID).is_displayed(),
            is_true())
        check_that(
            "Attributes file path on draft card",
            draft_card.find_element(By.CSS_SELECTOR,
                                    locators.ATTRIBUTE_FILE_CSS).text,
            equal_to("enterprise/meta/attributes.adoc"))
        check_that(
            "Attributes file path on published card",
            published_card.find_element(By.CSS_SELECTOR,
                                        locators.ATTRIBUTE_FILE_CSS).text,
            equal_to("enterprise/meta/attributes.adoc"))

    def teardown_suite(self):
        response = unpublish_module(self, constants.module_new_draft_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code for module",
                   response.status_code, equal_to(200))

        response = unpublish_module(self,
                                    constants.assembly_new_draft_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code for assembly",
                   response.status_code, equal_to(200))
Ejemplo n.º 12
0
class test_edit_metadata(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    @lcc.test("Verify that warning should be displayed on Edit Metadata modal when no data is entered")
    def edit_metadata_blank_data(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # # Click on the title if it is displayed on the first page
        utilities.wait(5)
        # search_page.search_for_module_and_click(self.driver, constants.module_to_be_published)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(self.driver, constants.module_to_be_published)
        self.driver.refresh()
        utilities.click_element(self.driver, By.XPATH, locators.ADD_METADATA_BUTTON_XPATH)
        check_that("Edit metadata modal title",
                   utilities.get_text(self.driver, By.CSS_SELECTOR, locators.EDIT_METADATA_MODAL_TITLE_CSS),
                   contains_string(constants.edit_metadata_modal_title))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.EDIT_METADATA_SAVE_CSS)
        check_that("Warning displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.edit_metadata_modal_warning))
        utilities.wait(2)

    @lcc.test("Verify that warning should be displayed on Edit Metadata modal when Product name field is blank")
    def edit_metadata_empty_productname(self):
        display_module_page.reset_edit_metadata_from(self.driver)
        display_module_page.fill_edit_metadata_form(self.driver, constants.default_product_name,
                                                    constants.default_product_version, constants.use_case,
                                                    constants.url_fragment)
        check_that("Warning displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.edit_metadata_modal_warning))
        utilities.wait(2)

    @lcc.test("Verify that warning should be displayed on Edit Metadata modal when Product version field is blank")
    def edit_metadata_empty_version(self):
        display_module_page.reset_edit_metadata_from(self.driver)
        display_module_page.fill_edit_metadata_form(self.driver, constants.product_name, constants.default_product_version,
                                                    constants.use_case, constants.url_fragment)
        check_that("Warning displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.edit_metadata_modal_warning))
        utilities.wait(2)

    @lcc.test("Verify that warning should be displayed on Edit Metadata modal when Usecase field is blank")
    def edit_metadata_empty_usecase(self):
        display_module_page.reset_edit_metadata_from(self.driver)
        display_module_page.fill_edit_metadata_form(self.driver, constants.product_name, constants.product_version,
                                                    constants.default_use_case, constants.url_fragment)
        check_that("Warning displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.edit_metadata_modal_warning))
        utilities.wait(2)

    @lcc.test("Verify that user should be able to add product metadata successfully")
    def edit_metadata_successfully(self):
        display_module_page.reset_edit_metadata_from(self.driver)
        display_module_page.fill_edit_metadata_form(self.driver, constants.product_name, constants.product_version,
                                                    constants.use_case, constants.url_fragment)
        check_that("Success message displayed",
                   utilities.get_text(self.driver, By.CSS_SELECTOR, locators.UPDATE_SUCCESS_MESSAGE_CSS),
                   contains_string(constants.success_message))
        check_that("Product name reflected on displayed module page",
                   utilities.get_text(self.driver, By.CSS_SELECTOR, locators.PRODUCT_INFO_CSS),
                   contains_string(constants.product_name))
        check_that("Product version reflected on displayed module page",
                   utilities.get_text(self.driver, By.CSS_SELECTOR, locators.PRODUCT_INFO_CSS),
                   contains_string(constants.product_version))
Ejemplo n.º 13
0
class test_view_module(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    def setup_suite(self):
        # Add metadata
        utilities.wait(5)
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # search_page.search_for_module_and_click(self.driver, constants.published_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(self.driver,
                                                 constants.published_module)
        display_module_page.add_metadata_and_publish(self.driver)
        utilities.wait_for_element(self.driver, By.ID,
                                   locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID)

    @lcc.test(
        "Verify that for authenticated user, unpublished module displays all expected checks: Preview, ability to"
        " Publish, and status")
    # @lcc.depends_on('test_publish_module.publish_module')
    def authenticated_user_view_unpublished_module(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # search_page.search_for_module_and_click(self.driver, constants.unpublished_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(self.driver,
                                                 constants.unpublished_module)
        check_that(
            "Button",
            utilities.get_text(self.driver, By.ID,
                               locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID),
            contains_string("Publish"))
        check_that(
            "Button",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS),
            contains_string("Preview"))
        check_that(
            "First Published date",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_FIRST_PUBLISHED_CSS),
            contains_string("--"))
        check_that(
            "Last Published date",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_LAST_PUBLISHED_CSS),
            contains_string("--"))
        check_that(
            "Module display page title",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_TITLE_CSS),
            contains_string(constants.unpublished_module))

    @lcc.test(
        "Verify that for authenticated user, a previously published module displays all expected checks: "
        "Unpublish and View buttons")
    # @lcc.depends_on('test_publish_module.publish_module')
    def authenticated_user_view_published_module(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        # search_page.search_for_module_and_click(self.driver, constants.published_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(self.driver,
                                                 constants.published_module)
        # utilities.find_element(self.driver, By.ID, locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID)
        check_that(
            "Button",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS),
            contains_string("Preview"))
        check_that(
            "Button",
            utilities.get_text(self.driver, By.ID,
                               locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID),
            contains_string("Unpublish"))
        # Add a check that the Published column contains some Published time.

    @lcc.test(
        "Verify that 'View on Customer Portal' link navigates to correct page and verify the presence of content"
    )
    # @lcc.depends_on('test_publish_module.publish_module')
    def view_on_portal_link_test(self):
        try:
            utilities.wait(5)
            utilities.click_element(self.driver, By.CSS_SELECTOR,
                                    locators.VIEW_ON_PORTAL_LINK_CSS)
            utilities.wait(5)
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(7)
            lcc.log_info(
                "Find the CP preview in the attachment below for debugging purposes"
            )
            self.driver.save_screenshot("cp_preview_module.png")
            lcc.save_attachment_file("cp_preview_module.png")
            check_that("View on Portal URL path", self.driver.current_url,
                       contains_string(constants.view_on_portal_page_url))
            module_id_regex = re.compile(
                r'^[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$'
            )
            current__module_id = self.driver.current_url.split("/topic/")[1]
            check_that("View on Portal URL id", current__module_id,
                       match_pattern(module_id_regex))
            # content_body_on_portal = utilities.find_element(self.driver, By.CSS_SELECTOR, locators.MODULE_BODY_ON_PORTAL_CSS)
        except (TimeoutException, StaleElementReferenceException,
                NoSuchElementException) as e:
            lcc.log_error("Error finding element!!!")
            lcc.log_error(e)
        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    @lcc.test("Verify that module content displays as expected on CP")
    def view_content_on_cp(self):
        # # try:
        test_repo_name = base.config_reader('test_repo', 'repo_name')
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.wait(5)
        # search_page.search_for_module_and_click(self.driver, constants.published_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(self.driver,
                                                 constants.published_module)
        utilities.wait(5)
        try:
            adoc_file_path = display_module_page.get_path_to_adoc(self.driver)
            utilities.click_element(self.driver, By.CSS_SELECTOR,
                                    locators.VIEW_ON_PORTAL_LINK_CSS)
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(6)
            content_body_on_portal = self.driver.find_element_by_css_selector(
                locators.MODULE_BODY_ON_PORTAL_CSS)
            # Verify content displayed on CP
            check_that(
                "Module title is displayed",
                utilities.find_shadow_dom_element(
                    self.driver, locators.MODULE_TITLE_ON_PORTAL_CSS,
                    locators.MODULE_BODY_ON_PORTAL_CSS).get_attribute(
                        "textContent"), equal_to(constants.published_module))
            check_that(
                "Product name displayed on Customer Portal",
                utilities.find_shadow_dom_element(
                    self.driver, locators.CP_PRODUCT_NAME_CSS,
                    locators.MODULE_BODY_ON_PORTAL_CSS).get_attribute(
                        "textContent"), equal_to(constants.product_name))
            check_that(
                "Product version displayed on Customer Portal",
                utilities.find_shadow_dom_element(
                    self.driver, locators.CP_PRODUCT_VERSION_CSS,
                    locators.MODULE_BODY_ON_PORTAL_CSS).get_attribute(
                        "textContent"), equal_to(constants.product_version))
            legal_notice = utilities.find_shadow_dom_element(
                self.driver, locators.LEGAL_NOTICE_ON_PORTAL_CSS,
                locators.MODULE_BODY_ON_PORTAL_CSS)
            check_that(
                "legal notice is displayed at the bottom of preview page",
                legal_notice.get_attribute("textContent"),
                contains_string("Legal Notices for Trademarks"))
            legal_notice_href = legal_notice.get_attribute("href")
            check_that("verify legal notice link", legal_notice_href,
                       contains_string(constants.legal_notice_link))
            image = utilities.find_shadow_dom_element(
                self.driver, locators.IMAGE_CSS,
                locators.MODULE_BODY_ON_PORTAL_CSS)
            src = image.get_attribute("src")
            imageasset = urlparse(src)
            imageasset = imageasset.path.split("/")[2]
            cmd = "echo " + imageasset + "|base64 -d"
            try:
                # subprocess.check_call(cmd, shell=True)
                path = subprocess.getoutput(cmd)
                print("Image file path::", path)
                print("File name::", constants.image_file_name)
                print("Path to adoc::", adoc_file_path)
                p1 = os.path.split(adoc_file_path)
                image_file = "/" + p1[
                    0] + "/images/" + constants.image_file_name
                # image_file = "/content/repositories/" + test_repo_name + "/entities/enterprise/modules/images/" + constants.image_file_name
                check_that("Path to image1", path, equal_to(image_file))
            except subprocess.CalledProcessError as e:
                lcc.log_info("Unable to decode imageasset")
        except Exception as e:
            lcc.log_info(e)
        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    @lcc.test("verify attribute is resolving correctly on preview page")
    def verify_attribute_text(self):
        try:
            utilities.click_element(self.driver, By.LINK_TEXT, "Search")
            # search_page.search_for_module_and_click(self.driver, constants.search_module_with_attribute)
            search_beta_page.select_repo(self.driver, fixture.repo_name)
            search_beta_page.search_module_and_click(
                self.driver, constants.search_module_with_attribute)
            utilities.click_element(self.driver, By.CSS_SELECTOR,
                                    locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS)
            utilities.wait(2)
            utilities.switch_to_latest_tab(self.driver)
            attribute_text = utilities.find_shadow_dom_element(
                self.driver, locators.ATTRIBUTE_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text
            check_that(
                "verify attribute is resolving correctly on preview page",
                attribute_text, contains_string(constants.attribute))
        except Exception as e:
            lcc.log_info(e)
        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    def teardown_suite(self):
        response = unpublish_module(self, constants.view_module_unpubish,
                                    constants.variant)
        check_that("Unpublish request status code", response.status_code,
                   equal_to(200))
        lcc.log_info(
            "module published for above test is unpublished successfully..")
class test_module_edit_publish:
    api_auth = lcc.inject_fixture("api_auth")
    path_for_module = ""
    request_url = ""

    @lcc.test(
        "Verify that authenticated user can edit metadata successfully also verify response of pre-live URL before and after adding metadata"
    )
    def edit_metadata(self, api_auth, setup_test_products):
        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, api_auth)
        edit_metadata_url = fixture.url + self.path_for_module + "/en_US/variants/" + self.variant + "/draft/metadata"
        cp_url_path = fixture.url + self.path_for_module + "/en_US/variants/" + self.variant + ".url.json"
        print(cp_url_path)
        lcc.log_info("Checking Get CP URL api")
        resp = self.api_auth.get(cp_url_path)
        print(resp.json())
        check_that("Get CP url response", resp.json(),
                   has_entry("type", "ERROR"))
        check_that(
            "Get CP url response", resp.json(),
            has_entry(
                "url",
                "Document does not have associated product/version metadata."))

        lcc.log_info("Edit metadata request for module: %s " %
                     edit_metadata_url)

        # Fetch the product id from fixtures, ta test product and version was created as setup step.
        product_id, product_name_uri = setup_test_products
        payload = {
            "productVersion": product_id,
            "documentUsecase": constants.documentUsecase,
            "urlFragment": constants.urlFragment,
            "searchKeywords": constants.searchKeywords
        }
        # payload = urlencode(payload)
        print("PAyload::", payload)
        # headers = {'content-type': "application/x-www-form-urlencoded"}
        edit_metadata_request = self.api_auth.post(edit_metadata_url,
                                                   data=payload)
        time.sleep(10)
        print("Response::", edit_metadata_request)
        self.request_url = fixture.url + self.path_for_module + ".10.json"
        #check that metadata has been added successfully.
        response = api_auth.get(self.request_url)
        print("Response::", response)
        metadata_response = response.json()["en_US"]["variants"][
            self.variant]["draft"]["metadata"]
        print("Metadata response::", metadata_response)
        check_that("The edit metadata request was successful",
                   edit_metadata_request.status_code,
                   any_of(equal_to(200), equal_to(201)))
        check_that("The product version has been updated successfully",
                   metadata_response["productVersion"], equal_to(product_id))
        check_that("The document use case has been updated successfully",
                   metadata_response["documentUsecase"],
                   equal_to(constants.documentUsecase))

        resp = self.api_auth.get(cp_url_path)
        print(resp.json())
        url_test = cp_url + "documentation/en-us/" + product_name_uri + "/" + constants.product_version_uri + "/topic/"
        check_that("Get CP url response", resp.json(),
                   has_entry("type", "PRELIVE"))
        check_that("Get CP url response", resp.json(), has_entry("url"))
        check_that("Get CP URL response",
                   resp.json()["url"], contains_string(url_test))

    @lcc.test("Verify that authenticated user can publish module successfully")
    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())

    @lcc.test("Verify that acknowledgement was received from Hydra")
    def ack_status_check(self, api_auth):
        #self.request_module_url = fixture.url + self.path_for_module + ".10.json"
        time.sleep(40)
        response = api_auth.get(self.request_url)
        lcc.log_info("Checking for ack_status at url: %s" %
                     str(self.request_url))
        check_that(
            "The published module now has a released node with ack_status node ",
            response.json()["en_US"]["variants"][self.variant]["released"],
            has_entry("ack_status"))
        lcc.log_info("Ack status node response: %s" %
                     str(response.json()["en_US"]["variants"][self.variant]
                         ["released"]["ack_status"]))
        check_that(
            "The published module has a successful message from Hydra",
            response.json()["en_US"]["variants"][self.variant]["released"]
            ["ack_status"]["pant:message"],
            equal_to("Solr call for index was successful"))

        check_that(
            "The published module has a successful ACK from Hydra",
            response.json()["en_US"]["variants"][self.variant]["released"]
            ["ack_status"]["pant:status"], equal_to("SUCCESSFUL"))

    @lcc.test("Verify that the module was indexed in Solr in docv2 collection")
    def verify_solr_indexing(self):
        # Reusing the module id fetched in the above test
        time.sleep(15)
        solr_request_url = fixture.solr_url + "solr/docv2/select?indent=on&q=id:" + self.module_uuid + "&wt=json"
        lcc.log_info("Checking docv2 collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The module is indexed in docv2 collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(1))
        check_that("The content type",
                   solr_request_json["response"]["docs"][0]["content_type"][0],
                   equal_to("module"))

    @lcc.disabled()
    @lcc.test(
        "Verify if the module is available for search in access collection")
    def verify_solr_access_collection_module(self):
        time.sleep(40)
        solr_request_url = fixture.solr_url + "solr/access/select?indent=on&q=id:" + self.module_uuid + "&wt=json"
        lcc.log_info("Checking access collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        time.sleep(10)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The module is indexed in access collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(1))
        # add more checks here.
        check_that("The content type source ",
                   solr_request_json["response"]["docs"][0]["source"],
                   equal_to("module"))

    @lcc.test(
        "Verify that the module is successfully unpublished, Hydra sends an ACK"
    )
    def unpublish_module(self, api_auth):
        unpublish_url = fixture.url + self.path_for_module
        lcc.log_info("Unpublishing the module: %s" % unpublish_url)
        payload = {
            ":operation": "pant:unpublish",
            "locale": "en_US",
            "variant": self.variant
        }
        unpublish_module_request = self.api_auth.post(
            unpublish_url,
            data=payload,
            headers={'Accept': 'application/json'})
        time.sleep(15)
        check_that("Unpublish request status code",
                   unpublish_module_request.status_code, equal_to(200))

        # Check if the unpublish request response does not return "url" for Customer Portal: CCS-3860
        cp_url_returned = unpublish_module_request.json()["location"]
        check_that(
            "UnPublish module response does not contain The Customer Portal URL",
            cp_url_returned,
            not_(contains_string(fixture.cp_url + "documentation")))

        time.sleep(20)
        response = api_auth.get(self.request_url)
        lcc.log_info("Checking for ack_status at url after unpublish: %s" %
                     str(self.request_url))
        check_that(
            "The unpublished module now has a draft node with ack_status node ",
            response.json()["en_US"]["variants"][self.variant]["draft"],
            has_entry("ack_status"))
        lcc.log_info("Ack status node response: %s" %
                     str(response.json()["en_US"]["variants"][self.variant]
                         ["draft"]["ack_status"]))
        # this is a place holder check
        check_that(
            "The unpublished module has a successful message from Hydra",
            response.json()["en_US"]["variants"][self.variant]["draft"]
            ["ack_status"]["pant:message"],
            equal_to("Solr call for delete was successful"))

        check_that(
            "The unpublished module has a successful ACK from Hydra",
            response.json()["en_US"]["variants"][self.variant]["draft"]
            ["ack_status"]["pant:status"], equal_to("SUCCESSFUL"))

    @lcc.test(
        "Verify if the module is successfully removed from docv2 collection in Solr"
    )
    def removed_from_solr(self):
        time.sleep(20)
        solr_request_url = fixture.solr_url + "solr/docv2/select?indent=on&q=id:" + self.module_uuid + "&wt=json"
        lcc.log_info("Checking docv2 collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The module is removed from docv2 collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(0))

    @lcc.disabled()
    @lcc.test(
        "Verify if the module is successfully removed from access collection in Solr"
    )
    def removed_from_access_Solr(self):
        lcc.log_info(
            "Checking if the module is removed from search results, access collection"
        )
        time.sleep(20)
        solr_request_url = fixture.solr_url + "solr/access/select?indent=on&q=id:" + self.module_uuid + "&wt=json"
        lcc.log_info("Checking access collection in Solr: %s" %
                     solr_request_url)
        solr_request = requests.get(solr_request_url)
        solr_request_json = solr_request.json()
        lcc.log_info("Response from Solr: %s " % str(solr_request_json))
        check_that("The module is removed from access collection in Solr",
                   solr_request_json["response"]["numFound"], equal_to(0))
Ejemplo n.º 15
0
    class MySuite:
        fix3 = lcc.inject_fixture()

        @lcc.test("test")
        def sometest(self):
            pass
Ejemplo n.º 16
0
class test_git_import:
    api_auth = lcc.inject_fixture("api_auth")
    status_key = ""

    @lcc.test(
        "Verify that git clone API is able to upload files successfully and get status_key from response"
    )
    def git_clone_api(self):
        payload = {
            "branch": git_import_repo_branch,
            "repo": git_import_repo_URL
        }

        payload = json.dumps(payload)
        lcc.log_info(str(payload))
        git_import_req = requests.post(fixture.git_import_server +
                                       "/api/clone",
                                       data=payload)
        check_that("POST request to git clone was done",
                   git_import_req.status_code, equal_to(202))
        self.status_key = git_import_req.content
        time.sleep(5)
        git_status_response = requests.post(fixture.git_import_server +
                                            "/api/status",
                                            data=self.status_key)
        check_that("git import status",
                   git_status_response.json()["status"],
                   contains_string("uploading"))

    @lcc.test("Verify that resources are uploaded")
    def check_resources_api(self):
        poll(lambda: requests.post(fixture.git_import_server +
                                   "/api/progress-update/resources",
                                   data=self.status_key),
             check_success=check_current_status,
             step=5,
             timeout=60)
        resources_response = requests.post(fixture.git_import_server +
                                           "/api/progress-update/resources",
                                           data=self.status_key)
        check_that("resources API status code", resources_response.status_code,
                   equal_to(200))
        check_that("current status",
                   resources_response.json()["current_status"],
                   equal_to("done"))
        check_that("number of resources uploaded",
                   resources_response.json()["total_files_uploaded"],
                   equal_to(int(number_of_resources_uploaded)))
        check_that("resources not uploaded",
                   resources_response.json()["resources_not_uploaded"],
                   equal_to([]))
        check_that("server message",
                   resources_response.json()["server_message"],
                   equal_to("Accepting requests"))
        check_that("server status",
                   resources_response.json()["server_status"], equal_to("OK"))
        check_that("last_uploaded_file",
                   resources_response.json()["last_uploaded_file"],
                   is_not_none())
        check_that("modules not uploaded",
                   resources_response.json()["resources_not_uploaded"],
                   equal_to([]))
        resources_uploaded = resources_response.json()["resources_uploaded"]
        check_response_code(resources_uploaded, "response_code",
                            int(number_of_resources_uploaded))
        check_not_null(resources_uploaded, "path",
                       int(number_of_resources_uploaded))
        check_not_null(resources_uploaded, "response_details",
                       int(number_of_resources_uploaded))

    @lcc.test("Verify that modules are uploaded")
    def check_modules_api(self):
        poll(lambda: requests.post(fixture.git_import_server +
                                   "/api/progress-update/modules",
                                   data=self.status_key),
             check_success=check_current_status,
             step=5,
             timeout=20)
        modules_response = requests.post(fixture.git_import_server +
                                         "/api/progress-update/modules",
                                         data=self.status_key)
        check_that("modules API status code", modules_response.status_code,
                   equal_to(200))
        check_that("current status",
                   modules_response.json()["current_status"], equal_to("done"))
        check_that("number of modules uploaded",
                   modules_response.json()["total_files_uploaded"],
                   equal_to(int(number_of_modules_uploaded)))
        check_that("modules not uploaded",
                   modules_response.json()["modules_not_uploaded"],
                   equal_to([]))
        check_that("server message",
                   modules_response.json()["server_message"],
                   equal_to("Accepting requests"))
        check_that("server status",
                   modules_response.json()["server_status"], equal_to("OK"))
        check_that("last_uploaded_file",
                   modules_response.json()["last_uploaded_file"],
                   is_not_none())
        modules_uploaded = modules_response.json()["modules_uploaded"]
        check_response_code(modules_uploaded, "response_code",
                            int(number_of_modules_uploaded))
        check_not_null(modules_uploaded, "path",
                       int(number_of_modules_uploaded))
        check_not_null(modules_uploaded, "response_details",
                       int(number_of_modules_uploaded))

    @lcc.test("Verify that assemblies are uploaded")
    def check_assemblies_api(self):
        poll(lambda: requests.post(fixture.git_import_server +
                                   "/api/progress-update/assemblies",
                                   data=self.status_key),
             check_success=check_current_status,
             step=5,
             timeout=20)
        assemblies_response = requests.post(fixture.git_import_server +
                                            "/api/progress-update/assemblies",
                                            data=self.status_key)
        check_that("modules API status code", assemblies_response.status_code,
                   equal_to(200))
        check_that("current status",
                   assemblies_response.json()["current_status"],
                   equal_to("done"))
        check_that("number of assemblies uploaded",
                   assemblies_response.json()["total_files_uploaded"],
                   equal_to(int(number_of_assemblies_uploaded)))
        check_that("assemblies not uploaded",
                   assemblies_response.json()["assemblies_not_uploaded"],
                   equal_to([]))
        check_that("server message",
                   assemblies_response.json()["server_message"],
                   equal_to("Accepting requests"))
        check_that("server status",
                   assemblies_response.json()["server_status"], equal_to("OK"))
        check_that("last_uploaded_file",
                   assemblies_response.json()["last_uploaded_file"],
                   is_not_none())
        assemblies_uploaded = assemblies_response.json()["assemblies_uploaded"]
        check_response_code(assemblies_uploaded, "response_code",
                            int(number_of_assemblies_uploaded))
        check_not_null(assemblies_uploaded, "path",
                       int(number_of_assemblies_uploaded))
        check_not_null(assemblies_uploaded, "response_details",
                       int(number_of_assemblies_uploaded))

    @lcc.test("Verify progress-update/all API works as expected")
    def check_progress_update_all_api(self):
        response = requests.post(fixture.git_import_server +
                                 "/api/progress-update/all",
                                 data=self.status_key)
        check_that("progress-update/all API status code", response.status_code,
                   equal_to(200))
        check_that("current status",
                   response.json()["current_status"], equal_to("done"))
        check_that(
            "status code for module variant created",
            response.json()["module_variants_created"][0]["response_code"],
            equal_to(201))

        git_status_response = requests.post(fixture.git_import_server +
                                            "/api/status",
                                            data=self.status_key)
        check_that("git import status",
                   git_status_response.json()["status"],
                   contains_string("done"))

    def teardown_suite(self):
        # Deleting the git repo uploaded via git import in the test suite.
        lcc.log_info("Deleting the git repo imported...")
        path_to_git_repo = fixture.url + "bin/cpm/nodes/node.json/content/repositories/" + git_import_repo_Name
        lcc.log_info(
            "Test repo node used for git import functionality being deleted at: %s"
            % path_to_git_repo)
        response_git_delete = requests.delete(path_to_git_repo,
                                              auth=(fixture.admin_username,
                                                    fixture.admin_auth))
        # print(str(response_git_delete.content))
        check_that(
            "The git import test repo was deleted successfully from backend",
            response_git_delete.status_code, equal_to(200))
class test_view_assembly(Screenshot):
    driver = lcc.inject_fixture("driver_obj")
    modules_count = 0
    module_titles = []

    @lcc.test("Verify that user can add metadata to assembly")
    def add_metadata(self):
        utilities.wait(5)
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # search_page.search_for_module_and_click(self.driver, constants.assembly_to_be_published)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.assembly_to_be_published)
        utilities.click_element(self.driver, By.XPATH,
                                locators.ADD_METADATA_BUTTON_XPATH)
        check_that(
            "Edit metadata modal title",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.EDIT_METADATA_MODAL_TITLE_CSS),
            contains_string(constants.edit_metadata_modal_title))
        display_module_page.fill_edit_metadata_form(self.driver,
                                                    constants.product_name,
                                                    constants.product_version,
                                                    constants.use_case,
                                                    constants.url_fragment)
        check_that(
            "Success message displayed",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.UPDATE_SUCCESS_MESSAGE_CSS),
            contains_string(constants.success_message))
        check_that(
            "Product name reflected on displayed module page",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.PRODUCT_INFO_CSS),
            contains_string(constants.product_name))
        check_that(
            "Product version reflected on displayed module page",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.PRODUCT_INFO_CSS),
            contains_string(constants.product_version))
        utilities.wait(2)

    @lcc.test("Verify that user is able to publish assembly successfully")
    def publish_assembly(self):
        utilities.wait(5)
        utilities.click_element(self.driver, By.ID,
                                locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID)
        check_that(
            "Button",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS),
            contains_string("Preview"))
        check_that(
            "Button",
            utilities.get_text(self.driver, By.ID,
                               locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID),
            contains_string("Unpublish"))
        # Add a check that the Published column contains some Published time.

    @lcc.test("Verify contents of assembly preview in pantheon")
    # 1. Verify assembly title is displayed as expected
    # 2. Verify product name is displayed as expected
    # 3. Verify product version is displayed as expected
    # 4. Verify image path is resolved and contains expected value
    # 5. Verify all included modules are displayed in assembly preview
    def preview_assembly(self):
        test_repo_name = base.config_reader('test_repo', 'repo_name')
        try:
            # Get list of modules included
            modules_included = utilities.find_elements_by_css_selector(
                self.driver, locators.MODULES_INCLUDED_LIST_CSS)
            test_view_assembly.modules_count = len(modules_included)
            for i in range(test_view_assembly.modules_count):
                test_view_assembly.module_titles.append(
                    modules_included[i].text)
            utilities.click_element(self.driver, By.CSS_SELECTOR,
                                    locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS)
            utilities.wait(5)
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(7)
            assembly_title = utilities.find_shadow_dom_element(
                self.driver, locators.DOCUMENT_TITLE,
                locators.MODULE_BODY_CONTENT_CSS).text
            print(assembly_title)
            check_that("Assembly title", constants.assembly_to_be_published,
                       contains_string(assembly_title))
            product_name = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_NAME_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text
            print(product_name)
            check_that("Product name reflected on view page", product_name,
                       contains_string(constants.product_name))
            product_version = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_VERSION_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text
            print(product_version)
            check_that("Product version reflected on view page",
                       product_version,
                       contains_string(constants.product_version))
            image = utilities.find_shadow_dom_element(
                self.driver, locators.IMAGE_CSS,
                locators.MODULE_BODY_CONTENT_CSS)
            src = image.get_attribute("src")
            imageasset = urlparse(src)
            imageasset = imageasset.path.split("/")[2]
            cmd = "echo " + imageasset + "|base64 -d"
            try:
                # subprocess.check_call(cmd, shell=True)
                path = subprocess.getoutput(cmd)
                print("Image file path::", path)
                image_file = "/content/repositories/" + test_repo_name + "/entities/enterprise/assemblies/images/" + constants.image_file_name
                check_that("Path to image1", path, equal_to(image_file))
            except subprocess.CalledProcessError as e:
                lcc.log_info("Unable to decode imageasset")

            assembly_body = utilities.get_text(
                self.driver, By.CSS_SELECTOR,
                locators.ASSEMBLY_BODY_PREVIEW_CSS)
            for i in range(test_view_assembly.modules_count):
                check_that(
                    "Assembly body", assembly_body,
                    contains_string(test_view_assembly.module_titles[i]))

        except Exception as e:
            lcc.log_error(e)

        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    @lcc.test("Verify contents of assembly on CP")
    def view_assembly_on_cp(self):
        test_repo_name = base.config_reader('test_repo', 'repo_name')
        try:
            utilities.page_reload(self.driver)
            utilities.click_element(self.driver, By.CSS_SELECTOR,
                                    locators.VIEW_ON_PORTAL_LINK_CSS)
            utilities.wait(5)
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(7)
            check_that(
                "URL portal is", self.driver.current_url,
                contains_string(
                    "https://access.qa.redhat.com/documentation/en-us/" +
                    constants.product_name_uri + "/" +
                    constants.product_version + "/guide/"))

            assembly_title = utilities.find_shadow_dom_element(
                self.driver, locators.DOCUMENT_TITLE_CP,
                locators.MODULE_BODY_ON_PORTAL_CSS).text
            check_that("Assembly title", assembly_title,
                       contains_string(constants.assembly_to_be_published))
            product_name = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_NAME_ON_PREVIEW_CSS,
                locators.MODULE_BODY_ON_PORTAL_CSS).text
            check_that("Product name reflected on view page", product_name,
                       contains_string(constants.product_name))
            product_version = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_VERSION_ON_PREVIEW_CSS,
                locators.MODULE_BODY_ON_PORTAL_CSS).text
            check_that("Product version reflected on view page",
                       product_version,
                       contains_string(constants.product_version))
            image = utilities.find_shadow_dom_element(
                self.driver, locators.IMAGE_CSS,
                locators.MODULE_BODY_ON_PORTAL_CSS)
            src = image.get_attribute("src")
            imageasset = urlparse(src)
            imageasset = imageasset.path.split("/")[2]
            cmd = "echo " + imageasset + "|base64 -d"
            try:
                # subprocess.check_call(cmd, shell=True)
                path = subprocess.getoutput(cmd)
                print("Image file path::", path)
                image_file = "/content/repositories/" + test_repo_name + "/entities/enterprise/assemblies/images/" + constants.image_file_name
                check_that("Path to image1", path, equal_to(image_file))
            except subprocess.CalledProcessError as e:
                lcc.log_info("Unable to decode imageasset")

            assembly_body = utilities.get_text(
                self.driver, By.CSS_SELECTOR,
                locators.ASSEMBLY_BODY_PREVIEW_CSS)
            for i in range(test_view_assembly.modules_count):
                check_that(
                    "Assembly body", assembly_body,
                    contains_string(test_view_assembly.module_titles[i]))

            guides_content_related = utilities.find_shadow_dom_element(
                self.driver, locators.CONTENT_RELATED_TO_GUIDES,
                locators.MODULE_BODY_ON_PORTAL_CSS)
            self.driver.execute_script("arguments[0].scrollIntoView();",
                                       guides_content_related)
            utilities.wait(20)
            check_that("Content related to this guide setcion",
                       guides_content_related.is_displayed(), equal_to(True))
            # utilities.click_element(self.driver, By.XPATH, "//summary[text()='Content related to this guide']")
            additional_res_guide = utilities.find_shadow_dom_element(
                self.driver, locators.CONTENT_RELATED_GUIDES_RESOURCES,
                locators.MODULE_BODY_ON_PORTAL_CSS)
            check_that(
                "Content related to this guide setcion to contain Addtional resources setion",
                additional_res_guide.is_displayed(), equal_to(True))

        except Exception as e:
            lcc.log_error(e)

        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)

    def teardown_suite(self):
        response = unpublish_module(self, constants.assembly_to_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code", response.status_code,
                   equal_to(200))
        lcc.log_info(
            "Assembly published for above test is unpublished successfully..")
class test_search_and_filter(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    @lcc.test('Verify that search results are as expected')
    @lcc.disabled()
    def search_for_module(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        utilities.wait(2)
        utilities.enter_text(self.driver, By.ID, locators.SEARCH_BOX_ID,
                             constants.module_to_search)
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.SEARCH_BUTTON_CSS)
        utilities.wait(3)
        check_that(
            "module is found on search page",
            utilities.get_text(self.driver, By.XPATH,
                               locators.SEARCH_MODULE_XPATH),
            contains_string(constants.module_to_search))

    @lcc.test(
        "Verify that warning should be displayed when module is not found")
    @lcc.disabled()
    def search_for_random_text(self):
        utilities.find_elements_by_id(self.driver,
                                      locators.SEARCH_BOX_ID).clear()
        utilities.enter_text(self.driver, By.ID, locators.SEARCH_BOX_ID,
                             constants.random_string_search)
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.SEARCH_BUTTON_CSS)
        utilities.wait(2)
        check_that(
            "warning alert displayed",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.ALERT_TITLE_CSS),
            contains_string(constants.no_module_found))
        utilities.click_element(self.driver, By.XPATH,
                                locators.CANCEL_BUTTON_XPATH)
        utilities.wait(2)

    @lcc.test(
        "verify that the search results for asian characters such as '安装术语' should give accurate results."
    )
    @lcc.disabled()
    def search_for_module_with_asian_chars(self):
        utilities.find_elements_by_id(self.driver,
                                      locators.SEARCH_BOX_ID).clear()
        utilities.enter_text(self.driver, By.ID, locators.SEARCH_BOX_ID,
                             constants.asian_char_module)
        # module will be searchable once CCS-3754 is fixed
        # verifying warning alert as of now
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.SEARCH_BUTTON_CSS)
        utilities.wait(2)
        check_that(
            "module with asian character should be found once CCS-3754 is fixed, checking for warning alert as of now..",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.ALERT_TITLE_CSS),
            contains_string(constants.no_module_found))
        utilities.click_element(self.driver, By.XPATH,
                                locators.CANCEL_BUTTON_XPATH)
        utilities.wait(2)

    @lcc.test("Verify search results from body of the module")
    @lcc.disabled()
    def search_for_body_of_module(self):
        try:
            utilities.find_elements_by_id(self.driver,
                                          locators.SEARCH_BOX_ID).clear()
            utilities.enter_text(self.driver, By.ID, locators.SEARCH_BOX_ID,
                                 constants.body_of_module_search)
            utilities.click_element(self.driver, By.CSS_SELECTOR,
                                    locators.SEARCH_BUTTON_CSS)
            utilities.wait(2)
            utilities.click_element(self.driver, By.XPATH,
                                    locators.SEARCH_MODULE_XPATH)
            utilities.wait(2)
            utilities.click_element(self.driver, By.CSS_SELECTOR,
                                    locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS)
            utilities.wait(2)
            utilities.switch_to_latest_tab(self.driver)
            body_of_module_on_preview = utilities.find_shadow_dom_element(
                self.driver, locators.SEARCH_BODY_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CSS).text
            check_that("content of module is displayed",
                       body_of_module_on_preview,
                       contains_string(constants.body_of_module_search))
            utilities.wait(2)
        except (TimeoutException, StaleElementReferenceException,
                NoSuchElementException) as e:
            lcc.log_error("Error finding element: %s" % e)
            lcc.log_error(e)
        finally:
            self.driver.close()
            utilities.switch_to_first_tab(self.driver)

    @lcc.test("Verify that product and version filter works as expected")
    @lcc.disabled()
    def select_product_and_version_filter(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.wait(2)
        utilities.select_value_from_dropdown(self.driver, By.CSS_SELECTOR,
                                             locators.SELECT_PRODUCT_NAME_CSS,
                                             constants.product_name)
        utilities.select_value_from_dropdown(
            self.driver, By.CSS_SELECTOR, locators.SELECT_PRODUCT_VERSION_CSS,
            constants.product_version)
        lcc.log_info(
            "product and version selected and displayed on search page")
        utilities.find_element(
            self.driver, By.XPATH,
            locators.PRODUCT_FILTER_DISPLAY_XPATH).is_displayed()
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.SEARCH_BUTTON_CSS)
        utilities.wait(2)
        utilities.click_element(self.driver, By.XPATH,
                                locators.SEARCH_MODULE_XPATH)
        utilities.wait(2)
        check_that(
            "verify that 'filter by product and version' functionality filters results correctly",
            utilities.get_text(self.driver, By.XPATH,
                               locators.PRODUCT_VERSION_DISPLAY_PAGE_XPATH),
            contains_string(constants.product_name + " " +
                            constants.product_version))

    @lcc.test(
        "Verify that 'Filter by content Type': Assembly functionality filters results correctly"
    )
    @lcc.disabled()
    def select_content_type_filter(self):
        verify_filter_by_content_type(self.driver, "Assembly")
class test_create_product(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    @lcc.test('Verify that Warning is displayed when no product name is being entered')
    def create_product_blank_name(self):
        utilities.click_element(self.driver, By.XPATH, locators.MENU_PRODUCTS_LINK_XPATH)
        utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_NEW_PRODUCT_LINK_TEXT)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS)
        check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.blank_product_name_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)

    @lcc.test("Verify that Warning is displayed when no url fragment is entered")
    def create_product_blank_url_fragment(self):
        # utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_PRODUCTS_LINK_TEXT)
        # utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_NEW_PRODUCT_LINK_TEXT)
        lcc.log_info("Product name input: %s " % product_name)
        # Reload new product to clear old values
        utilities.page_reload(self.driver)
        utilities.wait(3)
        # Fill new product form
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_NAME_TEXTBOX_ID, product_name)
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_VERSION_URL_FRAGMENT_ID, constants.product_version)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_DESCRIPTION_TEXTBOX_ID,
                             constants.new_product_description)
        utilities.find_element(self.driver, By.ID, locators.PRODUCT_URL_FRAGMENT_TEXTBOX_ID).clear()

        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS)
        check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.blank_product_name_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)

    @lcc.test("Verify that Warning is displayed when version is not entered")
    def create_product_blank_version(self):
        # utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_NEW_PRODUCT_LINK_TEXT)
        lcc.log_info("Product name input: %s " % product_name)
        # Reload new product to clear old values
        utilities.page_reload(self.driver)
        utilities.wait(3)
        # Fill new product form
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_NAME_TEXTBOX_ID, product_name)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_URL_FRAGMENT_TEXTBOX_ID, constants.url_fragment)
        utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_VERSION_URL_FRAGMENT_ID, constants.product_version)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_DESCRIPTION_TEXTBOX_ID, constants.new_product_description)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS)
        check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.blank_product_name_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)


    @lcc.test("Verify that the product is created successfully and listed in the Products list")
    def create_product(self):
        # utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_NEW_PRODUCT_LINK_TEXT)
        lcc.log_info("Product name input: %s " % product_name)
        # Reload new product page to clear old values
        utilities.page_reload(self.driver)
        # Fill new product form
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_NAME_TEXTBOX_ID, product_name)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_URL_FRAGMENT_TEXTBOX_ID, constants.url_fragment)
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_VERSION_URL_FRAGMENT_ID, constants.product_version)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_DESCRIPTION_TEXTBOX_ID,
                             constants.new_product_description)
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS)
        utilities.wait(5)
        products = utilities.find_elements_by_css_selector(self.driver, locators.PRODUCT_NAME_LIST_CSS)
        lcc.log_info(str(len(products)))
        products_list = []
        for product in products:
            products_list.append(product.text)
        check_that("Product created is listed successfully", products_list, has_item(product_name), quiet=False)

    @lcc.test("Verify that user is unable to create duplicate product names, Warning is displayed")
    def duplicate_product_name(self):
        # Navigate to New product page from Product listing page
        utilities.click_element(self.driver, By.XPATH, locators.MENU_PRODUCTS_LINK_XPATH)
        utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_NEW_PRODUCT_LINK_TEXT)
        lcc.log_info("Product name input: %s " % product_name)
        # Reload new product page to clear old values
        utilities.page_reload(self.driver)
        # Fill new product form
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_NAME_TEXTBOX_ID, product_name)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_URL_FRAGMENT_TEXTBOX_ID, constants.url_fragment)
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_VERSION_URL_FRAGMENT_ID, constants.product_version)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_DESCRIPTION_TEXTBOX_ID,
                             constants.new_product_description)
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS)
        check_that("Duplicate Product warning is displayed",
                   utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.duplicate_product_name_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)

    @lcc.test("Verify that user is unable to create duplicate product names with different version, Warning is displayed")
    def duplicate_product_name_different_version(self):
        # utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_NEW_PRODUCT_LINK_TEXT)
        lcc.log_info("Product name input: %s " % product_name)
        # Reload new product page to clear old values
        utilities.page_reload(self.driver)
        # Fill new product form
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_NAME_TEXTBOX_ID, product_name)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_URL_FRAGMENT_TEXTBOX_ID, constants.url_fragment)
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_2)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_VERSION_URL_FRAGMENT_ID, constants.product_version_url_fragment_2)
        utilities.enter_text(self.driver, By.ID, locators.PRODUCT_DESCRIPTION_TEXTBOX_ID,
                             constants.new_product_description)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS)
        check_that("Duplicate Product warning is displayed",
                   utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.duplicate_product_name_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)

    @lcc.test("Verify that blank product gives error message")
    def blank_product_versions(self):
        utilities.click_element(self.driver, By.XPATH, locators.MENU_PRODUCTS_LINK_XPATH)
        utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_PRODUCT_LISTING_LINK_TEXT)
        # User clicks on 'Product details' button for the product created above.
        lcc.log_info("Product name to add versions for: %s " % product_name)
        utilities.wait(10)
        products = utilities.find_elements_by_class_name(self.driver, locators.PRODUCT_NAMES_LIST_CLASS_NAME)
        lcc.log_info("Number of products found in the list %s" % str(len(products)))
        for product in products:
            if product_name in product.text:
                lcc.log_info("Adding versions to %s" % product.text)
                product.find_element_by_class_name("pf-c-options-menu").click()
                lcc.log_info("Clicking on the dropdown to add product details")
                product.find_element_by_class_name(locators.PRODUCT_DETAILS_BUTTON_CLASS_NAME).click()
                break

        #Verify blank product version and url fragment
        utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
        utilities.find_element(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID).clear()
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
        check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.blank_product_name_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)

    @lcc.test("Verify that invalid product version url_fragment gives error")
    def invalid_product_version_url_fragment(self):
        #Verify invalid input for url fragment
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_1)
        utilities.enter_text(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID, "#")
        check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.version_url_fragment_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)
        utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()

    @lcc.test("Verify that user is able to create versions of the above product")
    def create_product_versions(self):
        # User adds versions to the 'Add Product versions' and verifies if the versions were added successfully.
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_1)
        utilities.enter_text(self.driver,By.ID,locators.VERSION_URL_FRAGMENT_ID,
                             constants.product_version_url_fragment_1)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
        utilities.wait(3)
        utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_2)
        utilities.enter_text(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID,
                             constants.product_version_url_fragment_2)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
        utilities.wait(3)
        utilities.find_element(self.driver, By.ID,locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
        utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_3)
        utilities.enter_text(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID,
                             constants.product_version_url_fragment_3)
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
        utilities.wait(3)
        utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
        versions_ul = utilities.find_element(self.driver, By.CLASS_NAME, locators.PRODUCT_VERSIONS_UL_CLASS_NAME)
        versions_list = versions_ul.find_elements_by_tag_name(locators.PRODUCT_VERSIONS_LI_TAG_NAME)
        versions = []
        for version in versions_list:
            versions.append(version.text)
        lcc.log_info("Versions added: %s" % str(versions))
        check_that("Product version entered is added successfully ", versions, has_item(constants.product_version_1))
        check_that("Product version entered is added successfully ", versions, has_item(constants.product_version_2))
        check_that("Product version entered is added successfully ", versions, has_item(constants.product_version_3))

    def teardown_suite(self):
        lcc.log_info("Deleting the product created above...")
        product_name_node = product_name.replace(" ", "_").lower()
        path_to_product_node = url + "content/products/" + product_name_node
        lcc.log_info("Test Product node being deleted at: %s" % path_to_product_node)
        body = {":operation": "delete"}
        response = requests.post(path_to_product_node, data=body, auth=(fixture.admin_username, fixture.admin_auth))
        check_that("The Product created was deleted successfully",
                   response.status_code, equal_to(200))
Ejemplo n.º 20
0
    class MySuite:
        fxt = lcc.inject_fixture("fixt1")

        @lcc.test("sometest")
        def sometest(self):
            marker.append(self.fxt)
class test_search_beta(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    repo_name = base.config_reader('test_repo', 'repo_name')
    module_prefix = base.config_reader('test_repo', 'module_prefix')
    assembly_prefix = base.config_reader('test_repo', 'assembly_prefix')

    @lcc.test(
        "Verify that main filter toggle, filter by Repository toggle view works as expected; "
        "warning error msg is displayed when no repo is selected ")
    def no_repo_selected(self):
        utilities.wait(2)
        utilities.click_element(self.driver, By.LINK_TEXT,
                                locators.MENU_SEARCH_PAGE_LINK_TEXT)
        utilities.page_reload(self.driver)
        utilities.wait(1)
        # clicking on filter funnel icon twice to close and re-open the filter by repo pannel
        utilities.click_element(self.driver, By.ID, locators.TOGGLE_ID)
        utilities.wait(1)
        utilities.click_element(self.driver, By.ID, locators.TOGGLE_ID)
        utilities.wait(1)
        check_that(
            "Filter by repo section is displayed",
            utilities.find_element(
                self.driver, By.CLASS_NAME,
                locators.FILTER_BY_REPO_SECTION_CLASS_NAME).is_displayed(),
            is_true())
        check_that(
            "No results found warning message",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.NO_MODULE_RESULTS_FOUND_CSS),
            contains_string(constants.no_results_found))
        utilities.click_element(self.driver, By.XPATH,
                                locators.FILTER_BY_REPO_TOGGLE_XPATH)
        utilities.wait(1)
        utilities.click_element(self.driver, By.XPATH,
                                locators.FILTER_BY_REPO_TOGGLE_XPATH)
        utilities.wait(1)
        check_that(
            "Repository list is displayed after expanding Filter by Repo",
            utilities.find_element(self.driver, By.XPATH,
                                   locators.REPO_LIST_XPATH).is_displayed(),
            is_true())

    @lcc.test(
        "Verify that user is able to see results when he uses Filter by Repository search bar"
    )
    def search_for_repo(self):
        utilities.enter_text(self.driver, By.XPATH,
                             locators.FILTER_BY_REPO_SEARCH_BAR_XPATH,
                             self.repo_name)
        utilities.wait(1)
        repo_list = utilities.find_elements_by_css_selector(
            self.driver, locators.REPOSITORY_CHECKBOX_CSS)
        repo_list_count = len(repo_list)
        for i in range(repo_list_count):
            if repo_list[i].text == self.repo_name:
                check_that("Entered repo name is displayed on search results",
                           repo_list[i].text, equal_to(self.repo_name))
        utilities.click_element(
            self.driver, By.CLASS_NAME,
            locators.CANCEL_BUTTON_ON_REPO_SEARCH_BAR_CLASS_NAME)
        utilities.wait(1)

    @lcc.test(
        "Verify user is able to select a repo; Module and Assemblies section has content displayed and toggles."
    )
    def select_repo_filter(self):
        search_beta_page.select_repo(self.driver, self.repo_name)
        utilities.wait(1)
        utilities.find_element(self.driver, By.CSS_SELECTOR,
                               locators.REPOSITORY_CHECKBOX_CSS).is_selected()
        check_that(
            "Repository name displayed correctly on right side panel",
            utilities.get_text(self.driver, By.XPATH,
                               locators.REPOSITORY_NAME_XPATH),
            equal_to(self.repo_name))
        check_that(
            "Modules section has data displayed for selected repo",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.MODULES_CSS).is_displayed(),
            is_true())
        check_that(
            "Assemblies section has data displayed for selected repo",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.ASSEMBLY_CSS).is_displayed(),
            is_true())

        utilities.click_element(self.driver, By.XPATH,
                                locators.MODULES_TOGGLE_BUTTON_XPATH)
        utilities.wait(1)
        check_that(
            "Modules section is collapsible",
            utilities.find_element(
                self.driver, By.XPATH,
                locators.MODULE_ASSEMBLY_TOGGLE_XPATH).is_displayed(),
            is_true())
        utilities.click_element(self.driver, By.XPATH,
                                locators.MODULES_TOGGLE_BUTTON_XPATH)
        utilities.wait(1)
        utilities.click_element(self.driver, By.XPATH,
                                locators.ASSEMBLY_TOGGLE_BUTTON_XPATH)
        utilities.wait(1)
        check_that(
            "Assemblies section is collapsible",
            utilities.find_element(
                self.driver, By.XPATH,
                locators.MODULE_ASSEMBLY_TOGGLE_XPATH).is_displayed(),
            is_true())
        utilities.wait(1)
        utilities.click_element(self.driver, By.XPATH,
                                locators.ASSEMBLY_TOGGLE_BUTTON_XPATH)

    @lcc.test("Verify that modules and assemblies are listed for selected repo"
              )
    def modules_assemblies_list(self):
        utilities.wait(1)
        module_title_list = utilities.find_elements_by_css_selector(
            self.driver, locators.MODULE_TITLES_CSS)
        modules_count = len(module_title_list)
        modules = modules_count - 1
        lcc.log_info("Modules displayed: %s " % str(modules))
        for i in range(1, modules_count):
            check_that("Modules listed for selected repo",
                       module_title_list[i].text,
                       contains_string(self.module_prefix))
        assembly_title_list = utilities.find_elements_by_css_selector(
            self.driver, locators.ASSEMBLY_TITLES_CSS)
        assembly_count = len(assembly_title_list)
        assemblies = assembly_count - 1
        lcc.log_info("Assemblies displayed: %s" % str(assemblies))
        for i in range(1, assembly_count):
            check_that("Assemblies listed for selected repo",
                       assembly_title_list[i].text,
                       contains_string(self.assembly_prefix))
        lcc.log_info(
            "Find the Search beta page preview in the attachment below:")
        self.driver.save_screenshot("search_beta_repo_selected.png")
        lcc.save_attachment_file("search_beta_repo_selected.png")

    @lcc.test("Verify Status and Content Type filter on search page")
    def filters_on_search_page(self):
        utilities.click_element(self.driver, By.CLASS_NAME,
                                locators.STATUS_FILTER_CLASS_NAME)
        utilities.click_element(self.driver, By.CLASS_NAME,
                                locators.DRAFT_STATUS_CLASS_NAME)
        check_that(
            "Draft Status filter chip is displayed on search page",
            utilities.find_element(
                self.driver, By.CLASS_NAME,
                locators.STATUS_TOOLBAR_CHIP_CLASS_NAME).is_displayed(),
            is_true())
        last_published_date_list = utilities.find_elements_by_XPATH(
            self.driver, locators.LAST_PUBLISHED_DATE_XPATH)
        published_date_list = []
        for i in last_published_date_list:
            published_date_list.append(i.text)
        for i in published_date_list:
            check_that(
                "Published date for all titles should be '-' when draft status filter is selected",
                i, contains_string("-"))
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.CLEAR_ALL_FILTER_CSS)
        utilities.wait(1)
        search_beta_page.search_module_and_click(self.driver,
                                                 constants.publish_module)
        utilities.wait(1)
        display_module_page.add_metadata_and_publish(self.driver)
        utilities.wait(2)
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        search_beta_page.select_repo(self.driver, self.repo_name)
        utilities.wait(2)
        utilities.click_element(self.driver, By.CLASS_NAME,
                                locators.STATUS_FILTER_CLASS_NAME)
        utilities.click_element(self.driver, By.CLASS_NAME,
                                locators.PUBLISHED_STATUS_CLASS_NAME)
        utilities.wait(2)
        check_that(
            "Published module is filtered",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.FIRST_MODULE_LISTED_CSS),
            contains_string(constants.publish_module))
        check_that(
            "Green check is displayed for published module",
            utilities.find_element(
                self.driver, By.CLASS_NAME,
                locators.GREEN_CHECK_CLASS_NAME).is_displayed(), is_true())
        utilities.wait(3)
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.CLEAR_ALL_FILTER_CSS)
        utilities.wait(1)
        utilities.click_element(self.driver, By.CLASS_NAME,
                                locators.CONTENT_TYPE_CLASS_NAME)
        utilities.click_element(
            self.driver, By.CLASS_NAME,
            locators.CONCEPT_CONTENT_TYPE_FILTER_CLASS_NAME)
        check_that(
            "Content Type filter chip is displayed on search page",
            utilities.find_element(
                self.driver, By.CLASS_NAME,
                locators.STATUS_TOOLBAR_CHIP_CLASS_NAME).is_displayed(),
            is_true())
        utilities.wait(3)
        check_that(
            "'Concept' content type filter is selected",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.FIRST_MODULE_LISTED_CSS),
            contains_string("Concept"))
        utilities.wait(1)
        utilities.click_element(
            self.driver, By.CLASS_NAME,
            locators.CONCEPT_CONTENT_TYPE_FILTER_CLASS_NAME)
        utilities.click_element(
            self.driver, By.CLASS_NAME,
            locators.PROCEDURE_CONTENT_TYPE_FILTER_CLASS_NAME)
        utilities.wait(3)
        check_that(
            "'Procedure' content type filter is selected",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.FIRST_MODULE_LISTED_CSS),
            contains_string("Procedure"))
        utilities.wait(1)
        utilities.click_element(
            self.driver, By.CLASS_NAME,
            locators.PROCEDURE_CONTENT_TYPE_FILTER_CLASS_NAME)
        utilities.click_element(
            self.driver, By.CLASS_NAME,
            locators.REFERENCE_CONTENT_TYPE_FILTER_CLASS_NAME)
        utilities.wait(3)
        check_that(
            "'Reference' content type filter is selected",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.FIRST_MODULE_LISTED_CSS),
            contains_string("Reference"))
        utilities.wait(2)

    def teardown_suite(self):
        response = unpublish_module(self, constants.search_module_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code", response.status_code,
                   equal_to(200))
        lcc.log_info(
            "module published for above test is unpublished successfully..")
Ejemplo n.º 22
0
 class Suite:
     foo = lcc.inject_fixture()
class test_module_type(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    @lcc.test(
        "Verify that 'Filter by Module Type': CONCEPT functionality filters results correctly"
    )
    def verify_filter_by_content_type_concept(self):
        verify_filter_by_content_type(self.driver, "Concept")

    @lcc.test(
        "Verify module type: CONCEPT is shown correctly when added as filename 'con_file.adoc' verified using the api"
    )
    @lcc.depends_on("test_module_type.verify_filter_by_content_type_concept")
    def verify_module_type_from_backend_module_type_in_filename_con(self):
        open_module_display_page(self.driver, constants.con_module_title)
        verify_module_type_from_backend(self.driver, "Concept")

    @lcc.test(
        "Verify module type: CONCEPT appears as in on UI when module type is added as filename 'con_file.adoc'"
    )
    @lcc.depends_on(
        "test_module_type.verify_module_type_from_backend_module_type_in_filename_con"
    )
    def verify_module_type_from_ui_module_type_in_filename_con(self):
        verify_module_type_from_UI(self.driver, "Concept")

    @lcc.test(
        "Verify module type: CONCEPT does not disappear from the UI after the module is published."
    )
    @lcc.depends_on(
        "test_module_type.verify_module_type_from_backend_module_type_in_filename_con"
    )
    def verify_module_type_after_publising_con(self):
        verify_module_type_after_publishing(self.driver, "Concept")

    @lcc.test(
        "Verify module type: CONCEPT shows correctly when mentioned inside asccidoc file as ':pantheon-module-type: CONCEPT'"
    )
    def verify_module_type_from_backend_module_type_inside_file_con(self):
        utilities.click_element(self.driver, By.LINK_TEXT,
                                locators.MENU_SEARCH_PAGE_LINK_TEXT)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.filter_by_content_type(self.driver, "Concept")
        # search_page.filter_by_module_type(self.driver, "Concept")
        open_module_display_page(self.driver, constants.con_module_title1)
        verify_module_type_from_backend(self.driver, "Concept")

    @lcc.test(
        "Verify that 'Filter by Module Type': PROCEDURE functionality filters results correctly"
    )
    def verify_filter_by_content_type_procedure(self):
        verify_filter_by_content_type(self.driver, "Procedure")

    @lcc.test(
        "Verify module type: PROCEDURE is shown correctly when added as filename 'proc_file.adoc' verified using the api"
    )
    @lcc.depends_on("test_module_type.verify_filter_by_content_type_procedure")
    def verify_module_type_from_backend_module_type_in_filename_proc(self):
        open_module_display_page(self.driver, constants.proc_module_title)
        verify_module_type_from_backend(self.driver, "Procedure")

    @lcc.test(
        "Verify module type: PROCEDURE appears as in on UI when module type is added as filename 'proc_file.adoc'"
    )
    @lcc.depends_on(
        "test_module_type.verify_module_type_from_backend_module_type_in_filename_proc"
    )
    def verify_module_type_from_ui_module_type_in_filename_proc(self):
        verify_module_type_from_UI(self.driver, "Procedure")

    @lcc.test(
        "Verify module type: PROCEDURE does not disappear from the UI after the module is published."
    )
    @lcc.depends_on(
        "test_module_type.verify_module_type_from_backend_module_type_in_filename_proc"
    )
    def verify_module_type_after_publising_proc(self):
        verify_module_type_after_publishing(self.driver, "Procedure")

    @lcc.test(
        "Verify module type: PROCEDURE shows correctly when mentioned inside asccidoc file as ':pantheon-module-type: PROCEDURE'"
    )
    def verify_module_type_from_backend_module_type_inside_file_proc(self):
        utilities.click_element(self.driver, By.LINK_TEXT,
                                locators.MENU_SEARCH_PAGE_LINK_TEXT)
        # search_page.filter_by_module_type(self.driver, "Procedure")
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.filter_by_content_type(self.driver, "Procedure")
        open_module_display_page(self.driver, constants.proc_module_title1)
        verify_module_type_from_backend(self.driver, "Procedure")

    @lcc.test(
        "Verify that 'Filter by Module Type': REFERENCE functionality filters results correctly"
    )
    def verify_filter_by_content_type_reference(self):
        verify_filter_by_content_type(self.driver, "Reference")

    @lcc.test(
        "Verify module type: REFERENCE is shown correctly when added as filename 'ref_file.adoc' verified using the api"
    )
    @lcc.depends_on("test_module_type.verify_filter_by_content_type_reference")
    def verify_module_type_from_backend_module_type_in_filename_ref(self):
        open_module_display_page(self.driver, constants.ref_module_title)
        verify_module_type_from_backend(self.driver, "Reference")

    @lcc.test(
        "Verify module type: REFERENCE appears as in on UI when module type is added as filename 'ref_file.adoc'"
    )
    @lcc.depends_on(
        "test_module_type.verify_module_type_from_backend_module_type_in_filename_ref"
    )
    def verify_module_type_from_ui_module_type_in_filename_ref(self):
        verify_module_type_from_UI(self.driver, "Reference")

    @lcc.test(
        "Verify module type: REFERENCE does not disappear from the UI after the module is published."
    )
    @lcc.depends_on(
        "test_module_type.verify_module_type_from_backend_module_type_in_filename_ref"
    )
    def verify_module_type_after_publising_ref(self):
        verify_module_type_after_publishing(self.driver, "Reference")

    @lcc.test(
        "Verify module type: REFERENCE shows correctly when mentioned inside asccidoc file as ':pantheon-module-type: REFERENCE'"
    )
    def verify_module_type_from_backend_module_type_inside_file_ref(self):
        utilities.click_element(self.driver, By.LINK_TEXT,
                                locators.MENU_SEARCH_PAGE_LINK_TEXT)
        # search_page.filter_by_module_type(self.driver, "Reference")
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.filter_by_content_type(self.driver, "Reference")
        open_module_display_page(self.driver, constants.ref_module_title1)
        verify_module_type_from_backend(self.driver, "Reference")

    @lcc.test("Verify module with invalid type defined")
    def verify_no_module_type(self):
        utilities.click_element(self.driver, By.LINK_TEXT,
                                locators.MENU_SEARCH_PAGE_LINK_TEXT)
        utilities.page_reload(self.driver)
        # try:
        #     search_page.search_for_module_and_click(self.driver, constants.no_module_type_title)
        # except (TimeoutException, StaleElementReferenceException) as e:
        #     lcc.log_error("Module not listed on listed in the results after applying module type filter.")
        #     utilities.wait(2)
        #     search_page.search_for_module_and_click(self.driver, constants.no_module_type_title)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.no_module_type_title)
        lcc.log_info(
            "Verifying no module type is displayed for modules with invalid type mentioned inside "
            "the asciidoc file")
        # Once landed on the module display page, get path to adoc from the module display page url
        path_to_adoc_file = display_module_page.get_path_to_adoc(self.driver)
        path = path_to_adoc_file + constants.path_for_module_type
        response = requests.get(url=url + path,
                                auth=(fixture.username, fixture.api_auth))
        check_that("Module type node in backend", response.status_code,
                   equal_to(404))

    def teardown_suite(self):
        response = unpublish_module(self, constants.proc_module_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code", response.status_code,
                   equal_to(200))
        lcc.log_info(
            "Module published for module_type:PROCEDURE test is unpublished successfully.."
        )

        response = unpublish_module(self, constants.ref_module_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code", response.status_code,
                   equal_to(200))
        lcc.log_info(
            "Module published for module_type:REFERENCE test is unpublished successfully.."
        )

        response = unpublish_module(self, constants.con_module_unpublish,
                                    constants.variant)
        check_that("Unpublish request status code", response.status_code,
                   equal_to(200))
        lcc.log_info(
            "Module published for module_type:CONCEPT test is unpublished successfully.."
        )
Ejemplo n.º 24
0
class test_sitemap:
    api_auth = lcc.inject_fixture("api_auth")
    now = datetime.now(timezone.utc)
    # now_hour = int(datetime.now(timezone.utc).hour)
    # now_hour_plus_one = now_hour + 1
    # now_min = int(datetime.now(timezone.utc).minute)
    # now_min_minus_ten = now_min - 15
    # now_min_plus_ten = now_min + 15
    # if(now_min_plus_ten >= 60):
    #     now_min_plus_ten = now_min_plus_ten-60
    # if(now_min_minus_ten < 0):
    #     now_min_minus_ten = 0
    #
    # def check_time_range(time_read):
    range = now + timedelta(minutes=15)

    def setup_suite(self, setup_test_products, api_auth):
        lcc.log_info(
            "Setup: Adding metadata and publishing module, assembly to test the sitemap endpoint..."
        )
        lcc.log_info("Adding metadata, publishing the assembly first...")
        assembly_title_prefix = base.config_reader('test_repo',
                                                   'assembly_prefix')
        self.variant = utilities.read_variant_name_from_pantheon2config()

        self.assembly_path = utilities.select_nth_item_from_search_results(
            1, fixture.url, assembly_title_prefix, api_auth)
        lcc.log_info("Assembly path for tests: %s" % self.assembly_path)
        # Add metadata to the assembly
        res, self.product_name_uri = utilities.add_metadata(
            fixture.url,
            self.assembly_path,
            self.variant,
            self.api_auth,
            setup_test_products,
            content_type="assembly")
        # Publish the assembly
        publish_response = utilities.publish_content(fixture.url,
                                                     self.assembly_path,
                                                     self.variant,
                                                     self.api_auth)
        check_that("Publish Assembly response status ",
                   publish_response.status_code, equal_to(200))

        # Verify if the assembly was marked released
        response = api_auth.get(fixture.url + self.assembly_path +
                                "/en_US/variants/" + self.variant + ".10.json")
        check_that("Assembly was published", response.json(),
                   has_entry("released"))
        self.assembly_uuid = response.json()["jcr:uuid"]
        lcc.log_info("Assembly published uuid: %s" % self.assembly_uuid)

        lcc.log_info("Publishing a module now...")
        module_title_prefix = base.config_reader('test_repo', 'module_prefix')
        self.module_path = utilities.select_nth_item_from_search_results(
            0, fixture.url, module_title_prefix, api_auth)
        print(self.module_path)
        # Add metadat to module
        module_res, self.product_name_uri = utilities.add_metadata(
            fixture.url,
            self.module_path,
            self.variant,
            self.api_auth,
            setup_test_products,
            content_type="module")
        # Publish the module
        m_publish_response = utilities.publish_content(fixture.url,
                                                       self.module_path,
                                                       self.variant,
                                                       self.api_auth)
        # Verify if the module was marked released
        module_response = api_auth.get(fixture.url + self.module_path +
                                       "/en_US/variants/" + self.variant +
                                       ".10.json")
        check_that("Document published", module_response.json(),
                   has_entry("released"))
        self.module_uuid = module_response.json()["jcr:uuid"]
        lcc.log_info("Module published uuid: %s " % self.module_uuid)

    @lcc.test(
        "Verify api endpoint for assembly sitemap: api/sitemap/assembly.sitemap.xml contains published assembly"
    )
    def verify_assembly_sitemap(self, api_auth):
        lcc.log_info("Verifying sitemap for assemblies")
        req = fixture.url + "api/sitemap/assembly.sitemap.xml"
        response = api_auth.get(req)
        url_loc = fixture.cp_url + "documentation/en-us/" + self.product_name_uri + "/" + constants.product_version_uri + "/guide/" + self.assembly_uuid
        # Verify that assembly sitemap response contains recently published assembly url
        check_that("Assembly Sitemap response at endpoint: %s" % req,
                   response.text, contains_string(url_loc))

        xml_dict = {}
        root = ET.fromstring(response.content)
        lcc.log_info(
            "Creating a dict for the sitemap endpoint responses for verification..."
        )

        for sitemap in root:
            children = sitemap.getchildren()
            xml_dict[children[0].text] = children[1].text

        print(str(xml_dict))

        # Extract published date for recent assembly from the sitemap
        publish_date = xml_dict[url_loc]
        lcc.log_info("Extracting the publish date for %s as %s" %
                     (url_loc, publish_date))
        # date = publish_date.split("T")
        #
        # # Verify that published date is same as current date
        # check_that("Published date", date[0], equal_to(str(self.now.date())))
        #
        # t = date[1].split(".")[0].split(":")
        # hour = t[0]
        # min = t[1]
        # sec = t[2]
        # lcc.log_info("Time now: %s" % str(self.now.time()))
        # lcc.log_info("Published time to match: %s " % str(t))
        publish_date = publish_date.replace("Z", "+00:00")
        published_date = datetime.fromisoformat(publish_date)
        flag = False
        if (self.now <= published_date <= self.range):
            flag = True

        check_that(
            "Published date and time is in range %s to %s" %
            (self.now, self.range), flag, is_true())

        # # Verify that assembly publish time is within current time range
        # all_of(check_that("Published time (Hour)", int(hour), is_between(self.now_hour, self.now_hour_plus_one)),
        #        check_that("Published time (Min)", int(min), is_between(self.now_min_minus_ten, self.now_min_plus_ten)))

        lcc.log_info(
            "Verifying if unpublishing the assembly removes it from the sitemap..."
        )
        # Unpublishing the assembly
        res = utilities.unpublish_content(fixture.url, self.assembly_path,
                                          self.variant, self.api_auth)
        draft = api_auth.get(fixture.url + self.assembly_path +
                             "/en_US/variants/" + self.variant + ".10.json")
        # Check that assembly is unpublished successfully
        assert_that("Document unpublished", draft.json(), has_entry("draft"))
        response1 = api_auth.get(req)
        # Verify unpublished module not listed in sitemap
        check_that("Assembly Sitemap response", response1.text,
                   not_(contains_string(url_loc)))

    @lcc.test(
        "Verify api endpoint for module sitemap: api/sitemap/module.sitemap.xml contains published module"
    )
    def verify_module_sitemap(self, api_auth):
        lcc.log_info("Verifying sitemap for module")
        req = fixture.url + "api/sitemap/module.sitemap.xml"
        response = api_auth.get(req)
        url_loc = fixture.cp_url + "documentation/en-us/" + self.product_name_uri + "/" + constants.product_version_uri + "/topic/" + self.module_uuid
        check_that("Module Sitemap response at endpoint: %s" % req,
                   response.text, contains_string(url_loc))

        xml_dict = {}
        root = ET.fromstring(response.content)
        lcc.log_info(
            "Creating a dict for the sitemap endpoint responses for verification..."
        )

        for sitemap in root:
            children = sitemap.getchildren()
            xml_dict[children[0].text] = children[1].text

        print(str(xml_dict))

        # Extract published date for recent assembly from the sitemap
        publish_date = xml_dict[url_loc]
        lcc.log_info("Extracting the publish date for %s as %s" %
                     (url_loc, publish_date))
        # date = publish_date.split("T")
        #
        # # Verify that published date is same as current date
        # check_that("Published date", date[0], equal_to(str(self.now.date())))
        #
        # t = date[1].split(".")[0].split(":")
        # hour = t[0]
        # min = t[1]
        # sec = t[2]
        # lcc.log_info("Time now: %s" % str(self.now.time()))
        # lcc.log_info("Published time to match: %s " % str(t))
        # # Verify that module publish time is withing current time range
        # all_of(check_that("Published time (Hour)", int(hour), is_between(self.now_hour, self.now_hour_plus_one)),
        #        check_that("Published time (Min)", int(min),
        #                   is_between(self.now_min_minus_ten, self.now_min_plus_ten)))
        publish_date = publish_date.replace("Z", "+00:00")
        published_date = datetime.fromisoformat(publish_date)
        flag = False
        if (self.now <= published_date <= self.range):
            flag = True

        check_that(
            "Published date and time is in range %s to %s" %
            (self.now, self.range), flag, is_true())

        lcc.log_info(
            "Verifying if unpublishing a module removes it from the sitemap.xml... "
        )

        # Unpublishing the module
        res = utilities.unpublish_content(fixture.url, self.module_path,
                                          self.variant, self.api_auth)
        draft = api_auth.get(fixture.url + self.module_path +
                             "/en_US/variants/" + self.variant + ".10.json")
        # Check that the modules was unpublished successfully
        assert_that("Document unpublished", draft.json(), has_entry("draft"))
        response1 = api_auth.get(req)
        # Verify unpublished module not listed in sitemap
        check_that("Module Sitemap response", response1.text,
                   not_(contains_string(url_loc)))

    @lcc.test("Verify sitemap API endpoint behind akamai")
    def verify_module_sitemap_behind_akamai(self, api_auth):
        req1 = fixture.behind_akamai_url + "api/sitemap/module.sitemap.xml"
        lcc.log_info(req1)
        response1 = api_auth.get(req1, proxies=proxies)
        check_that("status code for Module Sitemap API behind akamai",
                   response1.status_code, equal_to(200))

        req2 = fixture.behind_akamai_url + "api/sitemap/assembly.sitemap.xml"
        lcc.log_info(req2)
        response2 = api_auth.get(req2, proxies=proxies)
        check_that("status code for Assembly Sitemap API behind akamai",
                   response2.status_code, equal_to(200))

    @lcc.test("Verify sitemap API endpoint external proxy")
    def verify_module_sitemap_ext_proxy(self, api_auth):
        req1 = fixture.external_proxy_url + "sitemap/module.sitemap.xml"
        lcc.log_info(req1)
        response1 = api_auth.get(req1, proxies=proxies)
        check_that("status code for Module Sitemap API for external proxy",
                   response1.status_code, equal_to(200))

        req2 = fixture.external_proxy_url + "sitemap/assembly.sitemap.xml"
        lcc.log_info(req2)
        response2 = api_auth.get(req2, proxies=proxies)
        check_that("status code for Assembly Sitemap API for external proxy",
                   response2.status_code, equal_to(200))
class test_git_import(Screenshot):
    driver = lcc.inject_fixture("driver_obj")

    # @lcc.disabled()
    @lcc.test(
        "Verify that warning message should be displayed when repository URL is empty"
    )
    def git_import_for_empty_git_repo(self):
        utilities.click_element(self.driver, By.LINK_TEXT,
                                locators.MENU_GIT_IMPORT_LINK_TEXT)
        git_import_page.import_git_repo(self.driver, None, None)
        check_that(
            "Empty git repo url warning message",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.WARNING_ALERT_CSS),
            contains_string(constants.repo_url_empty_warning_message))

    # @lcc.disabled()
    @lcc.test(
        "Verify that error message should be displayed when repository url has invalid"
    )
    def git_import_for_invalid_git_repo_url(self):
        git_import_page.import_git_repo(self.driver,
                                        constants.invalid_git_repo_url,
                                        git_import_repo_branch)
        text = utilities.get_text(self.driver, By.CSS_SELECTOR,
                                  locators.GIT_IMPORT_ALERT_CSS)
        print(text)
        check_that("Invalid git repo url error alert", text,
                   contains_string(constants.failure_alert_message))
        check_that("Invalid git repo url files count", text,
                   contains_string(constants.failure_alert_files_uploaded))
        utilities.verify_and_accept_confirmation_modal(
            self.driver, locators.GIT_IMPORT_REQUEST_SUBMITTED_TITLE,
            constants.git_import_submitted_modal_title,
            locators.GIT_IMPORT_REQUEST_SUBMITTED_NO)

    # @lcc.disabled()
    @lcc.test(
        "Verify that user should be able to upload modules successfully using git import"
    )
    def git_import_for_sample_repo(self):
        git_import_page.import_git_repo(self.driver, git_import_repo_URL,
                                        git_import_repo_branch)
        utilities.verify_and_accept_confirmation_modal(
            self.driver, locators.GIT_IMPORT_REQUEST_SUBMITTED_TITLE,
            constants.git_import_submitted_modal_title,
            locators.GIT_IMPORT_REQUEST_SUBMITTED_YES)
        utilities.wait(20)
        # utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        poll(lambda: utilities.find_element(
            self.driver, By.CSS_SELECTOR, locators.GIT_IMPORT_SUCCESS_ALERT_CSS
        ).is_displayed(),
             step=1,
             timeout=150)
        # screenshot_filename = "git_import" + utilities.generate_random_string(3) + ".png"
        # self.driver.save_screenshot(screenshot_filename)
        # lcc.save_attachment_file(screenshot_filename)
        text = utilities.get_text(self.driver, By.CSS_SELECTOR,
                                  locators.GIT_IMPORT_SUCCESS_ALERT_CSS)
        print(text)
        check_that("Git import successful alert", text,
                   contains_string(constants.success_alert_message))
        check_that(
            "Git import successfully uploaded files count", text,
            contains_string(constants.success_alert_files_uploaded +
                            number_of_files_imported))
        utilities.page_reload(self.driver)
        repo_list = utilities.find_elements_by_css_selector(
            self.driver, locators.LIST_OF_REPOS_CSS)
        name = []
        for i in repo_list:
            name.append(i.text)

        check_that("Git import repo is listed on search page", name,
                   has_item(git_import_repo_Name))

        # utilities.page_reload(self.driver)
        search_url = fixture.url + 'pantheon/internal/modules.json?repo=' + fixture.git_import_repo \
                     + '&search=' + module_title_prefix + '&key=Updated&direction=desc'

        lcc.log_info("Git import functionality verified using endpoint: %s" %
                     search_url)
        lcc.log_info(
            "Trying to poll the endpoint until we get the required number of search results as"
            " per the test data ...")
        req = requests.get(search_url)
        print(req.content)
        # poll(lambda: requests.get(search_url).json()["size"] == 9, step=5, timeout=120)

        imported_modules_request = requests.get(search_url)
        imported_modules = imported_modules_request.json()
        lcc.log_info(str(imported_modules))
        total_modules = imported_modules["size"]

        lcc.log_info(
            "Number of modules listed with the similar title name: %s" %
            str(total_modules))
        lcc.log_info(
            "Capturing the number of modules uploaded from the repo: %s ..." %
            git_import_repo_Name)
        results = imported_modules["results"]
        imported_modules_array = []
        for result in results:
            if result["pant:transientSourceName"] == git_import_repo_Name:
                imported_modules_array.append(result["jcr:title"])
        lcc.log_info(
            "Modules imported successfully via git import: %s with title prefix"
            % str(imported_modules_array))
        lcc.log_info(
            "Number of modules imported successfully from repo: %s is %s" %
            (git_import_repo_URL, str(len(imported_modules_array))))
        check_that("Count of modules uploaded using git import",
                   len(imported_modules_array),
                   equal_to(int(number_of_modules)))