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)
from helpers import utilities from helpers import locators from helpers import base from fixtures import fixture from selenium.webdriver.common.by import By import sys import lemoncheesecake.api as lcc from lemoncheesecake.matching import * sys.path.append("..") username = base.config_reader('login', 'username') password = base.config_reader('login', 'password') def login(driver): # utilities.click_element(driver, By.LINK_TEXT, locators.LOGIN_LINK_TEXT) assert_that("Assert sso url", driver.current_url, contains_string(fixture.sso_url)) utilities.enter_text(driver, By.ID, locators.USER_NAME_ID, username) utilities.click_element(driver, By.ID, locators.LOGIN_NEXT_BUTTON_ID) utilities.enter_text(driver, By.ID, locators.PASSWORD_ID, password) utilities.click_element(driver, By.ID, locators.LOGIN_BUTTON_ID) driver.get(fixture.url + "pantheon/#/") def get_logged_in_username(driver): logged_in_user = utilities.get_text(driver, By.PARTIAL_LINK_TEXT, username) return logged_in_user
import sys from helpers import base import lemoncheesecake.api as lcc from lemoncheesecake.matching import * from helpers import constants import requests from fixtures import fixture from polling2 import poll from helpers import utilities import urllib.parse import os proxy_server = base.config_reader('proxy', 'proxy_server') proxies = { "http": proxy_server, "https": proxy_server, } sys.path.append("..") assembly_title_prefix = base.config_reader('test_repo', 'assembly_prefix') assembly_prefix = base.config_reader('test_repo', 'assembly_content_prefix') repo_name = base.config_reader('test_repo', 'repo_name') module_title_prefix = base.config_reader('test_repo', 'module_prefix') env = os.getenv('PANTHEON_ENV') @lcc.suite(description="Suite: Verify contents of published assembly", rank=4) class test_assembly_content:
import lemoncheesecake.api as lcc from lemoncheesecake.matching import * from html2json import collect from urllib.parse import urlparse from helpers import constants import requests from fixtures import fixture from polling2 import poll from helpers import utilities import urllib.parse import suites.test_module_edit_publish as test_module_edit_publish import os import subprocess import time proxy_server = base.config_reader('proxy', 'proxy_server') proxies = { "http": proxy_server, "https": proxy_server, } sys.path.append("..") module_title_prefix = base.config_reader('test_repo', 'module_prefix') module_prefix = base.config_reader('test_repo', 'module_content_prefix') repo_name = base.config_reader('test_repo', 'repo_name') assembly_title_prefix = base.config_reader('test_repo', 'assembly_prefix') assembly_prefix = base.config_reader('test_repo', 'assembly_content_prefix') env = os.getenv('PANTHEON_ENV') cp_url = base.config_reader(env, 'cp_url')
from fixtures.fixture import admin_username, admin_auth from helpers import constants, base from helpers import locators from helpers import utilities from fixtures import fixture from helpers.base_screenshot import Screenshot from datetime import datetime from pages import search_page from pages import search_beta_page from selenium.webdriver.common.by import By from selenium.common.exceptions import TimeoutException, StaleElementReferenceException, NoSuchElementException from polling2 import poll sys.path.append("..") username = base.config_reader('login', 'username') auth = base.config_reader('login', 'password') api_auth = base.config_reader('login', 'api_password') # SUITE = { # "description": "Publish module test", # "rank": "4" # } @lcc.suite("Suite: Publish module test", rank=5) class test_publish_module(Screenshot): driver = lcc.inject_fixture("driver_obj") first_pub_date_details_page = "" last_pub_date_details_page = ""
import sys from helpers import base import lemoncheesecake.api as lcc from lemoncheesecake.matching import * from helpers import utilities from helpers import constants import time import requests import json from fixtures import fixture from polling2 import poll git_import_repo_URL = base.config_reader('git_import_test_repo', 'git_import_repo_url') git_import_repo_Name = base.config_reader('git_import_test_repo', 'git_import_repo_name') git_import_repo_branch = base.config_reader('git_import_test_repo', 'git_import_repo_branch') # number_of_modules = base.config_reader('git_import_test_repo', 'number_of_modules_imported') # module_title_prefix = base.config_reader('git_import_test_repo', 'module_prefix') # assembly_title_prefix = base.config_reader('git_import_test_repo', 'assembly_prefix') number_of_resources_uploaded = base.config_reader( 'git_import_test_repo', 'number_of_resources_uploaded') number_of_modules_uploaded = base.config_reader('git_import_test_repo', 'number_of_modules_uploaded') number_of_assemblies_uploaded = base.config_reader( 'git_import_test_repo', 'number_of_assemblies_uploaded') @lcc.suite(description="Suite: Git import functionality", rank=6) class test_git_import:
from selenium.webdriver.chrome.options import Options # from webdriver_manager.firefox import GeckoDriverManager # from selenium.webdriver.firefox.options import Options # from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from lemoncheesecake.matching import * from pages import login_page from helpers import constants from polling2 import poll logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) test_repo_URL = base.config_reader('test_repo', 'test_repo_url') test_repo_name = base.config_reader('test_repo', 'repo_name') git_import_repo = base.config_reader('git_import_test_repo', 'git_import_repo_name') # setting the appropriate URL value from env variable env = os.environ['PANTHEON_ENV'] if env == "qa": url = base.config_reader('qa', 'base_url') sso_url = base.config_reader('qa', 'sso_url') elif env == "dev": url = base.config_reader('dev', 'base_url') sso_url = base.config_reader('dev', 'sso_url') elif env == "stage": url = base.config_reader('stage', 'base_url') sso_url = base.config_reader('stage', 'sso_url') elif env == "prod":
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)
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..")
import sys, os from helpers import base import lemoncheesecake.api as lcc from lemoncheesecake.matching import * from helpers import constants import requests import time from fixtures import fixture from polling2 import poll from helpers import utilities import json # from urllib.parse import urlencode sys.path.append("..") env = fixture.env assembly_title_prefix = base.config_reader('test_repo', 'assembly_prefix') cp_url = base.config_reader(env, 'cp_url') @lcc.suite(description="Suite: Tests for Assemblies", rank=3) 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)
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 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)
import sys from helpers import base import lemoncheesecake.api as lcc from lemoncheesecake.matching import * from helpers import constants import requests from fixtures import fixture from polling2 import poll number_of_modules = base.config_reader('test_repo', 'number_of_modules_uploaded') module_title_prefix = base.config_reader('test_repo', 'module_prefix') @lcc.suite(description="Suite: Verify search functionality", rank=5) 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",
import lemoncheesecake.api as lcc from lemoncheesecake.matching import * from helpers import constants import requests from fixtures import fixture from polling2 import poll from helpers import utilities # from urllib.parse import urlencode import json import time import os sys.path.append("..") module_title_prefix = base.config_reader('test_repo', 'module_prefix') module_uuid = "" env = fixture.env cp_url = base.config_reader(env, 'cp_url') @lcc.suite( description= "Suite: Verify that authenticated user can edit metadata and publish module", rank=1) class test_module_edit_publish: api_auth = lcc.inject_fixture("api_auth") path_for_module = "" request_url = "" @lcc.test(
import requests import lemoncheesecake.api as lcc from helpers import base from fixtures import fixture from helpers import constants, utilities from lemoncheesecake.matching import * import xml.etree.ElementTree as ET from datetime import datetime, timezone, timedelta proxy_server = base.config_reader('proxy', 'proxy_server') proxies = { "http": proxy_server, "https": proxy_server, } @lcc.suite( description="Suite: Verify sitemap api endpoints for assembly and modules", rank=8) 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):
from helpers import utilities from helpers import constants from helpers import locators import requests from fixtures import fixture from helpers.base_screenshot import Screenshot from selenium.webdriver.common.by import By from polling2 import poll sys.path.append("..") # SUITE = { # "description": "Git import for authenticated user", # "rank": "6" # } git_import_repo_URL = base.config_reader('git_import_test_repo', 'git_import_repo_url') git_import_repo_Name = base.config_reader('git_import_test_repo', 'git_import_repo_name') git_import_repo_branch = base.config_reader('git_import_test_repo', 'git_import_repo_branch') number_of_modules = base.config_reader('git_import_test_repo', 'number_of_modules_imported') number_of_files_imported = base.config_reader('git_import_test_repo', 'number_of_files_imported') module_title_prefix = constants.module_title_prefix @lcc.suite("Suite: Git import functionality", rank=3) class test_git_import(Screenshot): driver = lcc.inject_fixture("driver_obj")
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)
import git import os import shutil, time, datetime import logging import requests import subprocess import helpers.base as base from lemoncheesecake.matching import * from helpers import constants from helpers import utilities import json logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) test_repo_URL = base.config_reader('test_repo', 'test_repo_url') test_repo_name = base.config_reader('test_repo', 'repo_name') test_repo_branch = base.config_reader('test_repo', 'test_repo_branch') git_import_repo = base.config_reader('git_import_test_repo', 'git_import_repo_name') module_title_prefix = base.config_reader('test_repo', 'module_prefix') # setting the appropriate URL value from env variable env = os.environ['PANTHEON_ENV'] if env == "qa": url = base.config_reader('qa', 'base_url') git_import_server = base.config_reader('git_import_pod_details', 'qa') cp_url = base.config_reader('qa', 'cp_url') solr_url = base.config_reader('qa', 'solr_url') behind_akamai_url = base.config_reader('qa', 'behind_akamai_url') external_proxy_url = base.config_reader('qa', 'external_proxy_url')