Skip to content

Commit

Permalink
test: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiderfelipe committed Oct 2, 2023
1 parent 4e5e8b9 commit 1fb0f5b
Show file tree
Hide file tree
Showing 14 changed files with 1,581 additions and 1,575 deletions.
18 changes: 10 additions & 8 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3 # noqa: INP001, EXE001

"""Tests for the application programming interface (API)."""

from __future__ import annotations

import numpy as np
import pytest

Expand All @@ -10,7 +10,8 @@
from overreact import coords


def test_get_enthalpies(): # noqa: D103
def test_get_enthalpies() -> None:
"""Ensure we can retrieve enthalpies."""
model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k")
assert rx.get_delta(
model.scheme.B,
Expand All @@ -21,7 +22,7 @@ def test_get_enthalpies(): # noqa: D103
)


def test_get_entropies():
def test_get_entropies() -> None:
"""Ensure get_entropies match some logfiles.
It is worth mentioning that, currently, ORCA uses QRRHO in entropy
Expand Down Expand Up @@ -58,7 +59,8 @@ def test_get_entropies():
)


def test_get_freeenergies(): # noqa: D103
def test_get_freeenergies() -> None:
"""Ensure we can retrieve free energies."""
model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k")
sym_correction = 298.15 * rx.change_reference_state(3, 1)

Expand All @@ -74,7 +76,7 @@ def test_get_freeenergies(): # noqa: D103
)


def test_compare_calc_star_with_get_star():
def test_compare_calc_star_with_get_star() -> None:
"""Ensure the calc_* functions match the get_* functions."""
model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k")
sym_correction = 298.15 * rx.change_reference_state(3, 1)
Expand All @@ -99,7 +101,7 @@ def test_compare_calc_star_with_get_star():
for bias in np.array([-1, 0, 1]) * constants.kcal:
for environment in ["gas", "solvent"]:
for qrrho in [True, False, (False, True)]:
qrrho_enthalpy, qrrho_entropy = rx.api._check_qrrho( # noqa: SLF001
qrrho_enthalpy, qrrho_entropy = rx.api._check_qrrho(
qrrho,
)
for temperature in [200, 298.15, 400]:
Expand Down Expand Up @@ -166,7 +168,7 @@ def test_compare_calc_star_with_get_star():
bias == 0
and environment == "gas"
and qrrho == (False, True)
and temperature == 298.15 # noqa: PLR2004
and temperature == 298.15
and pressure == constants.atm
# TODO(schneiderfelipe): do a test for H+(w)
and compound != "H+(w)"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#!/usr/bin/env python3 # noqa: INP001, EXE001

"""Tests for the command-line interface."""

from __future__ import annotations

from overreact import _cli as cli


def test_cli_compiles_source_file(monkeypatch):
def test_cli_compiles_source_file(monkeypatch) -> None:
"""Ensure the command-line interface can compile a source file (`.k`)."""
params = ["overreact", "--compile", "data/ethane/B97-3c/model.k"]
monkeypatch.setattr("sys.argv", params)
cli.main()


def test_cli_describes_source_file(monkeypatch):
def test_cli_describes_source_file(monkeypatch) -> None:
"""Ensure the command-line interface can describe a source file (`.k`)."""
params = ["overreact", "data/ethane/B97-3c/model.k"]
monkeypatch.setattr("sys.argv", params)
cli.main()


def test_cli_describes_model_file(monkeypatch):
def test_cli_describes_model_file(monkeypatch) -> None:
"""Ensure the command-line interface can describe a model file (`.jk`)."""
params = ["overreact", "data/ethane/B97-3c/model.jk"]
monkeypatch.setattr("sys.argv", params)
cli.main()


def test_cli_accepts_gaussian_logfiles(monkeypatch):
def test_cli_accepts_gaussian_logfiles(monkeypatch) -> None:
"""Ensure the command-line interface is OK with Gaussian logfiles."""
params = ["overreact", "data/acetate/Gaussian09/wB97XD/6-311++G**/model.k"]
monkeypatch.setattr("sys.argv", params)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_constants.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python3 # noqa: INP001, EXE001

"""Tests for constants module."""

from __future__ import annotations

import pytest

import overreact as rx
from overreact import _constants as constants


def test_reference_raw_constants():
def test_reference_raw_constants() -> None:
"""Ensure raw constants are close to values commonly used by the community.
Reference values were taken from the ones used by Gaussian 16
Expand All @@ -28,7 +28,7 @@ def test_reference_raw_constants():
) == pytest.approx(0.022710953)


def test_reference_conversion_factors():
def test_reference_conversion_factors() -> None:
"""Ensure conversion factors are close to values commonly used by the community.
Reference values were taken from the ones used by Gaussian 16
Expand Down
Loading

0 comments on commit 1fb0f5b

Please sign in to comment.