parent
bb8e164f21
commit
2190628e82
@ -52,6 +52,7 @@ MACOS_OPTIONS = make_click_option_decorator(
|
||||
@click.command()
|
||||
@DB_OPTION
|
||||
@JSON_OPTION
|
||||
@click.option("--count", is_flag=True, help="Print count of photos matching query and exit.")
|
||||
@QUERY_OPTIONS
|
||||
@DELETED_OPTIONS
|
||||
@MACOS_OPTIONS
|
||||
@ -82,6 +83,7 @@ def query(
|
||||
db,
|
||||
field,
|
||||
json_,
|
||||
count,
|
||||
print_template,
|
||||
quiet,
|
||||
photos_library,
|
||||
@ -137,6 +139,10 @@ def query(
|
||||
# below needed for to make CliRunner work for testing
|
||||
cli_json = cli_obj.json if cli_obj is not None else None
|
||||
|
||||
if count:
|
||||
click.echo(len(photos))
|
||||
return
|
||||
|
||||
if add_to_album and photos:
|
||||
assert_macos()
|
||||
|
||||
|
||||
@ -8176,6 +8176,46 @@ def test_query_added_in_last():
|
||||
assert results.exit_code == 0
|
||||
|
||||
|
||||
def test_query_count():
|
||||
"""Test query --count"""
|
||||
|
||||
runner = CliRunner()
|
||||
cwd = os.getcwd()
|
||||
# pylint: disable=not-context-manager
|
||||
results = runner.invoke(
|
||||
query,
|
||||
[
|
||||
"--library",
|
||||
os.path.join(cwd, PHOTOS_DB_15_7),
|
||||
"--added-before",
|
||||
"2019-07-28",
|
||||
"--count",
|
||||
],
|
||||
)
|
||||
assert results.exit_code == 0
|
||||
assert results.output.strip() == "7"
|
||||
|
||||
|
||||
def test_query_count_0():
|
||||
"""Test query --count with zero results"""
|
||||
|
||||
runner = CliRunner()
|
||||
cwd = os.getcwd()
|
||||
# pylint: disable=not-context-manager
|
||||
results = runner.invoke(
|
||||
query,
|
||||
[
|
||||
"--library",
|
||||
os.path.join(cwd, PHOTOS_DB_15_7),
|
||||
"--added-before",
|
||||
"1900-01-01",
|
||||
"--count",
|
||||
],
|
||||
)
|
||||
assert results.exit_code == 0
|
||||
assert results.output.strip() == "0"
|
||||
|
||||
|
||||
def test_export_export_dir_template():
|
||||
"""Test {export_dir} template"""
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user