Esempio n. 1
0
def test_ui_check_job_details_page_values(core_session, core_admin_ui, list_of_created_systems):
    """
         Test case: C1670
               :param core_session: Returns API session
               :param core_admin_ui: Centrify admin Ui session
               :param list_of_created_systems: returns the empty systems list.
               """
    account_name_prefix = f'account_test{guid()}'

    # adding multiple systems with accounts
    result = ResourceManager.add_multiple_systems_with_accounts(core_session, 1, 1, list_of_created_systems,
                                                                user_prefix=account_name_prefix)

    # arranging the results in the lists
    all_systems, all_accounts = DataManipulation.aggregate_lists_in_dict_values([result])

    # Deleting systems for creating bulk delete scheduled report
    result_acc, success_acc = ResourceManager.del_multiple_accounts(core_session, all_accounts)
    assert success_acc, f"Api did not complete successfully for bulk account delete MSG:{result_acc}"

    # Deleting accounts for creating bulk delete scheduled report
    result_sys, success = ResourceManager.del_multiple_systems(core_session, all_systems)
    assert success, f'Delete systems job failed when expected success'
    logger.info(f"Delete systems job executed successfully {result_sys}")

    # Going to password storage page and click on migration job status link.
    ui = core_admin_ui
    ui.navigate("Settings", "Resources", "Password Storage", check_rendered_tab=False)
    ui.expect(Anchor("View Migration Job Status and Reports "), "Clicking migration job status").try_click()
    ui.switch_to_newest_tab()
    ui._waitUntilSettled()
    ui.click_row(GridRowByGuid(result_sys))
    ui.expect(Span("Details"), "Clicking migration job status").try_click(Div("Job Details"))

    # Checking the Job Id of system.
    ui.expect_value(Div(result_sys), value=None, expected_value=result_sys,
                    wrong_value_message="expected id value is not matched in the report",
                    text=True)
    logger.info("Id value in the Job description appeared correctly")

    # List of the Expected text from Job Details
    list_of_text = ['Job Information', 'Type', 'ID', 'Description', 'Submitted', 'Started', 'Completed',
                    'Retry Count', 'Items Synced', 'Items Failed']

    # Getting the Job history
    job_history = JobManager.get_job_history(core_session)

    # Validating the Job history expected title appeared correctly on UI.
    for label in list_of_text:
        ui.expect_value(Label(label), value=None, expected_value=label,
                        wrong_value_message=f"expected {label} value is not matched in the report",
                        text=True)
        logger.info(f"expected {label} value is matched in the report")
    delete_scheduled_job = []
    check_text = []
    if job_history[1]['JobName'] == 'BulkSystemDelete':
        account_bulk_delete_schedule_id = job_history[0]['ID']
        System_bulk_delete_schedule_id = job_history[1]['ID']
        System_jobdescription = job_history[1]['JobDescription']
        System_jobName = job_history[1]['JobName']
        check_text.append(System_bulk_delete_schedule_id)
        check_text.append(System_jobdescription)
        check_text.append(System_jobName)
        check_text.append(account_bulk_delete_schedule_id)
        delete_scheduled_job.append(System_bulk_delete_schedule_id)
    ui.switch_context(RenderedTab("Job Details"))

    # Validating the Job history results from API appeared correctly on UI.
    for text in check_text:
        ui.expect_value(Div(text), value=None, expected_value=text,
                        wrong_value_message=f"expected {text} value is not matched in the report",
                        text=True)
        logger.info(f"expected {text} value is matched in the report")

    # Deleting the Scheduled jobs of Bulk System's and Account's
    for delete in delete_scheduled_job:
        result_account_delete, success, response = Discovery.delete_job_history(core_session, delete)
        assert success, f"Failed to delete Job history profile {result_account_delete}"
        logger.info(f"delete Job history profile with id {delete} successful {success}")