|
2 | 2 | from datetime import datetime |
3 | 3 |
|
4 | 4 | from my_pages import * |
5 | | -from utils import oracle, fit_kit_logged |
| 5 | +from utils import fit_kit_logged |
| 6 | +from utils.batch_processing import batch_processing |
6 | 7 | from utils.fit_kit_generation import create_fit_id_df |
7 | 8 | from utils.fit_kit_logged import process_kit_data, update_kit_service_management_entity |
8 | 9 | from utils.oracle import OracleDB |
9 | 10 | from utils.screening_subject_page_searcher import verify_subject_event_status_by_nhs_no |
10 | 11 |
|
| 12 | + |
11 | 13 | @pytest.mark.wip2 |
12 | 14 | def test_compartment_3(page: Page) -> None: |
13 | 15 | UserTools.user_login(page, "Hub Manager State Registered") |
14 | 16 |
|
15 | | - # Add results to the test records in the KIT_QUEUE table (i.e. mimic receiving results from the middleware) |
| 17 | + # (STEP 1 & 2) Add results to the test records in the KIT_QUEUE table (i.e. mimic receiving results from the middleware) |
16 | 18 | # and get device IDs and their flags |
17 | 19 | device_ids = process_kit_data() |
18 | 20 | # (STEP - 4) Run two stored procedures to process any kit queue records at status BCSS_READY |
@@ -44,29 +46,49 @@ def test_compartment_3(page: Page) -> None: |
44 | 46 | logging.error(f"Verification failed for NHS number {nhs_number} with status {expected_status}: {str(e)}") |
45 | 47 | raise |
46 | 48 |
|
| 49 | + # (STEP - 5) Check the results of the processed FIT kits have correctly updated the status of the associated subjects |
| 50 | + # Navigate to log devices page |
| 51 | + MainMenu(page).go_to_fit_test_kits_page() |
| 52 | + FITTestKits(page).go_to_log_devices_page() |
| 53 | + |
| 54 | + # Get a fit device id |
| 55 | + subjectdf = create_fit_id_df() |
| 56 | + |
| 57 | + # Log fit device |
| 58 | + for subject in range(4): |
| 59 | + fit_device_id = subjectdf["fit_device_id"].iloc[subject] |
| 60 | + LogDevices(page).fill_fit_device_id_field(fit_device_id) |
| 61 | + sample_date = datetime.now().strftime("%#d %b %Y") |
| 62 | + LogDevices(page).fill_sample_date_field(sample_date) |
| 63 | + LogDevices(page).verify_successfully_logged_device_text() |
| 64 | + |
| 65 | + # Check statuses of 'normal' FIT kit subjects has moved to S2 |
| 66 | + nhs_no = subjectdf["subject_nhs_number"].iloc[0] |
| 67 | + verify_subject_event_status_by_nhs_no(page, nhs_no, "S2 - Normal") |
| 68 | + |
| 69 | + # Check status of 'abnormal' FIT kit subjects has moved to A8 |
| 70 | + nhs_no = subjectdf["subject_nhs_number"].iloc[0] |
| 71 | + verify_subject_event_status_by_nhs_no(page, nhs_no, "A8 - Abnormal") |
| 72 | + |
| 73 | + # (Step 12) - Process S2 batch |
| 74 | + # Run batch processing function on S2 batch |
| 75 | + batch_processing(page, "S2", "Normal", "S2 - Normal") |
| 76 | + nhs_number_df = batch_processing(page, "S2", "Normal", "S2 - Normal") |
| 77 | + for index, row in nhs_number_df.iterrows(): |
| 78 | + OracleDB().exec_bcss_timed_events(row["subject_nhs_number"]) |
| 79 | + |
| 80 | + # Verify Status of subject is updated to S158 |
| 81 | + nhs_no = subjectdf["subject_nhs_number"].iloc[0] |
| 82 | + verify_subject_event_status_by_nhs_no(page, nhs_no, "S158") |
| 83 | + |
| 84 | + # (Step 13) - Process S158 batch |
| 85 | + # Run batch processing function on S158 batch |
| 86 | + batch_processing(page, "S158", "Normal result letter sent to subject", "S158 - Normal result letter sent to subject") |
| 87 | + nhs_number_df = batch_processing(page, "S158", "Normal result letter sent to subject", "S158 - Normal result letter sent to subject") |
| 88 | + for index, row in nhs_number_df.iterrows(): |
| 89 | + OracleDB().exec_bcss_timed_events(row["subject_nhs_number"]) |
47 | 90 |
|
| 91 | + # Verify Status of subject is updated to S159 |
| 92 | + nhs_no = subjectdf["subject_nhs_number"].iloc[0] |
| 93 | + verify_subject_event_status_by_nhs_no(page, nhs_no, "S159 - Normal result letter sent to GP") |
48 | 94 |
|
49 | | - # |
50 | | - # # (STEP - 5) Check the results of the processed FIT kits have correctly updated the status of the associated subjects |
51 | | - # # Navigate to log devices page |
52 | | - # MainMenu(page).go_to_fit_test_kits_page() |
53 | | - # FITTestKits(page).go_to_log_devices_page() |
54 | | - # |
55 | | - # # Get a fit device id |
56 | | - # subjectdf = create_fit_id_df() |
57 | | - # |
58 | | - # # Log fit device |
59 | | - # for subject in range(4): |
60 | | - # fit_device_id = subjectdf["fit_device_id"].iloc[subject] |
61 | | - # LogDevices(page).fill_fit_device_id_field(fit_device_id) |
62 | | - # sample_date = datetime.now().strftime("%#d %b %Y") |
63 | | - # LogDevices(page).fill_sample_date_field(sample_date) |
64 | | - # LogDevices(page).verify_successfully_logged_device_text() |
65 | | - # |
66 | | - # # Check statuses of 'normal' FIT kit subjects has moved to S2 |
67 | | - # nhs_no = subjectdf["subject_nhs_number"].iloc[0] |
68 | | - # verify_subject_event_status_by_nhs_no(page, nhs_no, "S2 - Normal") |
69 | | - # |
70 | | - # # Check status of 'abnormal' FIT kit subjects has moved to A8 |
71 | | - # nhs_no = subjectdf["subject_nhs_number"].iloc[0] |
72 | | - # verify_subject_event_status_by_nhs_no(page, nhs_no, "A8 - Abnormal") |
|
0 commit comments