Esempio n. 1
0
def test_UI_GIVEN_valid_pixel_mapping_WHEN_entering_pixel_options_THEN_changing_to_invalid_pixel_grid_causes_validity_to_change(
        qtbot, template, pixel_options):

    # Change to pixel mapping
    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)

    manually_create_pixel_mapping_list(pixel_options)

    # Give valid input
    qtbot.keyClicks(pixel_options.pixel_mapping_widgets[0].pixelIDLineEdit,
                    "22")

    # Change to pixel grid
    systematic_button_press(qtbot, template,
                            pixel_options.single_pixel_radio_button)

    # Make the pixel grid invalid
    qtbot.keyClick(pixel_options.row_count_spin_box, Qt.Key_Down)
    qtbot.keyClick(pixel_options.column_count_spin_box, Qt.Key_Down)

    # Check that the test for unacceptable pixel states gives True
    assert pixel_options._pixel_validator.unacceptable_pixel_states() == [
        False, False
    ]
Esempio n. 2
0
def test_UI_GIVEN_user_provides_mesh_file_WHEN_entering_pixel_mapping_THEN_pixel_mapping_list_is_populated_with_correct_number_of_widgets(
        qtbot, template, pixel_options):

    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)
    manually_create_pixel_mapping_list(pixel_options)
    assert pixel_options.get_pixel_mapping_table_size() == CORRECT_CUBE_FACES
def test_UI_GIVEN_user_selects_no_pixels_and_gives_valid_nonpixel_input_WHEN_changing_pixel_layout_THEN_add_component_button_is_enabled(
    qtbot, template, pixel_options
):

    systematic_button_press(qtbot, template, pixel_options.no_pixels_button)

    # Check that the add component button is enabled
    assert pixel_options._pixel_validator.unacceptable_pixel_states() == [False, False]
Esempio n. 4
0
def test_UI_GIVEN_user_selects_no_pixels_WHEN_changing_pixel_layout_THEN_pixel_options_stack_becomes_invisible(
        qtbot, template, pixel_options):

    # Press the entire shape button under pixel layout
    systematic_button_press(qtbot, template, pixel_options.no_pixels_button)

    # Check that the pixel mapping items are visible
    assert not pixel_options.pixel_options_stack.isVisible()
Esempio n. 5
0
def test_UI_GIVEN_mesh_file_changes_WHEN_entering_pxixel_mapping_THEN_pixel_mapping_list_changes(
        qtbot, template, pixel_options):

    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)
    manually_create_pixel_mapping_list(pixel_options)
    manually_create_pixel_mapping_list(pixel_options, VALID_OCTA_OFF_FILE)
    assert pixel_options.get_pixel_mapping_table_size() == CORRECT_OCTA_FACES
def test_UI_GIVEN_cylinder_number_WHEN_entering_pixel_mapping_THEN_pixel_mapping_list_is_populated_with_correct_number_of_widgets(
    qtbot, template, pixel_options
):

    cylinder_number = 6
    systematic_button_press(qtbot, template, pixel_options.entire_shape_radio_button)
    pixel_options.populate_pixel_mapping_list_with_cylinder_number(cylinder_number)
    assert pixel_options.pixel_mapping_list_widget.count() == cylinder_number
Esempio n. 7
0
def test_UI_GIVEN_user_selects_entire_shape_WHEN_choosing_pixel_layout_THEN_pixel_mapping_becomes_visible(
        qtbot, template, pixel_options):
    # Press the entire shape button under pixel layout
    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)

    # Check that the pixel mapping items are visible
    assert pixel_options.pixel_options_stack.isVisible()
    assert pixel_options.pixel_options_stack.currentIndex() == 1
Esempio n. 8
0
def test_UI_GIVEN_mesh_file_WHEN_generating_mapping_list_THEN_filename_returned_by_pixel_options_matches_filename_of_mesh(
        qtbot, template, pixel_options):

    filename = "a/mesh/file.off"

    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)
    manually_create_pixel_mapping_list(pixel_options, filename=filename)

    assert pixel_options.get_current_mapping_filename() == filename
Esempio n. 9
0
def test_UI_GIVEN_user_switches_from_mesh_to_cylinder_WHEN_creating_cylindrical_geometry_THEN_pixel_mapping_filename_is_changed_to_none(
        qtbot, template, pixel_options):

    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)
    manually_create_pixel_mapping_list(pixel_options)

    pixel_options.populate_pixel_mapping_list_with_cylinder_number(12)

    assert pixel_options.get_current_mapping_filename() is None
def test_UI_GIVEN_user_selects_single_pixel_WHEN_changing_pixel_layout_THEN_pixel_grid_becomes_visible(
    qtbot, template, pixel_options
):

    # Single pixel is selected by default so switch to entire shape then switch back
    systematic_button_press(qtbot, template, pixel_options.entire_shape_radio_button)
    systematic_button_press(qtbot, template, pixel_options.single_pixel_radio_button)

    assert pixel_options.pixel_options_stack.isVisible()
    assert pixel_options.pixel_options_stack.currentIndex() == 0
Esempio n. 11
0
def test_UI_GIVEN_user_selects_pixel_grid_WHEN_changing_pixel_layout_THEN_pixel_grid_is_set_to_true_in_ok_validator(
        qtbot, template, pixel_options):

    # Press the pixel grid button
    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)

    # Check that the pixel grid boolean has become true
    assert pixel_options._pixel_validator.pixel_grid_is_valid
    # Check that the pixel_mapping boolean has become false
    assert not pixel_options._pixel_validator.pixel_mapping_is_valid
Esempio n. 12
0
def test_UI_GIVEN_user_opens_two_different_files_WHEN_creating_off_geometry_THEN_filename_stored_by_pixel_options_changes(
        qtbot, template, pixel_options):

    first_filename = "a/mesh/file.off"
    second_filename = "a/different/mesh/file.off"

    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)
    manually_create_pixel_mapping_list(pixel_options, filename=first_filename)
    manually_create_pixel_mapping_list(pixel_options, filename=second_filename)

    assert pixel_options.get_current_mapping_filename() == second_filename
Esempio n. 13
0
def test_UI_GIVEN_cylinder_number_changes_WHEN_entering_pixel_mapping_THEN_pixel_mapping_list_changes(
        qtbot, template, pixel_options):

    first_cylinder_number = 6
    second_cylinder_number = first_cylinder_number - 1
    systematic_button_press(qtbot, template,
                            pixel_options.entire_shape_radio_button)
    pixel_options.populate_pixel_mapping_list_with_cylinder_number(
        first_cylinder_number)
    pixel_options.populate_pixel_mapping_list_with_cylinder_number(
        second_cylinder_number)
    assert pixel_options.get_pixel_mapping_table_size(
    ) == second_cylinder_number
def test_UI_GIVEN_user_switches_to_pixel_mapping_WHEN_creating_component_THEN_pixel_mapping_signal_is_emitted(
    qtbot, template, pixel_options
):

    global emitted
    emitted = False

    def check_that_signal_is_emitted():
        global emitted
        emitted = not emitted

    pixel_options.pixel_mapping_button_pressed.connect(check_that_signal_is_emitted)
    systematic_button_press(qtbot, template, pixel_options.entire_shape_radio_button)
    assert emitted
def test_UI_GIVEN_valid_pixel_grid_WHEN_entering_pixel_options_THEN_changing_to_pixel_mapping_causes_validity_to_change(
    qtbot, template, pixel_options
):

    # Change the first ID
    qtbot.keyClick(pixel_options.first_id_spin_box, Qt.Key_Up)
    qtbot.keyClick(pixel_options.first_id_spin_box, Qt.Key_Up)
    show_and_close_window(qtbot, template)

    assert pixel_options._pixel_validator.unacceptable_pixel_states() == [False, False]

    # Switch to pixel mapping
    systematic_button_press(qtbot, template, pixel_options.entire_shape_radio_button)

    assert pixel_options._pixel_validator.unacceptable_pixel_states() == [False, True]
Esempio n. 16
0
def test_GIVEN_pixel_grid_information_WHEN_creating_pixel_grid_THEN_calling_generate_pixel_data_returns_grid_that_matches_user_input(
        qtbot, template, pixel_options):

    systematic_button_press(qtbot, template,
                            pixel_options.single_pixel_radio_button)

    pixel_grid = pixel_options.generate_pixel_data()

    assert pixel_grid.rows == 1
    assert pixel_grid.columns == 1
    assert pixel_grid.row_height == 0.5
    assert pixel_grid.col_width == 0.5
    assert pixel_grid.first_id == 0
    assert pixel_grid.initial_count_corner == INITIAL_COUNT_CORNER[
        "Bottom Left"]
    assert pixel_grid.count_direction == COUNT_DIRECTION["Rows"]
def test_UI_GIVEN_mapping_list_provided_by_user_WHEN_entering_pixel_data_THEN_calling_generate_pixel_data_returns_mapping_with_list_that_matches_user_input(
    qtbot, template, pixel_options
):

    systematic_button_press(qtbot, template, pixel_options.entire_shape_radio_button)
    num_faces = 6
    expected_id_list = [i if i % 2 != 0 else None for i in range(num_faces)]
    manually_create_pixel_mapping_list(pixel_options)

    for i in range(num_faces):
        qtbot.keyClicks(
            pixel_options.pixel_mapping_widgets[i].pixelIDLineEdit,
            str(expected_id_list[i]),
        )

    assert pixel_options.generate_pixel_data().pixel_ids == expected_id_list
def test_UI_GIVEN_invalid_pixel_mapping_WHEN_entering_pixel_options_THEN_changing_to_valid_pixel_grid_causes_validity_to_change(
    qtbot, template, pixel_options
):

    # Change to pixel mapping
    systematic_button_press(qtbot, template, pixel_options.entire_shape_radio_button)

    manually_create_pixel_mapping_list(pixel_options)

    # Give input that will be rejected by the validator
    qtbot.keyClicks(pixel_options.pixel_mapping_widgets[0].pixelIDLineEdit, "abc")

    # Switch to pixel grid
    systematic_button_press(qtbot, template, pixel_options.single_pixel_radio_button)

    # Check that the test for unacceptable pixel states gives False
    assert pixel_options._pixel_validator.unacceptable_pixel_states() == [False, False]
Esempio n. 19
0
def test_UI_GIVEN_no_pixels_button_is_pressed_WHEN_entering_pixel_data_THEN_calling_generate_pixel_data_returns_none(
        qtbot, template, pixel_options):

    systematic_button_press(qtbot, template, pixel_options.no_pixels_button)
    assert pixel_options.generate_pixel_data() is None