From ddda4d3d7a71c7f556ffe85b4cdecd1f31562d2a Mon Sep 17 00:00:00 2001 From: "chinmay.mudholkar1@nhs.net" Date: Fri, 15 Nov 2024 11:20:33 +0000 Subject: [PATCH] sessions fixture --- .gitignore | 2 + conftest.py | 1 + libs/__init__.py | 1 + pages/pg_login.py | 6 +++ pages/pg_sessions.py | 4 +- requirements.txt | Bin 2256 -> 2108 bytes tests/{test_0_smoke.py => test_00_smoke.py} | 0 tests/{test_1_login.py => test_01_login.py} | 0 ...test_2_sessions.py => test_02_sessions.py} | 0 ...upload.py => test_03_class_list_upload.py} | 40 +++++++++--------- .../{test_4_cohorts.py => test_04_cohorts.py} | 0 ...upload.py => test_05_child_list_upload.py} | 0 ..._vaccs_batch.py => test_06_vaccs_batch.py} | 0 ...y => test_07_record_a_vaccine_using_ui.py} | 0 ...accs_upload.py => test_08_vaccs_upload.py} | 0 .../{test_3_consent.py => test_10_consent.py} | 4 +- 16 files changed, 35 insertions(+), 23 deletions(-) rename tests/{test_0_smoke.py => test_00_smoke.py} (100%) rename tests/{test_1_login.py => test_01_login.py} (100%) rename tests/{test_2_sessions.py => test_02_sessions.py} (100%) rename tests/{test_9_class_list_upload.py => test_03_class_list_upload.py} (59%) rename tests/{test_4_cohorts.py => test_04_cohorts.py} (100%) rename tests/{test_5_child_list_upload.py => test_05_child_list_upload.py} (100%) rename tests/{test_6_vaccs_batch.py => test_06_vaccs_batch.py} (100%) rename tests/{test_7_record_a_vaccine_using_ui.py => test_07_record_a_vaccine_using_ui.py} (100%) rename tests/{test_8_vaccs_upload.py => test_08_vaccs_upload.py} (100%) rename tests/{test_3_consent.py => test_10_consent.py} (94%) diff --git a/.gitignore b/.gitignore index e7cef02..d0f4ecd 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ venv/ # Local logs/pytest.log main.py +reports/* +working/* diff --git a/conftest.py b/conftest.py index 98fd12f..d698190 100644 --- a/conftest.py +++ b/conftest.py @@ -28,6 +28,7 @@ def start_playwright(): @pytest.fixture() def start_mavis(start_exe_session, start_playwright): _browser, _context = start_browser(pw=start_playwright, browser_or_device=ce.current_browser_name) + ce.browser = _browser ce.page = _context.new_page() ce.page.goto(url=ce.service_url) yield diff --git a/libs/__init__.py b/libs/__init__.py index 0dfc2bc..5abe9ea 100644 --- a/libs/__init__.py +++ b/libs/__init__.py @@ -7,6 +7,7 @@ class CurrentExecution: page = None + browser = None service_url: str = "" base_auth_username: str = "" base_auth_password: str = "" diff --git a/pages/pg_login.py b/pages/pg_login.py index 52c4579..6b44d77 100644 --- a/pages/pg_login.py +++ b/pages/pg_login.py @@ -10,6 +10,7 @@ class pg_login: TXT_EMAIL_ADDRESS = "Email address" TXT_PASSWORD = "Password" BTN_LOGIN = "Log in" + BTN_LOGOUT = "Log out" LBL_BANNER = "banner" LBL_USER = "Nurse Joy" LBL_PARAGRAPH = "paragraph" @@ -42,3 +43,8 @@ def perform_invalid_login(self, user: str, pwd: str, expected_message: str) -> s self.enter_password(password=pwd) self.click_login() self.po.verify(locator=self.LBL_PARAGRAPH, property=object_properties.TEXT, value=expected_message, exact=True) + + def logout(self): + self.po.perform_action(locator=self.BTN_LOGOUT, action=actions.CLICK_BUTTON) + self.ce.page.close() + # self.ce.browser.close() diff --git a/pages/pg_sessions.py b/pages/pg_sessions.py index ae7f3e0..44e9ab3 100644 --- a/pages/pg_sessions.py +++ b/pages/pg_sessions.py @@ -226,7 +226,7 @@ def create_invalid_session(self): def upload_class_list(self, file_paths: str): _input_file_path, _output_file_path = self.tdo.split_file_paths(file_paths=file_paths) - self.click_unscheduled() + self.click_scheduled() self.click_school1() self.click_import_class_list() self.choose_file_child_records(file_path=_input_file_path) @@ -238,7 +238,7 @@ def upload_class_list(self, file_paths: str): def upload_invalid_class_list_records(self, file_paths: str): _input_file_path, _output_file_path = self.tdo.split_file_paths(file_paths=file_paths) - self.click_unscheduled() + self.click_scheduled() self.click_school1() self.click_import_class_list() self.choose_file_child_records(file_path=_input_file_path) diff --git a/requirements.txt b/requirements.txt index fd49f23bd55d9a183540b68927c558769b79ca73..e4a87817e3414c3da57beb02907b45768e7f0c2a 100644 GIT binary patch delta 322 zcmW-cy-UMT6vgj*d3g!JK}E5~5JMVEkPy;XM2d=|li;p{;Gm_}k2B6A=a?#ILBp(H+$F7!BpudVs#}<4w2mt$bWMNaPY4 zGQ_>CV<_kGC+!)Fj_8~&=zxw3tdtfNSgMp@(dL>R!$&=c<|ltuk=t12+}mr4Iar$|(X> z0#{T3ZYZdVu9^l1Y7Tso`lr-wEi5@SNf~WZo3<#$6Vp6JR3oQIHSTR{+Zq#j%6Ahm_O7*mD(*OPC)R zyg@45G}ygwu;ZOk2{=oK_UVXPczV(sp|6gYvws;2PzENhr)Zd*plR|pCno0@$ayGV z-^~OS*J9_yYJj;_1+OjdKVOf!*tm_GS(G_3CM;vdy~XZtR@vh;IW))P91#?MNgSJ} fM>fx0w|S#XD(5zSSn(*858=1Xx8qOv2K)U2Mg(0+ diff --git a/tests/test_0_smoke.py b/tests/test_00_smoke.py similarity index 100% rename from tests/test_0_smoke.py rename to tests/test_00_smoke.py diff --git a/tests/test_1_login.py b/tests/test_01_login.py similarity index 100% rename from tests/test_1_login.py rename to tests/test_01_login.py diff --git a/tests/test_2_sessions.py b/tests/test_02_sessions.py similarity index 100% rename from tests/test_2_sessions.py rename to tests/test_02_sessions.py diff --git a/tests/test_9_class_list_upload.py b/tests/test_03_class_list_upload.py similarity index 59% rename from tests/test_9_class_list_upload.py rename to tests/test_03_class_list_upload.py index 5ee31ba..c416aae 100644 --- a/tests/test_9_class_list_upload.py +++ b/tests/test_03_class_list_upload.py @@ -9,37 +9,39 @@ class Test_Regression_Class_List_Upload: dashboard_page = pg_dashboard.pg_dashboard() sessions_page = pg_sessions.pg_sessions() - @pytest.mark.classlist - @pytest.mark.order(901) - def test_reg_class_list_file_upload_positive(self, start_mavis): + @pytest.fixture() + def create_session(self, start_mavis: None): self.login_page.perform_valid_login() self.dashboard_page.click_sessions() + self.sessions_page.schedule_a_valid_session() + self.dashboard_page.go_to_dashboard() + self.dashboard_page.click_sessions() + yield + self.dashboard_page.go_to_dashboard() + self.dashboard_page.click_sessions() + self.sessions_page.delete_all_sessions() + + @pytest.mark.classlist + @pytest.mark.order(301) + def test_reg_class_list_file_upload_positive(self, create_session: None): self.sessions_page.upload_class_list(file_paths=test_data_file_paths.CLASS_POSITIVE) @pytest.mark.classlist - @pytest.mark.order(902) - def test_reg_class_list_file_upload_negative(self, start_mavis): - self.login_page.perform_valid_login() - self.dashboard_page.click_sessions() + @pytest.mark.order(302) + def test_reg_class_list_file_upload_negative(self, create_session: None): self.sessions_page.upload_class_list(file_paths=test_data_file_paths.CLASS_NEGATIVE) @pytest.mark.classlist - @pytest.mark.order(903) - def test_reg_class_list_file_structure(self, start_mavis): - self.login_page.perform_valid_login() - self.dashboard_page.click_sessions() + @pytest.mark.order(303) + def test_reg_class_list_file_structure(self, create_session: None): self.sessions_page.upload_invalid_class_list_records(file_paths=test_data_file_paths.CLASS_INVALID_STRUCTURE) @pytest.mark.classlist - @pytest.mark.order(904) - def test_reg_class_list_no_record(self, start_mavis): - self.login_page.perform_valid_login() - self.dashboard_page.click_sessions() + @pytest.mark.order(304) + def test_reg_class_list_no_record(self, create_session: None): self.sessions_page.upload_invalid_class_list_records(file_paths=test_data_file_paths.CLASS_HEADER_ONLY) @pytest.mark.classlist - @pytest.mark.order(905) - def test_reg_class_list_empty_file(self, start_mavis): - self.login_page.perform_valid_login() - self.dashboard_page.click_sessions() + @pytest.mark.order(305) + def test_reg_class_list_empty_file(self, create_session: None): self.sessions_page.upload_invalid_class_list_records(file_paths=test_data_file_paths.CLASS_EMPTY_FILE) diff --git a/tests/test_4_cohorts.py b/tests/test_04_cohorts.py similarity index 100% rename from tests/test_4_cohorts.py rename to tests/test_04_cohorts.py diff --git a/tests/test_5_child_list_upload.py b/tests/test_05_child_list_upload.py similarity index 100% rename from tests/test_5_child_list_upload.py rename to tests/test_05_child_list_upload.py diff --git a/tests/test_6_vaccs_batch.py b/tests/test_06_vaccs_batch.py similarity index 100% rename from tests/test_6_vaccs_batch.py rename to tests/test_06_vaccs_batch.py diff --git a/tests/test_7_record_a_vaccine_using_ui.py b/tests/test_07_record_a_vaccine_using_ui.py similarity index 100% rename from tests/test_7_record_a_vaccine_using_ui.py rename to tests/test_07_record_a_vaccine_using_ui.py diff --git a/tests/test_8_vaccs_upload.py b/tests/test_08_vaccs_upload.py similarity index 100% rename from tests/test_8_vaccs_upload.py rename to tests/test_08_vaccs_upload.py diff --git a/tests/test_3_consent.py b/tests/test_10_consent.py similarity index 94% rename from tests/test_3_consent.py rename to tests/test_10_consent.py index ee5d482..536f65a 100644 --- a/tests/test_3_consent.py +++ b/tests/test_10_consent.py @@ -13,7 +13,7 @@ class Test_Regression_Consent: @pytest.mark.consent @pytest.mark.mobile - @pytest.mark.order(301) + @pytest.mark.order(1001) @pytest.mark.parametrize("scenario_data", helper.df.iterrows(), ids=[_tc[0] for _tc in helper.df.iterrows()]) def test_reg_parental_consent_workflow(self, start_consent_workflow, scenario_data): self.helper.read_data_for_scenario(scenario_data=scenario_data) @@ -21,7 +21,7 @@ def test_reg_parental_consent_workflow(self, start_consent_workflow, scenario_da @pytest.mark.consent @pytest.mark.mobile - @pytest.mark.order(302) + @pytest.mark.order(1002) def test_reg_gillick_consent(self, start_mavis): self.login_page.perform_valid_login() self.dashboard_page.click_sessions()