diff --git a/tests/client_unit_test/test_cli_parse_search_files.py b/tests/client_unit_test/test_cli_parse_search_files.py new file mode 100644 index 0000000..3428998 --- /dev/null +++ b/tests/client_unit_test/test_cli_parse_search_files.py @@ -0,0 +1,51 @@ +""" +Tests the search-files parser. +""" + +import datetime + +import dateutil.parser + +from hera_librarian import cli + + +def test_parser_simple_name(): + parser = cli.generate_parser() + + args = parser.parse_args( + [ + "search-files", + "fake_connection", + "--name=test_file", + ] + ) + + assert args.name == "test_file" + + +def test_parser_lots(): + parser = cli.generate_parser() + + args = parser.parse_args( + [ + "search-files", + "fake_connection", + "--name=test_file", + "--create-time-start=2020-01-01", + "--create-time-end=2020-01-02", + "--uploader=uploader", + "--source=source", + "--max-results=10", + ] + ) + + assert args.name == "test_file" + assert dateutil.parser.parse(args.create_time_start) == datetime.datetime( + year=2020, month=1, day=1 + ) + assert dateutil.parser.parse(args.create_time_end) == datetime.datetime( + year=2020, month=1, day=2 + ) + assert args.uploader == "uploader" + assert args.source == "source" + assert args.max_results == 10 diff --git a/tests/integration_test/test_search_file.py b/tests/integration_test/test_search_file.py index ad42e95..1ec7134 100644 --- a/tests/integration_test/test_search_file.py +++ b/tests/integration_test/test_search_file.py @@ -3,6 +3,7 @@ """ import subprocess +from hera_librarian import cli def test_simple_name_search(librarian_client_command_line, garbage_file): @@ -25,4 +26,4 @@ def test_simple_name_search(librarian_client_command_line, garbage_file): ] ) - assert "test_file_for_searching" in str(captured) + assert "test_file_for_searching" in str(captured) \ No newline at end of file