-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for number of samples and point spacing when determining …
…the sample size
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |