Files
osxphotos/tests/test_cli_add_locations.py
dvdkon ca3da647f2 Port to non-MacOS platforms (#1026)
* Port to non-MacOS platforms

* Keep NFD normalization on macOS

* Update locale_util.py

Fix lint error from ruff (runs in CI)

* Update query.py

click.Option first arg needs to be a list (different than click.option)

* Dynamically normalize Unicode paths in test

* Fix missing import

---------

Co-authored-by: Rhet Turnbull <rturnbull@gmail.com>
2023-05-07 06:55:56 -07:00

57 lines
1.8 KiB
Python

"""Test osxphotos add-locations command"""
import pytest
from click.testing import CliRunner
from osxphotos.utils import is_macos
if is_macos:
import photoscript
from osxphotos.cli.add_locations import add_locations
else:
pytest.skip(allow_module_level=True)
UUID_TEST_PHOTO_1 = "F12384F6-CD17-4151-ACBA-AE0E3688539E" # Pumkins1.jpg
UUID_TEST_PHOTO_LOCATION = "D79B8D77-BFFC-460B-9312-034F2877D35B" # Pumkins2.jpg
TEST_LOCATION = (41.26067, -95.94056) # Omaha, NE
@pytest.mark.test_add_locations
def test_add_locations():
"""Test add-locations command"""
with CliRunner().isolated_filesystem():
# need to clear location data from test photo
test_photo = photoscript.Photo(UUID_TEST_PHOTO_1)
test_photo.location = None
source_photo = photoscript.Photo(UUID_TEST_PHOTO_LOCATION)
source_photo.location = TEST_LOCATION
# now run add-locations
result = CliRunner().invoke(
add_locations,
[
"--window",
"2 hours",
"--dry-run",
],
)
assert result.exit_code == 0
# should find 3 matching locations: Pumkins1.jpg, Pumpkins3.jpg, Pumpkins4.jpg
assert "found location: 3" in result.output
# verify location not really added
assert test_photo.location == (None, None)
# run again without dry-run
result = CliRunner().invoke(
add_locations,
[
"--window",
"2 hours",
],
)
assert result.exit_code == 0
# should find 3 matching locations: Pumkins1.jpg, Pumpkins3.jpg, Pumpkins4.jpg
assert "found location: 3" in result.output
assert test_photo.location == TEST_LOCATION