Skip to content

Commit

Permalink
test: Switch to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbjoernl committed May 23, 2024
1 parent d6bf764 commit 025442b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 72 deletions.
8 changes: 3 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ install_requires =
package_dir =
=src
packages = aerovaldb

[options.extras_require] # in setup.cfg
test =
tox
parameterized
test_require =
tox:tox
pytest

[options.entry_points]
aerovaldb =
Expand Down
67 changes: 0 additions & 67 deletions tests/test_jsonFileDB.py

This file was deleted.

49 changes: 49 additions & 0 deletions tests/test_jsonfiledb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import pytest
import aerovaldb

def test_get_glob_stats():
with aerovaldb.open(f"json_files:./tests/test-db/json") as db:
data = db.get_glob_stats(
"project", "experiment", "frequency", access_type="OBJ"
)
assert data["path"] == "./project/experiment/hm/"

def test_put_glob_stats():
# TODO: These tests should ideally cleanup after themselves. For now
# it is best to delete ./tests/test-db/tmp before running to verify
# that they run as intended.
with aerovaldb.open("json_files:./tests/test-db/tmp") as db:
obj = {"data": "gibberish"}
db.put_glob_stats(obj, "test1", "test2", "test3")
read_data = db.get_glob_stats("test1", "test2", "test3")

assert obj["data"] == read_data["data"]

def test_get_contour():
with aerovaldb.open(f"json_files:./tests/test-db/json") as db:
data = db.get_contour("project", "experiment")
assert data["path"] == "./project/experiment/contour/"

def test_put_contour():
with aerovaldb.open("json_files:./tests/test-db/tmp") as db:
obj = {"data": "gibberish"}
db.put_contour(obj, "test1", "test2")
read_data = db.get_contour("test1", "test2")
assert obj["data"] == read_data["data"]

def test_get_ts():
with aerovaldb.open(f"json_files:./tests/test-db/json") as db:
data = db.get_ts(
"project", "experiment", "region", "network", "obsvar", "layer"
)

assert data["path"] == "./project/experiment/ts/"

def test_put_ts():
with aerovaldb.open("json_files:./tests/test-db/tmp") as db:
obj = {"data": "gibberish"}
db.put_ts(obj, "test1", "test2", "test3", "test4", "test5", "test6")

read_data = db.get_ts("test1", "test2", "test3", "test4", "test5", "test6")

assert obj["data"] == read_data["data"]
7 changes: 7 additions & 0 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
import aerovaldb

def test_plugins():
engines = aerovaldb.list_engines()
print(engines)
assert len(engines) >= 1

0 comments on commit 025442b

Please sign in to comment.