diff --git a/cosima_cookbook/database_update.py b/cosima_cookbook/database_update.py index 4182328e..a0785833 100755 --- a/cosima_cookbook/database_update.py +++ b/cosima_cookbook/database_update.py @@ -4,7 +4,7 @@ import cosima_cookbook as cc -def main(): +def main(argv=None): parser = argparse.ArgumentParser(description="Update COSIMA cookbook database.") parser.add_argument( "dirs", type=pathlib.Path, nargs="+", help="Directories to index." @@ -17,7 +17,7 @@ def main(): default="cosima_master.db", help="Database to update.", ) - args = parser.parse_args() + args = parser.parse_args(argv) print(cc) diff --git a/test/data/update/experiment_a/test1.nc b/test/data/update/experiment_a/test1.nc new file mode 100644 index 00000000..27f5ea7b Binary files /dev/null and b/test/data/update/experiment_a/test1.nc differ diff --git a/test/data/update/experiment_b/test2.nc b/test/data/update/experiment_b/test2.nc new file mode 100644 index 00000000..d3498cc5 Binary files /dev/null and b/test/data/update/experiment_b/test2.nc differ diff --git a/test/test_indexing.py b/test/test_indexing.py index 6855e1e5..67129094 100644 --- a/test/test_indexing.py +++ b/test/test_indexing.py @@ -38,7 +38,7 @@ def test_find_files(): # Test works with alternative suffix files = database.find_files("test/", "*.py") - assert len(files) == 8 + assert len(files) == 9 for f in files: assert Path(f).suffix == ".py" diff --git a/test/test_update.py b/test/test_update.py new file mode 100644 index 00000000..998d470a --- /dev/null +++ b/test/test_update.py @@ -0,0 +1,13 @@ +import shlex +from cosima_cookbook import database_update + + +def test_database_update(tmpdir): + + args = shlex.split( + "-db {db} test/data/update/experiment_a test/data/update/experiment_b".format( + db=tmpdir.join("test.db") + ) + ) + + database_update.main(args)