Skip to content

Commit 1ec0f90

Browse files
committed
test_validate: Fix tests, reformat
Now has two arguments, passing possible options first.
1 parent ac3693c commit 1ec0f90

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

hypnotoad/test_suite/test_validate.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
from hypnotoad.agent import tools
2+
from hypnotoad.cases import tokamak
3+
from hypnotoad.core.mesh import BoutMesh
4+
5+
POSSIBLE_OPTIONS = (
6+
tokamak.TokamakEquilibrium.user_options_factory.defaults
7+
| tokamak.TokamakEquilibrium.nonorthogonal_options_factory.defaults
8+
| BoutMesh.user_options_factory.defaults
9+
)
210

311

412
def test_validate_unknown_key():
513
# Using an invalid key should lead to an issue and suggestion
6-
assert tools.validate_settings({"nxcore": 10}) == {
14+
assert tools.validate_settings(POSSIBLE_OPTIONS, {"nxcore": 10}) == {
715
"valid": False,
816
"issues": {
917
"nxcore": {
@@ -17,7 +25,7 @@ def test_validate_unknown_key():
1725

1826
def test_validate_wrong_type():
1927
# Using the wrong type
20-
assert tools.validate_settings({"nx_core": 3.4}) == {
28+
assert tools.validate_settings(POSSIBLE_OPTIONS, {"nx_core": 3.4}) == {
2129
"valid": False,
2230
"issues": {
2331
"nx_core": {
@@ -31,7 +39,9 @@ def test_validate_wrong_type():
3139

3240

3341
def test_validate_invalid_value():
34-
assert tools.validate_settings({"curvature_type": "nonsense"}) == {
42+
assert tools.validate_settings(
43+
POSSIBLE_OPTIONS, {"curvature_type": "nonsense"}
44+
) == {
3545
"valid": False,
3646
"issues": {
3747
"curvature_type": {
@@ -45,7 +55,7 @@ def test_validate_invalid_value():
4555

4656

4757
def test_validate_out_of_bounds():
48-
assert tools.validate_settings({"refine_width": -1.0}) == {
58+
assert tools.validate_settings(POSSIBLE_OPTIONS, {"refine_width": -1.0}) == {
4959
"valid": False,
5060
"issues": {
5161
"refine_width": {

0 commit comments

Comments
 (0)