def get_service_templates_and_api_key_for_tests(driver, test_profile): dashboard_page = DashboardPage(driver) dashboard_page.click_email_templates() service_id = dashboard_page.get_service_id() email_template_page = SendEmailTemplatePage(driver) email_template_page.click_add_a_new_template() new_email_template_page = EditEmailTemplatePage(driver) new_email_template_page.create_template() email_template_page = SendEmailTemplatePage(driver) email_template_page.click_edit_template() edit_email_template_page = EditEmailTemplatePage(driver) email_template_id = edit_email_template_page.get_id() dashboard_page = DashboardPage(driver) dashboard_page.go_to_dashboard_for_service() dashboard_page.click_sms_templates() sms_template_page = SendSmsTemplatePage(driver) sms_template_page.click_add_new_template() new_sms_template = EditSmsTemplatePage(driver) new_sms_template.create_template() sms_template_page = SendSmsTemplatePage(driver) sms_template_page.click_edit_template() edit_sms_template = EditSmsTemplatePage(driver) sms_template_id = edit_sms_template.get_id() dashboard_page = DashboardPage(driver) dashboard_page.go_to_dashboard_for_service() dashboard_page.click_api_keys_link() api_key_page = ApiKeyPage(driver) api_key_page.click_keys_link() api_key_page.click_create_key() api_key_page.click_key_type_radio(key_type='team') api_key_page.enter_key_name(key_type='team') api_key_page.click_continue() api_key = api_key_page.get_api_key() test_profile.service_id = service_id test_profile.email_template_id = email_template_id test_profile.sms_template_id = sms_template_id test_profile.api_key = api_key return {'service_id': service_id, 'email_template_id': email_template_id, 'sms_template_id': sms_template_id, 'api_key': api_key} # noqa
def do_edit_and_delete_email_template(driver): test_name = "edit/delete test" dashboard_page = DashboardPage(driver) dashboard_page.go_to_dashboard_for_service() dashboard_page.click_email_templates() existing_templates = [x.text for x in driver.find_elements_by_class_name("message-name")] all_templates_page = SendEmailTemplatePage(driver) all_templates_page.click_add_new_template() template_page = EditEmailTemplatePage(driver) template_page.create_template(name=test_name) assert test_name in [x.text for x in driver.find_elements_by_class_name("message-name")] all_templates_page.click_edit_template() template_page.click_delete() assert [x.text for x in driver.find_elements_by_class_name("message-name")] == existing_templates