def test_new_extension(conf, base_url, selenium, qr_code): """Test adding a new extension.""" ldap_page = LDAPLogin(selenium, base_url) home_page = ldap_page.setup(conf, qr_code) extensions_listing_page = home_page.click_extensions() new_extension_page = extensions_listing_page.click_new_extension() new_extension_page.upload_extension()
def test_add_recipe(conf, base_url, selenium, qr_code): """Test adding a recipe.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page = home_page.click_add_recipe() assert home_page.heading == 'SHIELD Control Panel' assert recipe_page.heading_two == "RecipesAdd New" assert recipe_page.find_element(*recipe_page.LOCATORS.save).is_displayed()
def test_approve_recipe(conf, base_url, selenium, qr_code): """Test the approval flow of creating a recipe.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page, messages_list = home_page.create_approved_recipe(conf) assert 'Approval requested.' in messages_list assert recipe_page.find_element( *recipe_page.LOCATORS.enable_button).is_displayed()
def test_enable_recipe(conf, base_url, selenium, qr_code): """Test the approval flow of creating a recipe.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page, recipe_name, messages_list = home_page.create_approved_and_enabled_recipe( conf) # noqa print("messages_list ", messages_list) assert "Recipe enabled." in messages_list or "Revision approved." in messages_list # noqa assert recipe_page.find_element( *recipe_page.LOCATORS.disable_button).is_displayed()
def test_save_recipe(conf, base_url, selenium, qr_code): """Test creating a recipe and successfully submitting it.""" time.sleep(20) LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page = home_page.click_add_recipe() recipe_page, recipe_name, messages_list = recipe_page.save_recipe(conf) assert recipe_page.find_element( *recipe_page.LOCATORS.request_button).is_displayed() assert 'Recipe saved.' in messages_list
def test_verify_col_names(conf, base_url, selenium, qr_code): """Test that column values of a recipe is correctly saved.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page, recipe_name, messages_list = home_page.create_approved_and_enabled_recipe( conf) # noqa home_page = recipe_page.click_home_button() found_recipe, recipe_page, row_content = home_page.find_recipe_in_table( recipe_name) assert found_recipe assert recipe_name == row_content[0] assert conf.get('recipe', 'recipe_action') == row_content[1]
def test_disable_recipe(conf, base_url, selenium, qr_code): """Test disabling a recipe.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page, recipe_name, messages_list = home_page.create_approved_and_enabled_recipe(conf) # noqa home_page = recipe_page.click_home_button() found_recipe, recipe_page, row_content = home_page.find_recipe_in_table( recipe_name) recipe_page, messages_list = recipe_page.disable_recipe() found_recipe_at_rest_api = find_recipe_rest_api(conf, recipe_name) assert "Recipe disabled." in messages_list assert not found_recipe_at_rest_api
def test_publish_recipe(conf, base_url, selenium, qr_code): """Test publishing a recipe.""" time.sleep(30) ldap_page = LDAPLogin(selenium, base_url) home_page = ldap_page.setup(conf, qr_code) recipes_listing_page = home_page.click_recipes() new_recipe_page = recipes_listing_page.click_new_recipe() view_recipe_page, recipe_action, recipe_name = new_recipe_page.create_new_recipe(conf) # noqa view_recipe_page = view_recipe_page.click_request_approval() approval_history_page = view_recipe_page.click_approval_request() approval_history_page = approval_history_page.approve_recipe(conf) view_recipe_page = approval_history_page.click_view_recipe_breadcrumb() view_recipe_page = view_recipe_page.publish_recipe() assert view_recipe_page.alert_message == "This is the published version."
def test_edit_recipe(conf, base_url, selenium, qr_code): """Test editing an existing recipe.""" time.sleep(30) ldap_page = LDAPLogin(selenium, base_url) home_page = ldap_page.setup(conf, qr_code) recipes_listing_page = home_page.click_recipes() new_recipe_page = recipes_listing_page.click_new_recipe() view_recipe_page, recipe_action, recipe_name = new_recipe_page.create_new_recipe( conf) # noqa edit_recipe_page = view_recipe_page.click_edit() new_recipe_action, edit_recipe_page = edit_recipe_page.edit_recipe(conf) view_recipe_page = edit_recipe_page.click_view_recipe_breadcrumb() action_name = view_recipe_page.get_action_name assert new_recipe_action == action_name
def test_clone_recipe(conf, base_url, selenium, qr_code): """Test cloning a recipe.""" time.sleep(30) ldap_page = LDAPLogin(selenium, base_url) home_page = ldap_page.setup(conf, qr_code) recipes_listing_page = home_page.click_recipes() new_recipe_page = recipes_listing_page.click_new_recipe() view_recipe_page, recipe_action, recipe_name = new_recipe_page.create_new_recipe( conf) # noqa clone_recipe_page = view_recipe_page.click_clone() view_recipe_page = clone_recipe_page.clone_recipe(conf) assert view_recipe_page.alert_message == "You are viewing a draft." action_name = view_recipe_page.get_action_name assert recipe_action == action_name
def test_create_new_recipe(conf, base_url, selenium, qr_code): """Test creating a new recipe.""" ldap_page = LDAPLogin(selenium, base_url) home_page = ldap_page.setup(conf, qr_code) recipes_listing_page = home_page.click_recipes() new_recipe_page = recipes_listing_page.click_new_recipe() assert new_recipe_page.heading_two == "Create New Recipe" assert new_recipe_page.find_element( *new_recipe_page.LOCATORS.save_button).is_displayed() view_recipe_page, recipe_action, recipe_name = new_recipe_page.create_new_recipe( conf) # noqa assert view_recipe_page.alert_message == "You are viewing a draft." assert view_recipe_page.find_element( *view_recipe_page.LOCATORS.edit_button).is_displayed()
def test_delete_recipe(conf, base_url, selenium, qr_code): """Confirm recipe deleted on home page.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page, recipe_name, messages_list = home_page.create_approved_and_enabled_recipe(conf) # noqa home_page = recipe_page.click_home_button() found_before_deleted_recipe, recipe_page, row_content = home_page.find_recipe_in_table(recipe_name) # noqa home_page, messages_list = recipe_page.delete_recipe() found_after_deleted_recipe, recipe_page, row_content = home_page.find_recipe_in_table(recipe_name) # noqa found_recipe_in_rest_api = find_recipe_rest_api(conf, recipe_name) assert found_before_deleted_recipe assert 'Recipe deleted.' in messages_list assert not found_after_deleted_recipe assert not found_recipe_in_rest_api
def test_approve_recipe(conf, base_url, selenium, qr_code): """Test the approval flow of creating a recipe.""" time.sleep(30) ldap_page = LDAPLogin(selenium, base_url) home_page = ldap_page.setup(conf, qr_code) recipes_listing_page = home_page.click_recipes() new_recipe_page = recipes_listing_page.click_new_recipe() view_recipe_page, recipe_action, recipe_name = new_recipe_page.create_new_recipe( conf) # noqa view_recipe_page = view_recipe_page.click_request_approval() time.sleep(10) assert view_recipe_page.alert_message == "This is pending approval." approval_history_page = view_recipe_page.click_approval_request() approval_history_page = approval_history_page.approve_recipe(conf) time.sleep(5) assert approval_history_page.get_tag == "Approved"
def test_find_recipe_in_table(conf, base_url, selenium, qr_code): """Find recipe on home page.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page, recipe_name, messages_list = home_page.create_approved_and_enabled_recipe( conf) # noqa home_page = recipe_page.click_home_button() found_recipe, recipe_page, row_content = home_page.find_recipe_in_table( recipe_name) action_selected = recipe_page.get_action_selected found_recipe_at_rest_api = find_recipe_rest_api(conf, recipe_name) assert found_recipe, "recipe name not found" assert recipe_page.find_element( *recipe_page.LOCATORS.filter_textbox).text == conf.get( 'recipe', 'recipe_additional_filters') # noqa assert action_selected == conf.get('recipe', 'recipe_action') assert recipe_page.find_element( *recipe_page.LOCATORS.action_message).get_attribute( 'value') == conf.get('recipe', 'recipe_message') assert found_recipe_at_rest_api
def test_edit_recipe(conf, base_url, selenium, foxpuppet, qr_code): """Find recipe on home page, and edit recipe.""" """Check recipe was correctly changed.""" LDAP = LDAPLogin(selenium, base_url) home_page = LDAP.setup(conf, qr_code) recipe_page, recipe_name, messages_list = home_page.create_approved_and_enabled_recipe(conf) # noqa home_page = recipe_page.click_home_button() found_recipe, recipe_page, row_content = home_page.find_recipe_in_table( recipe_name) recipe_page, messages_list = recipe_page.edit_enabled_recipe(conf) home_page = recipe_page.click_home_button() found_recipe, recipe_page, row_content = home_page.find_recipe_in_table( recipe_name) action_selected = recipe_page.get_action_selected print("enter browser chrome to check heartbeat") assert found_recipe assert recipe_page.find_element(*recipe_page.LOCATORS.survey_id).get_attribute('value') == conf.get('recipe', 'recipe_survey_id') # noqa assert recipe_page.find_element(*recipe_page.LOCATORS.action_message).get_attribute('value') == conf.get('recipe', 'recipe_message') # noqa assert recipe_page.find_element(*recipe_page.LOCATORS.thanks_message).get_attribute('value') == conf.get('recipe', 'recipe_thanks_message') # noqa assert recipe_page.find_element(*recipe_page.LOCATORS.post_answer_url).get_attribute('value') == conf.get('recipe', 'recipe_post_url') # noqa assert recipe_page.find_element(*recipe_page.LOCATORS.learn_more).get_attribute('value') == conf.get('recipe', 'recipe_learn_more') # noqa assert recipe_page.find_element(*recipe_page.LOCATORS.learn_more_url).get_attribute('value') == conf.get('recipe', 'recipe_learn_more_url') # noqa assert action_selected == conf.get('recipe', 'recipe_new_action')