Skip to content

Commit

Permalink
Added tests for number of samples and point spacing when determining …
Browse files Browse the repository at this point in the history
…the sample size
  • Loading branch information
XavierCLL committed Dec 15, 2024
1 parent bfba9ae commit 6a02b91
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_sample_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest

from AcATaMa.core import config


def test_get_n_calculates_correct_samples_simple(plugin, unwrap):
# restore
input_yml_path = pytest.tests_data_dir / "test_sample_size.yml"
config_restore = unwrap(config.restore)
config_restore(input_yml_path)
sampling_design = plugin.dockwidget.sampling_design_window

# set values
sampling_design.determine_number_samples_dialog_SimpRS.get_n()

assert sampling_design.determine_number_samples_dialog_SimpRS.NumberOfSamples.text() == "306"

def test_point_spacing_calculates_correct_samples_systematic(plugin, unwrap, monkeypatch):
# restore
input_yml_path = pytest.tests_data_dir / "test_sample_size.yml"
config_restore = unwrap(config.restore)
config_restore(input_yml_path)
sampling_design = plugin.dockwidget.sampling_design_window

determine_number_samples_dialog = sampling_design.determine_number_samples_dialog_SystS

# Replace QDialog.exec_ to always return QDialog.Accepted
monkeypatch.setattr(determine_number_samples_dialog, "exec_", lambda: determine_number_samples_dialog.Accepted)
sampling_design.determine_number_samples_dialog_SystS.get_n()

assert sampling_design.PointSpacing_SystS.value() == 1028.9

0 comments on commit 6a02b91

Please sign in to comment.