Skip to content

Commit

Permalink
update tests of parameter classes
Browse files Browse the repository at this point in the history
ensure that values are actually correct instead of checking for succesfull initialization only
  • Loading branch information
schuenke committed Dec 18, 2023
1 parent 31538a5 commit 7080755
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion tests/parameters/test_CESTPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
def test_from_valid_params(r1, r2, k, f, dw, t1, t2):
"""Test CESTPool instantiation from valid parameters."""
a = CESTPool(r1=r1, r2=r2, k=k, f=f, dw=dw, t1=t1, t2=t2)
assert isinstance(a, CESTPool)

# assert that the attributes are set correctly
assert a.r1 == float(r1) if r1 is not None else 1 / float(t1)
assert a.r2 == float(r2) if r2 is not None else 1 / float(t2)
assert a.k == float(k)
assert a.f == float(f)
assert a.dw == float(dw)


@pytest.mark.parametrize(
Expand Down
7 changes: 6 additions & 1 deletion tests/parameters/test_Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
def test_from_valid_params(verbose, reset_init_mag, scale, max_pulse_samples):
"""Test Options instantiation from valid parameters."""
a = Options(verbose=verbose, reset_init_mag=reset_init_mag, scale=scale, max_pulse_samples=max_pulse_samples)
assert isinstance(a, Options)

# assert that the attributes are set correctly
assert a.verbose == bool(verbose)
assert a.reset_init_mag == bool(reset_init_mag)
assert a.scale == float(scale)
assert a.max_pulse_samples == int(max_pulse_samples)


@pytest.mark.parametrize(
Expand Down
7 changes: 6 additions & 1 deletion tests/parameters/test_PoolBaseClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
def test_from_valid_params(r1, r2, f, dw, t1, t2):
"""Test Pool instantiation from valid parameters."""
a = Pool(r1=r1, r2=r2, f=f, dw=dw, t1=t1, t2=t2)
assert isinstance(a, Pool)

# assert that the attributes are set correctly
assert a.r1 == float(r1) if r1 is not None else 1 / float(t1)
assert a.r2 == float(r2) if r2 is not None else 1 / float(t2)
assert a.f == float(f)
assert a.dw == float(dw)


@pytest.mark.parametrize(
Expand Down
6 changes: 5 additions & 1 deletion tests/parameters/test_WaterPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
def test_from_valid_params(r1, r2, f, t1, t2):
"""Test WaterPool instantiation from valid parameters."""
a = WaterPool(r1=r1, r2=r2, f=f, t1=t1, t2=t2)
assert isinstance(a, WaterPool)

# assert that the attributes are set correctly
assert a.r1 == float(r1) if r1 is not None else 1 / float(t1)
assert a.r2 == float(r2) if r2 is not None else 1 / float(t2)
assert a.f == float(f)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 7080755

Please sign in to comment.