Feature UUID from stdin 965 (#979)

* Allow --uuid-from-file to read from stdin, #965

* Load query options before opening the database
This commit is contained in:
Rhet Turnbull
2023-02-11 09:26:42 -08:00
committed by GitHub
parent f7ca3977a9
commit 97a0a65d8a
11 changed files with 100 additions and 27 deletions

View File

@@ -1176,6 +1176,25 @@ def test_query_uuid_from_file_1():
assert sorted(UUID_EXPECTED_FROM_FILE) == sorted(uuid_got)
def test_query_uuid_from_file_stdin():
"""Test query with --uuid-from-file reading from stdin"""
runner = CliRunner()
cwd = os.getcwd()
input_text = open(UUID_FILE, "r").read()
result = runner.invoke(
query,
["--json", "--db", os.path.join(cwd, PHOTOS_DB_15_7), "--uuid-from-file", "-"],
input=input_text,
)
assert result.exit_code == 0
# build list of uuids we got from the output JSON
json_got = json.loads(result.output)
uuid_got = [photo["uuid"] for photo in json_got]
assert sorted(UUID_EXPECTED_FROM_FILE) == sorted(uuid_got)
def test_query_has_comment():
"""Test query with --has-comment"""