diff --git a/setup.cfg b/setup.cfg index 4e745ac..1bc05fb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 = diff --git a/tests/test_jsonFileDB.py b/tests/test_jsonFileDB.py deleted file mode 100644 index 8a0280a..0000000 --- a/tests/test_jsonFileDB.py +++ /dev/null @@ -1,67 +0,0 @@ -import unittest - -# from aerovaldb.jsonfiledb import AerovalJsonFileDB -import aerovaldb -from aerovaldb.jsonfiledb import AccessType -from parameterized import parameterized_class - - -class TestJsonFileDB(unittest.TestCase): - """ """ - - def test_plugins(self): - engines = aerovaldb.list_engines() - print(engines) - self.assertGreaterEqual(len(engines), 1) - - def test_get_glob_stats(self): - with aerovaldb.open(f"json_files:./tests/test-db/json") as db: - data = db.get_glob_stats( - "project", "experiment", "frequency", access_type=AccessType.OBJ - ) - - self.assertEqual(data["path"], "./project/experiment/hm/") - - def test_put_glob_stats(self): - # 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") - - self.assertEqual(obj["data"], read_data["data"]) - - def test_get_contour(self): - with aerovaldb.open(f"json_files:./tests/test-db/json") as db: - data = db.get_contour("project", "experiment") - - self.assertEqual(data["path"], "./project/experiment/contour/") - - def test_put_contour(self): - 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") - - self.assertEqual(obj["data"], read_data["data"]) - - def test_get_ts(self): - with aerovaldb.open(f"json_files:./tests/test-db/json") as db: - data = db.get_ts( - "project", "experiment", "region", "network", "obsvar", "layer" - ) - - self.assertEqual(data["path"], "./project/experiment/ts/") - - def test_put_ts(self): - 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") - - self.assertEqual(obj["data"], read_data["data"]) diff --git a/tests/test_jsonfiledb.py b/tests/test_jsonfiledb.py new file mode 100644 index 0000000..cc0c15e --- /dev/null +++ b/tests/test_jsonfiledb.py @@ -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"] diff --git a/tests/test_plugins.py b/tests/test_plugins.py new file mode 100644 index 0000000..91c4dee --- /dev/null +++ b/tests/test_plugins.py @@ -0,0 +1,7 @@ +import pytest +import aerovaldb + +def test_plugins(): + engines = aerovaldb.list_engines() + print(engines) + assert len(engines) >= 1 \ No newline at end of file