Exemple #1
0
def assert_changes_are_saved(context):
    """
    Save the changes by pressing the 'Save' button in the modal.

    :param context:
    :return:
    """
    modal_page = SetTherapeuticLevelModal(context.driver)
    modal = modal_page.get_currently_open_modal()

    scenario_name = context.scenario.name
    if 'Error notification' in scenario_name:
        modal_page.click_modal_button_by_name(
            modal,
            'Save',
            element_to_verify=NOTIFICATION_ERROR_MESSAGE_FIRST_LINE,
            hidden=False)
    elif 'Error modal' in scenario_name:
        modal_page.click_modal_button_by_name(
            modal,
            'Save',
            element_to_verify=MODAL_CONTAINER_ERROR_MESSAGE,
            hidden=False)
    else:
        modal_page.click_modal_button_by_name(modal, 'Save')
Exemple #2
0
def cancel_therapeutic_level_changes(context):
    """
    Cancel therapeutic level changes by pressing the 'Cancel' button in the
    modal.

    :param context:
    :return:
    """
    modal_page = SetTherapeuticLevelModal(context.driver)
    modal = modal_page.get_currently_open_modal()
    modal_page.click_modal_button_by_name(modal, 'Cancel')
Exemple #3
0
def select_staff_to_patient_ratio(context, staff_to_patient_ratio):
    """
    Select a level for the staff-to-patient ratio field.

    :param context:
    :param staff_to_patient_ratio:
    :return:
    """
    if staff_to_patient_ratio == 'nothing':
        return
    modal_page = SetTherapeuticLevelModal(context.driver)
    modal_page.set_staff_to_patient_ratio(staff_to_patient_ratio)
Exemple #4
0
def select_frequency(context, frequency):
    """
    Select a value for the frequency field.

    :param context:
    :param frequency:
    :return:
    """
    if frequency == 'nothing':
        return
    modal_page = SetTherapeuticLevelModal(context.driver)
    modal_page.set_frequency(frequency)
Exemple #5
0
def assert_observation_frequency_field_value(context, expected_frequency):
    """
    Assert that the value of the frequency field is as expected. Useful for
    checking pre-populated or default values.

    :param context:
    :param expected_frequency:
    :return:
    """
    modal_page = SetTherapeuticLevelModal(context.driver)
    actual_frequency = modal_page.get_frequency(readonly=True)
    assert expected_frequency == actual_frequency, \
        "Expected '{}' but was actually '{}'"\
        .format(expected_frequency, actual_frequency)
Exemple #6
0
def assert_observation_level_field_options(context):
    """
    Assert the options in the observation level field.

    :param context:
    :return:
    """
    expected_level_options = \
        [row['therapeutic level'] for row in context.table]
    modal_page = SetTherapeuticLevelModal(context.driver)
    actual_level_options = modal_page.get_level_field_options()
    assert expected_level_options == actual_level_options, \
        "Expected options to be '{}' but was actually '{}'" \
        .format(expected_level_options, actual_level_options)
Exemple #7
0
def assert_observation_level_field_value(context, level_number):
    """
    Assert the value of the observation level field.

    :param context:
    :param level_number:
    :return:
    """
    expected_level = 'Level {}'.format(level_number)
    modal_page = SetTherapeuticLevelModal(context.driver)
    actual_level = modal_page.get_level()
    assert expected_level == actual_level, \
        "Expected level input to have a value of '{}' but was actually '{}'." \
        .format(expected_level, actual_level)
Exemple #8
0
def select_level(context, level):
    """
    Select a value for the level field.

    :param context:
    :param level:
    :return:
    """
    if level == 'nothing':
        return
    level_number = level[-1]

    modal_page = SetTherapeuticLevelModal(context.driver)
    modal_page.set_level(level_number)
Exemple #9
0
def assert_frequency_field_is_editable(context):
    """
    Assert that the frequency field is currently editable (rather than
    read-only) so that a frequency can be chosen by the user.

    :param context:
    :return:
    """
    expected_frequency_options = \
        [row['frequency'] for row in context.table]
    modal_page = SetTherapeuticLevelModal(context.driver)
    actual_frequency_options = modal_page.get_frequency_field_options()
    assert expected_frequency_options == actual_frequency_options, \
        "Expected options to be '{}' but was actually '{}'" \
        .format(expected_frequency_options, actual_frequency_options)
Exemple #10
0
def assert_observation_frequency_field_is_read_only(context):
    """
    Assert that a field is read only and therefore cannot be edited.

    :param context:
    :return:
    """
    modal_page = SetTherapeuticLevelModal(context.driver)
    frequency_field = modal_page.get_frequency_field()
    assert frequency_field.tag_name == 'span'  # Not clickable.
    try:
        frequency_field.find_element(By.CSS_SELECTOR, '*')
    except NoSuchElementException:
        # No child elements which means there is nothing to click here.
        # Therefore can deduce that the field is read-only.
        pass