preview package

viewer_test module

Unittests for the viewer module

Pytest unit tests for tools.preview.viewer

class tests.tools.preview.viewer_test.TestFacesDisplay

Bases: object

Test :class:`~tools.preview.viewer.FacesDisplay

get_faces_display_instance(columns: int = 5, face_size: int = 256) FacesDisplay

Obtain an instance of FacesDisplay with the given column and face size layout.

Parameters:
  • columns (int, optional) – The number of columns to display in the viewer, default: 5

  • face_size (int, optional) – The size of each face image to be displayed in the viewer, default: 256

Returns:

An instance of the FacesDisplay class at the given settings

Return type:

FacesDisplay

test__build_faces_image(columns: int, face_size: int, mocker: MockerFixture) None

Test FacesDisplay _build_faces_image method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

  • mocker (pytest_mock.MockerFixture) – Mocker for checking internal methods called

test__crop_destination_faces(columns: int, face_size: int, mocker: MockerFixture) None

Test FacesDisplay _crop_destination_faces method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

  • mocker (pytest_mock.MockerFixture) – Mocker for dummying in full frames

test__crop_source_faces(columns: int, face_size: int, monkeypatch: MonkeyPatch, mocker: MockerFixture) None

Test FacesDisplay _crop_source_faces method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

  • monkeypatch (pytest.MonkeyPatch) – For patching the transform_image function

  • mocker (pytest_mock.MockerFixture) – Mocker for mocking various internal methods

test__draw_rect_text(columns: int, face_size: int, mocker: MockerFixture) None

Test FacesDisplay _draw_rect method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

  • mocker (pytest_mock.MockerFixture) – Mocker for dummying in cv2 calls

test__header_text(columns: int, face_size: int, mocker: MockerFixture) None

Test FacesDisplay _header_text method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

  • mocker (pytest_mock.MockerFixture) – Mocker for dummying in cv2 calls

test__total_columns(columns: int, face_size: int) None

Test FacesDisplay _total_columns property is correctly calculated

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

test_faces__from_frames(columns, face_size, mocker: MockerFixture) None

Test FacesDisplay _from_frames method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

  • mocker (pytest_mock.MockerFixture) – Mocker for checking _build_faces_image method called

test_get_scale_size(columns: int, face_size: int) None

Test FacesDisplay get_scale_size method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

test_init() None

Test FacesDisplay __init__ method

test_set_centering() None

Test FacesDisplay set_centering method

test_set_display_dimensions() None

Test FacesDisplay set_display_dimensions method

test_update_tk_image(columns: int, face_size: int, mocker: MockerFixture) None

Test FacesDisplay update_tk_image method

Parameters:
  • columns (int) – The number of columns to display in the viewer

  • face_size (int) – The size of each face image to be displayed in the viewer

  • mocker (pytest_mock.MockerFixture) – Mocker for checking _build_faces_image method called

class tests.tools.preview.viewer_test.TestImagesCanvas

Bases: object

Test ImagesCanvas

images_canvas_fixture(parent) ImagesCanvas

Fixture for creating a testing ImagesCanvas instance

Parameters:

parent (unittest.mock.MagicMock) – The mocked ttk.PanedWindow parent

Returns:

The class instance for testing

Return type:

ImagesCanvas

parent() MagicMock

Mock object to act as the parent widget to the ImagesCanvas

Returns:

The mocked ttk.PanedWindow widget

Return type:

unittest.mock.MagicMock

test_init(images_canvas_instance: ImagesCanvas, parent: MagicMock) None

Test ImagesCanvas __init__ method

Parameters:
  • images_canvas_instance (ImagesCanvas) – The class instance to test

  • parent (unittest.mock.MagicMock) – The mocked parent ttk.PanedWindow

test_reload(images_canvas_instance: ImagesCanvas, parent: MagicMock, mocker: MockerFixture) None

Test ImagesCanvas reload method

Parameters:
  • images_canvas_instance (ImagesCanvas) – The class instance to test

  • parent (unittest.mock.MagicMock) – The mocked parent ttk.PanedWindow

  • mocker (pytest_mock.MockerFixture) – Mocker for dummying in tk calls

test_resize(images_canvas_instance: ImagesCanvas, parent: MagicMock, mocker: MockerFixture) None

Test ImagesCanvas resize method

Parameters:
  • images_canvas_instance (ImagesCanvas) – The class instance to test

  • parent (unittest.mock.MagicMock) – The mocked parent ttk.PanedWindow

  • mocker (pytest_mock.MockerFixture) – Mocker for dummying in tk calls

tests.tools.preview.viewer_test.test__faces()

Test the :class:`~tools.preview.viewer._Faces dataclass initializes correctly