From 521848f955465b506794ddbcbdaee6a109b0548d Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sat, 25 Dec 2021 05:53:26 -0800 Subject: [PATCH] Added export test for --exif --- tests/test_cli.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 878ebb09..49f40f1f 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -886,10 +886,12 @@ EXPORT_UNICODE_TITLE_FILENAMES = [ "Frítest (3).jpg", ] +# data for --exif QUERY_EXIF_DATA = [("EXIF:Make", "FUJIFILM", ["6191423D-8DB8-4D4C-92BE-9BBBA308AAC4"])] QUERY_EXIF_DATA_CASE_INSENSITIVE = [ ("Make", "Fujifilm", ["6191423D-8DB8-4D4C-92BE-9BBBA308AAC4"]) ] +EXPORT_EXIF_DATA = [("EXIF:Make", "FUJIFILM", ["Tulips.jpg", "Tulips_edited.jpeg"])] def modify_file(filename): @@ -4229,6 +4231,29 @@ def test_export_error(monkeypatch): assert "Error exporting" in result.output +@pytest.mark.skipif(exiftool is None, reason="exiftool not installed") +@pytest.mark.parametrize("exiftag,exifvalue,files_expected", EXPORT_EXIF_DATA) +def test_export_exif(exiftag, exifvalue, files_expected): + """Test export --exif query """ + import glob + import os + import os.path + + import osxphotos + from osxphotos.cli import export + + runner = CliRunner() + cwd = os.getcwd() + # pylint: disable=not-context-manager + with runner.isolated_filesystem(): + result = runner.invoke( + export, + [os.path.join(cwd, CLI_PHOTOS_DB), ".", "--exif", exiftag, exifvalue, "-V"], + ) + files = glob.glob("*") + assert sorted(files) == sorted(files_expected) + + def test_places(): import json import os