Skip to content

Commit

Permalink
Add tests for cli parser
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Jan 25, 2024
1 parent 5ceab6c commit 4be31c0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
51 changes: 51 additions & 0 deletions tests/client_unit_test/test_cli_parse_search_files.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion tests/integration_test/test_search_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import subprocess
from hera_librarian import cli


def test_simple_name_search(librarian_client_command_line, garbage_file):
Expand All @@ -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)

0 comments on commit 4be31c0

Please sign in to comment.