Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tschm committed Jul 31, 2023
1 parent 09584ef commit 72ae19b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cvx/cli/smallest_eigenvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def smallest_ev(bson_file) -> None:
print(np.min(np.linalg.eigh(matrix)[0]))


def main():
def main(): # pragma: no cover
fire.Fire(smallest_ev)
Empty file removed tests/resources/.gitkeep
Empty file.
Binary file added tests/resources/test.bson
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/test_smallest_eigenvalue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from cvx.cli.smallest_eigenvalue import smallest_ev


def test_smallest_eigenvalue(resource_dir):
file = resource_dir / "test.bson"

smallest_ev(file)

2 changes: 0 additions & 2 deletions tests/test_trivial.py

This file was deleted.

24 changes: 24 additions & 0 deletions tests/test_weather.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
import mock

from cvx.cli.weather import cli

def test_weather():
temperature = cli(metric="temperature")
print(temperature)
assert isinstance(temperature, float)
assert temperature > -50
assert temperature < 50


def test_missing_metric():
with pytest.raises(ValueError):
cli(metric="maffay")


def test_server_down():
with mock.patch("requests.get", return_value=mock.Mock(status_code=500)):
with pytest.raises(ConnectionError):
cli("temperature")


0 comments on commit 72ae19b

Please sign in to comment.