Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Refactor tests into unit and functional #589

Merged
merged 10 commits into from
Oct 6, 2023
Merged
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ repos:
args:
[
'--output-format=parseable',
'--disable=missing-class-docstring,missing-function-docstring,protected-access',
'--disable=duplicate-code',
'--disable=missing-class-docstring',
'--disable=missing-function-docstring',
'--disable=protected-access',
'--rcfile=pylintrc',
]
4 changes: 2 additions & 2 deletions src/pymovements/gaze/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def from_csv(

>>> from pymovements.gaze.io import from_csv
>>> gaze = from_csv(
... file='tests/gaze/io/files/monocular_example.csv',
... file='tests/files/monocular_example.csv',
... time_column = 'time',
... pixel_columns = ['x_left_pix','y_left_pix'],)
>>> gaze.frame
Expand Down Expand Up @@ -189,7 +189,7 @@ def from_ipc(

>>> from pymovements.gaze.io import from_ipc
>>> gaze = from_ipc(
... file='tests/gaze/io/files/monocular_example.feather',
... file='tests/files/monocular_example.feather',
... )
>>> gaze.frame
shape: (10, 2)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,59 +43,59 @@
def fixture_gaze_init_kwargs(request):
init_param_dict = {
'csv_monocular': {
'file': 'tests/gaze/io/files/monocular_example.csv',
'file': 'tests/files/monocular_example.csv',
'time_column': 'time', 'pixel_columns': ['x_left_pix', 'y_left_pix'],
'experiment': pm.Experiment(1024, 768, 38, 30, 60, 'center', 1000),
},
'csv_binocular': {
'file': 'tests/gaze/io/files/binocular_example.csv',
'file': 'tests/files/binocular_example.csv',
'time_column': 'time',
'pixel_columns': ['x_left_pix', 'y_left_pix', 'x_right_pix', 'y_right_pix'],
'position_columns': ['x_left_pos', 'y_left_pos', 'x_right_pos', 'y_right_pos'],
'experiment': pm.Experiment(1024, 768, 38, 30, 60, 'center', 1000),
},
'ipc_monocular': {
'file': 'tests/gaze/io/files/monocular_example.feather',
'file': 'tests/files/monocular_example.feather',
'experiment': pm.Experiment(1024, 768, 38, 30, 60, 'center', 1000),
},
'ipc_binocular': {
'file': 'tests/gaze/io/files/binocular_example.feather',
'file': 'tests/files/binocular_example.feather',
'experiment': pm.Experiment(1024, 768, 38, 30, 60, 'center', 1000),
},
'hbn': {
'file': 'tests/gaze/io/files/hbn_example.csv',
'file': 'tests/files/hbn_example.csv',
'time_column': pm.datasets.HBN().time_column,
'pixel_columns': pm.datasets.HBN().pixel_columns,
'experiment': pm.datasets.HBN().experiment,
},
'sbsat': {
'file': 'tests/gaze/io/files/sbsat_example.csv',
'file': 'tests/files/sbsat_example.csv',
'time_column': pm.datasets.SBSAT().time_column,
'pixel_columns': pm.datasets.SBSAT().pixel_columns,
'experiment': pm.datasets.SBSAT().experiment,
**pm.datasets.SBSAT().custom_read_kwargs,
},
'gaze_on_faces': {
'file': 'tests/gaze/io/files/gaze_on_faces_example.csv',
'file': 'tests/files/gaze_on_faces_example.csv',
'time_column': pm.datasets.GazeOnFaces().time_column,
'pixel_columns': pm.datasets.GazeOnFaces().pixel_columns,
'experiment': pm.datasets.GazeOnFaces().experiment,
**pm.datasets.GazeOnFaces().custom_read_kwargs,
},
'gazebase': {
'file': 'tests/gaze/io/files/gazebase_example.csv',
'file': 'tests/files/gazebase_example.csv',
'time_column': pm.datasets.GazeBase().time_column,
'position_columns': pm.datasets.GazeBase().position_columns,
'experiment': pm.datasets.GazeBase().experiment,
},
'gazebase_vr': {
'file': 'tests/gaze/io/files/gazebase_vr_example.csv',
'file': 'tests/files/gazebase_vr_example.csv',
'time_column': pm.datasets.GazeBaseVR().time_column,
'position_columns': pm.datasets.GazeBaseVR().position_columns,
'experiment': pm.datasets.GazeBaseVR().experiment,
},
'judo1000': {
'file': 'tests/gaze/io/files/judo1000_example.csv',
'file': 'tests/files/judo1000_example.csv',
'time_column': pm.datasets.JuDo1000().time_column,
'pixel_columns': pm.datasets.JuDo1000().pixel_columns,
'experiment': pm.datasets.JuDo1000().experiment,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions tests/gaze/io/csv_test.py → tests/unit/gaze/io/csv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
[
pytest.param(
{
'file': 'tests/gaze/io/files/monocular_example.csv',
'file': 'tests/files/monocular_example.csv',
'time_column': 'time',
'pixel_columns': ['x_left_pix', 'y_left_pix'],
},
Expand All @@ -37,7 +37,7 @@
),
pytest.param(
{
'file': 'tests/gaze/io/files/binocular_example.csv',
'file': 'tests/files/binocular_example.csv',
'time_column': 'time',
'pixel_columns': ['x_left_pix', 'y_left_pix', 'x_right_pix', 'y_right_pix'],
'position_columns': ['x_left_pos', 'y_left_pos', 'x_right_pos', 'y_right_pos'],
Expand All @@ -47,7 +47,7 @@
),
pytest.param(
{
'file': 'tests/gaze/io/files/hbn_example.csv',
'file': 'tests/files/hbn_example.csv',
'time_column': pm.datasets.HBN().time_column,
'pixel_columns': pm.datasets.HBN().pixel_columns,
},
Expand All @@ -56,7 +56,7 @@
),
pytest.param(
{
'file': 'tests/gaze/io/files/sbsat_example.csv',
'file': 'tests/files/sbsat_example.csv',
'time_column': pm.datasets.SBSAT().time_column,
'pixel_columns': pm.datasets.SBSAT().pixel_columns,
**pm.datasets.SBSAT().custom_read_kwargs,
Expand All @@ -66,7 +66,7 @@
),
pytest.param(
{
'file': 'tests/gaze/io/files/gazebase_example.csv',
'file': 'tests/files/gazebase_example.csv',
'time_column': pm.datasets.GazeBase().time_column,
'position_columns': pm.datasets.GazeBase().position_columns,
**pm.datasets.GazeBase().custom_read_kwargs,
Expand All @@ -76,7 +76,7 @@
),
pytest.param(
{
'file': 'tests/gaze/io/files/gaze_on_faces_example.csv',
'file': 'tests/files/gaze_on_faces_example.csv',
'time_column': pm.datasets.GazeOnFaces().time_column,
'pixel_columns': pm.datasets.GazeOnFaces().pixel_columns,
**pm.datasets.GazeOnFaces().custom_read_kwargs,
Expand All @@ -86,7 +86,7 @@
),
pytest.param(
{
'file': 'tests/gaze/io/files/gazebase_vr_example.csv',
'file': 'tests/files/gazebase_vr_example.csv',
'time_column': pm.datasets.GazeBaseVR().time_column,
'position_columns': pm.datasets.GazeBaseVR().position_columns,
},
Expand All @@ -95,7 +95,7 @@
),
pytest.param(
{
'file': 'tests/gaze/io/files/judo1000_example.csv',
'file': 'tests/files/judo1000_example.csv',
'time_column': pm.datasets.JuDo1000().time_column,
'pixel_columns': pm.datasets.JuDo1000().pixel_columns,
**pm.datasets.JuDo1000().custom_read_kwargs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
[
pytest.param(
{
'file': 'tests/gaze/io/files/monocular_example.feather',
'file': 'tests/files/monocular_example.feather',
},
(10, 2),
id='feather_mono_shape',
),
pytest.param(
{
'file': 'tests/gaze/io/files/binocular_example.feather',
'file': 'tests/files/binocular_example.feather',
},
(10, 3),
id='feather_bino_shape',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ def test_pix2deg_raises_error(kwargs, series, exception, msg_substrings):
),
],
)
@pytest.mark.parametrize(
'distance_as_column',
[
pytest.param(True, id='column_distance'),
pytest.param(False, id='scalar_distance'),
],
)
def test_pix2deg_returns(kwargs, series, expected_df, distance_as_column):
df = series.to_frame().clone()
kwargs = kwargs.copy()
Expand Down Expand Up @@ -640,8 +647,3 @@ def test_pix2deg_distance_as_colum_returns(kwargs, data, expected_df):
)

assert_frame_equal(result_df, expected_df.to_frame())


@pytest.fixture(params=[True, False], ids=['column_distance', 'scalar_distance'])
def distance_as_column(request):
return request.param
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ def fixture_unsupported_archive(request, tmp_path):
),
],
)
def test_extract_archive_destination_path_None(
recursive, remove_finished, expected_files, archive, tmp_path,
):
def test_extract_archive_destination_path_None(recursive, remove_finished, expected_files, archive):
extract_archive(
source_path=archive,
destination_path=None,
Expand All @@ -271,9 +269,7 @@ def test_extract_archive_destination_path_None(
pytest.param(True, True, id='recursive_true_remove_finished_true'),
],
)
def test_extract_compressed_file_destination_path_None(
recursive, remove_finished, compressed_file, tmp_path,
):
def test_extract_compressed_file_destination_path_None(recursive, remove_finished, compressed_file):
extract_archive(
source_path=compressed_file,
destination_path=None,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.