Updated to pytimeparse2, added tests for custom Click param types
This commit is contained in:
parent
fa991b8b48
commit
3ed658a7d0
@ -2,10 +2,11 @@
|
||||
import datetime
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
import bitmath
|
||||
import click
|
||||
import pytimeparse
|
||||
import pytimeparse2
|
||||
|
||||
from osxphotos.export_db_utils import export_db_get_version
|
||||
from osxphotos.photoinfo import PhotoInfoNone
|
||||
@ -159,19 +160,31 @@ class DateOffset(click.ParamType):
|
||||
name = "DATEOFFSET"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
offset = pytimeparse.parse(value)
|
||||
# if it's a single number treat it as days
|
||||
# but pytimeparse2 treats is as seconds so need to verify it's just a number and if so,
|
||||
# convert it to seconds
|
||||
value = value.strip()
|
||||
if re.match(r"^[+-]?\s*?\d+$", value):
|
||||
# just a number
|
||||
# strip any whitespace, e.g. for "+ 1" or "- 1"
|
||||
value = "".join(value.split())
|
||||
try:
|
||||
return datetime.timedelta(days=int(value))
|
||||
except ValueError:
|
||||
self.fail(
|
||||
f"Invalid date offset format: {value}. "
|
||||
"Valid format for date/time offset: '±D days', '±W weeks', '±M months', '±D' where D is days "
|
||||
)
|
||||
|
||||
offset = pytimeparse2.parse(value)
|
||||
if offset is not None:
|
||||
offset = offset / 86400
|
||||
return datetime.timedelta(days=offset)
|
||||
|
||||
# could be in format "-1" (negative offset) or "+1" (positive offset)
|
||||
try:
|
||||
return datetime.timedelta(days=int(value))
|
||||
except ValueError:
|
||||
self.fail(
|
||||
f"Invalid date offset format: {value}. "
|
||||
"Valid format for date/time offset: '±D days', '±W weeks', '±D' where D is days "
|
||||
)
|
||||
self.fail(
|
||||
f"Invalid date offset format: {value}. "
|
||||
"Valid format for date/time offset: '±D days', '±W weeks', '±M months', '±D' where D is days "
|
||||
)
|
||||
|
||||
|
||||
class TimeOffset(click.ParamType):
|
||||
@ -180,18 +193,14 @@ class TimeOffset(click.ParamType):
|
||||
name = "TIMEOFFSET"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
offset = pytimeparse.parse(value)
|
||||
offset = pytimeparse2.parse(value)
|
||||
if offset is not None:
|
||||
return datetime.timedelta(seconds=offset)
|
||||
|
||||
# could be in format "-18000" (negative offset) or "+18000" (positive offset)
|
||||
try:
|
||||
return datetime.timedelta(seconds=int(value))
|
||||
except ValueError:
|
||||
self.fail(
|
||||
f"Invalid time offset format: {value}. "
|
||||
"Valid format for date/time offset: '±HH:MM:SS', '±H hours' (or hr), '±M minutes' (or min), '±S seconds' (or sec), '±S' (where S is seconds)"
|
||||
)
|
||||
self.fail(
|
||||
f"Invalid time offset format: {value}. "
|
||||
"Valid format for date/time offset: '±HH:MM:SS', '±H hours' (or hr), '±M minutes' (or min), '±S seconds' (or sec), '±S' (where S is seconds)"
|
||||
)
|
||||
|
||||
|
||||
class UTCOffset(click.ParamType):
|
||||
|
||||
@ -8,7 +8,7 @@ import re
|
||||
|
||||
def utc_offset_string_to_seconds(utc_offset: str) -> int:
|
||||
"""match a UTC offset in format ±[hh]:[mm], ±[h]:[mm], or ±[hh][mm] and return number of seconds offset"""
|
||||
patterns = ["^([+-]?)(\d{1,2}):(\d{2})$", "^([+-]?)(\d{2})(\d{2})$"]
|
||||
patterns = [r"^([+-]?)(\d{1,2}):(\d{2})$", r"^([+-]?)(\d{2})(\d{2})$"]
|
||||
for pattern in patterns:
|
||||
match = re.match(pattern, utc_offset)
|
||||
if not match:
|
||||
@ -56,7 +56,7 @@ def update_datetime(
|
||||
return dt
|
||||
|
||||
|
||||
def time_string_to_datetime(time: str) -> datetime.datetime:
|
||||
def time_string_to_datetime(time: str) -> datetime.time:
|
||||
"""Convert time string to datetime.datetime"""
|
||||
|
||||
""" valid time formats:
|
||||
@ -74,7 +74,7 @@ def time_string_to_datetime(time: str) -> datetime.datetime:
|
||||
|
||||
for dt_format in time_formats:
|
||||
try:
|
||||
parsed_dt = datetime.datetime.strptime(time, dt_format)
|
||||
parsed_dt = datetime.datetime.strptime(time, dt_format).time()
|
||||
except ValueError as e:
|
||||
pass
|
||||
else:
|
||||
|
||||
@ -54,3 +54,8 @@ class Timezone:
|
||||
|
||||
def __repr__(self):
|
||||
return self.name
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Timezone):
|
||||
return self.timezone == other.timezone
|
||||
return False
|
||||
|
||||
@ -19,7 +19,7 @@ pyobjc-framework-Metal>=7.3,<9.0
|
||||
pyobjc-framework-Photos>=7.3,<9.0
|
||||
pyobjc-framework-Quartz>=7.3,<9.0
|
||||
pyobjc-framework-Vision>=7.3,<9.0
|
||||
pytimeparse==1.1.8
|
||||
pytimeparse2==1.4.0
|
||||
PyYAML>=5.4.1,<6.0.0
|
||||
requests>=2.27.1,<3.0.0
|
||||
rich>=11.2.0,<13.0.0
|
||||
|
||||
2
setup.py
2
setup.py
@ -95,7 +95,7 @@ setup(
|
||||
"pyobjc-framework-Photos>=7.3,<9.0",
|
||||
"pyobjc-framework-Quartz>=7.3,<9.0",
|
||||
"pyobjc-framework-Vision>=7.3,<9.0",
|
||||
"pytimeparse==1.1.8",
|
||||
"pytimeparse2==1.4.0",
|
||||
"requests>=2.27.1,<3.0.0",
|
||||
"rich>=11.2.0,<13.0.0",
|
||||
"rich_theme_manager>=0.11.0",
|
||||
|
||||
205
tests/test_cli_param_types.py
Normal file
205
tests/test_cli_param_types.py
Normal file
@ -0,0 +1,205 @@
|
||||
""" Test custom click paramater types used by osxphotos CLI"""
|
||||
|
||||
import datetime
|
||||
from bitmath import MB
|
||||
|
||||
import pytest
|
||||
|
||||
from osxphotos.timezones import Timezone
|
||||
|
||||
from click.exceptions import BadParameter
|
||||
|
||||
from osxphotos.cli.param_types import (
|
||||
BitMathSize,
|
||||
DateOffset,
|
||||
DateTimeISO8601,
|
||||
ExportDBType,
|
||||
FunctionCall,
|
||||
TemplateString,
|
||||
TimeISO8601,
|
||||
TimeOffset,
|
||||
TimeString,
|
||||
UTCOffset,
|
||||
)
|
||||
|
||||
|
||||
def test_date_offset():
|
||||
"""Test DateOffset"""
|
||||
date_offset_data = {
|
||||
"1": datetime.timedelta(days=1),
|
||||
"1 day": datetime.timedelta(days=1),
|
||||
"+1 day": datetime.timedelta(days=1),
|
||||
"1 d": datetime.timedelta(days=1),
|
||||
"1d": datetime.timedelta(days=1),
|
||||
"+ 1": datetime.timedelta(days=1),
|
||||
"+1 day": datetime.timedelta(days=1),
|
||||
"+ 1": datetime.timedelta(days=1),
|
||||
"14:30": datetime.timedelta(minutes=14, seconds=30),
|
||||
"14:30:00": datetime.timedelta(hours=14, minutes=30, seconds=0),
|
||||
"1 week": datetime.timedelta(days=7),
|
||||
"2 wk": datetime.timedelta(days=14),
|
||||
"2 months": datetime.timedelta(days=60),
|
||||
"1 mos": datetime.timedelta(days=30),
|
||||
}
|
||||
for date_offset_str, date_offset_delta in date_offset_data.items():
|
||||
assert DateOffset().convert(date_offset_str, None, None) == date_offset_delta
|
||||
|
||||
|
||||
def test_date_offset_invalid_format():
|
||||
"""Test DateOffset with invalid format"""
|
||||
date_offset_data = [
|
||||
"1 foo",
|
||||
"1 day 14",
|
||||
"day",
|
||||
]
|
||||
for date_offset_str in date_offset_data:
|
||||
with pytest.raises(BadParameter):
|
||||
DateOffset().convert(date_offset_str, None, None)
|
||||
|
||||
|
||||
def test_time_offset():
|
||||
"""Test TimeOffset"""
|
||||
time_offset_data = {
|
||||
"1": datetime.timedelta(seconds=1),
|
||||
"1s": datetime.timedelta(seconds=1),
|
||||
"2 s": datetime.timedelta(seconds=2),
|
||||
"2 sec": datetime.timedelta(seconds=2),
|
||||
"3 sec": datetime.timedelta(seconds=3),
|
||||
"1m": datetime.timedelta(minutes=1),
|
||||
"1 min": datetime.timedelta(minutes=1),
|
||||
"1 day": datetime.timedelta(days=1),
|
||||
"14:30": datetime.timedelta(minutes=14, seconds=30),
|
||||
"14:30:00": datetime.timedelta(hours=14, minutes=30, seconds=0),
|
||||
}
|
||||
for time_offset_str, time_offset_delta in time_offset_data.items():
|
||||
assert TimeOffset().convert(time_offset_str, None, None) == time_offset_delta
|
||||
|
||||
|
||||
def test_time_offset_invalid_format():
|
||||
"""Test TimeOffset with invalid format"""
|
||||
time_offset_data = [
|
||||
"1 foo",
|
||||
"1 day 14",
|
||||
"1 sec 1",
|
||||
"sec",
|
||||
]
|
||||
for time_offset_str in time_offset_data:
|
||||
with pytest.raises(BadParameter):
|
||||
TimeOffset().convert(time_offset_str, None, None)
|
||||
|
||||
|
||||
def test_bitmath_size():
|
||||
"""Test BitMathSize"""
|
||||
bitmath_size_data = {
|
||||
"1048576": MB(1.048576),
|
||||
"1.048576MB": MB(1.048576),
|
||||
"1 MiB": MB(1.048576),
|
||||
}
|
||||
for bitmath_size_str, bitmath_size_int in bitmath_size_data.items():
|
||||
assert BitMathSize().convert(bitmath_size_str, None, None) == bitmath_size_int
|
||||
|
||||
|
||||
def test_bitmath_size_invalid_format():
|
||||
"""Test BitMathSize with invalid format"""
|
||||
bitmath_size_data = [
|
||||
"1 foo",
|
||||
"1 mehgabite",
|
||||
]
|
||||
for bitmath_size_str in bitmath_size_data:
|
||||
with pytest.raises(BadParameter):
|
||||
BitMathSize().convert(bitmath_size_str, None, None)
|
||||
|
||||
|
||||
def test_date_time_iso8601():
|
||||
"""Test DateTimeISO8601"""
|
||||
date_time_iso8601_data = {
|
||||
"2020-01-01T00:00:00": datetime.datetime(2020, 1, 1, 0, 0, 0),
|
||||
"2020-01-01T00:00:00.000": datetime.datetime(2020, 1, 1, 0, 0, 0),
|
||||
"2020-01-01": datetime.datetime(2020, 1, 1),
|
||||
}
|
||||
for date_time_iso8601_str, date_time_iso8601_dt in date_time_iso8601_data.items():
|
||||
assert (
|
||||
DateTimeISO8601().convert(date_time_iso8601_str, None, None)
|
||||
== date_time_iso8601_dt
|
||||
)
|
||||
|
||||
|
||||
def test_date_time_iso8601_invalid_format():
|
||||
"""Test DateTimeISO8601 with invalid format"""
|
||||
date_time_iso8601_data = [
|
||||
"20-01-01T00:00:00",
|
||||
"20-01-1",
|
||||
]
|
||||
for date_time_iso8601_str in date_time_iso8601_data:
|
||||
with pytest.raises(BadParameter):
|
||||
DateTimeISO8601().convert(date_time_iso8601_str, None, None)
|
||||
|
||||
|
||||
def test_time_iso8601():
|
||||
"""Test TimeISO8601"""
|
||||
time_iso8601_data = {
|
||||
"00:00:00": datetime.time(0, 0, 0),
|
||||
"00:00:00.000": datetime.time(0, 0, 0),
|
||||
}
|
||||
|
||||
for time_iso8601_str, time_iso8601_dt in time_iso8601_data.items():
|
||||
assert TimeISO8601().convert(time_iso8601_str, None, None) == time_iso8601_dt
|
||||
|
||||
|
||||
def test_time_iso8601_invalid_format():
|
||||
"""Test TimeISO8601 with invalid format"""
|
||||
date_time_iso8601_data = [
|
||||
"20-01-01T00:00:00",
|
||||
"20-01-1",
|
||||
]
|
||||
for date_time_iso8601_str in date_time_iso8601_data:
|
||||
with pytest.raises(BadParameter):
|
||||
TimeISO8601().convert(date_time_iso8601_str, None, None)
|
||||
|
||||
|
||||
def test_timestring():
|
||||
"""Test TimeString"""
|
||||
timestring_data = {
|
||||
"01:02:03": datetime.time(1, 2, 3),
|
||||
"01:02:03.000": datetime.time(1, 2, 3),
|
||||
"01:02:03.0000": datetime.time(1, 2, 3),
|
||||
"01:02": datetime.time(1, 2, 0),
|
||||
}
|
||||
for timestring_str, timestring_dt in timestring_data.items():
|
||||
assert TimeString().convert(timestring_str, None, None) == timestring_dt
|
||||
|
||||
|
||||
def test_timestring_invalid_format():
|
||||
"""Test TimeString with invalid format"""
|
||||
timestring_data = [
|
||||
"20-01-01T00:00:00",
|
||||
"20-01-1",
|
||||
]
|
||||
for timestring_str in timestring_data:
|
||||
with pytest.raises(BadParameter):
|
||||
TimeString().convert(timestring_str, None, None)
|
||||
|
||||
|
||||
def test_utcoffset():
|
||||
"""Test UTCOffset"""
|
||||
utcoffset_data = {
|
||||
"+00:00": Timezone(0),
|
||||
"-00:00": Timezone(-0),
|
||||
"+01:00": Timezone(3600),
|
||||
"-01:00": Timezone(-3600),
|
||||
"+01:30": Timezone(5400),
|
||||
"-01:30": Timezone(-5400),
|
||||
}
|
||||
for utcoffset_str, utcoffset_int in utcoffset_data.items():
|
||||
assert UTCOffset().convert(utcoffset_str, None, None) == utcoffset_int
|
||||
|
||||
|
||||
def test_utcoffset_invalid_format():
|
||||
"""Test UTCOffset with invalid format"""
|
||||
utcoffset_data = [
|
||||
"20-01-01T00:00:00",
|
||||
"20-01-1",
|
||||
]
|
||||
for utcoffset_str in utcoffset_data:
|
||||
with pytest.raises(BadParameter):
|
||||
UTCOffset().convert(utcoffset_str, None, None)
|
||||
@ -81,7 +81,7 @@ def test_inspect(photoslib, suspend_capture, output_file):
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
@ -101,6 +101,7 @@ def test_date(photoslib, suspend_capture):
|
||||
"--date",
|
||||
TEST_DATA["date"]["value"],
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
@ -122,13 +123,14 @@ def test_date_delta(photoslib, suspend_capture, input_value, expected, output_fi
|
||||
"--date-delta",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -148,6 +150,7 @@ def test_time(photoslib, suspend_capture, input_value, expected, output_file):
|
||||
"--time",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
@ -156,7 +159,7 @@ def test_time(photoslib, suspend_capture, input_value, expected, output_file):
|
||||
# don't use photo.date as it will return local time instead of the time in the timezone
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -176,13 +179,14 @@ def test_time_delta(photoslib, suspend_capture, input_value, expected, output_fi
|
||||
"--time-delta",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -206,13 +210,14 @@ def test_time_zone(
|
||||
"--timezone",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -232,6 +237,7 @@ def test_compare_exif(photoslib, suspend_capture, expected, output_file):
|
||||
[
|
||||
"--compare-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"-o",
|
||||
output_file,
|
||||
],
|
||||
@ -258,6 +264,7 @@ def test_compare_exif_add_to_album(photoslib, suspend_capture, expected, album):
|
||||
"--add-to-album",
|
||||
album,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
@ -282,7 +289,7 @@ def test_compare_exif_3(photoslib, suspend_capture, expected, output_file):
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
@ -304,13 +311,14 @@ def test_match(photoslib, suspend_capture, input_value, expected, output_file):
|
||||
input_value,
|
||||
"--match-time",
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -324,7 +332,9 @@ def test_push_exif_missing_file():
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
timewarp, ["--push-exif", "--plain", "--verbose"], terminal_width=TERMINAL_WIDTH
|
||||
timewarp,
|
||||
["--push-exif", "--plain", "--force", "--verbose"],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "Skipping EXIF update for missing photo" in result.output
|
||||
@ -361,6 +371,7 @@ def test_push_exif_1(
|
||||
time_delta_value,
|
||||
"--push-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
]
|
||||
if match:
|
||||
cli_args.append("--match-time")
|
||||
@ -370,7 +381,7 @@ def test_push_exif_1(
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -403,7 +414,7 @@ def test_push_exif_2(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -414,6 +425,7 @@ def test_push_exif_2(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--push-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
@ -422,7 +434,7 @@ def test_push_exif_2(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -442,14 +454,14 @@ def test_pull_exif_1(photoslib, suspend_capture, output_file):
|
||||
# update the photo so we know if the data is updated
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["-z", "-0400", "-D", "+1 day", "-m", "-V", "--plain"],
|
||||
["-z", "-0400", "-D", "+1 day", "-m", "-V", "--plain", "--force"],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -460,6 +472,7 @@ def test_pull_exif_1(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--pull-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
@ -468,7 +481,7 @@ def test_pull_exif_1(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -493,7 +506,7 @@ def test_pull_exif_no_time(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -504,6 +517,7 @@ def test_pull_exif_no_time(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--pull-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
@ -512,7 +526,7 @@ def test_pull_exif_no_time(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -537,7 +551,7 @@ def test_pull_exif_no_offset(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -548,6 +562,7 @@ def test_pull_exif_no_offset(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--pull-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
@ -556,7 +571,7 @@ def test_pull_exif_no_offset(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -583,7 +598,7 @@ def test_pull_exif_no_data(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -594,6 +609,7 @@ def test_pull_exif_no_data(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--pull-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
@ -603,7 +619,7 @@ def test_pull_exif_no_data(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -622,7 +638,7 @@ def test_pull_exif_no_data_use_file_time(photoslib, suspend_capture, output_file
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -633,6 +649,7 @@ def test_pull_exif_no_data_use_file_time(photoslib, suspend_capture, output_file
|
||||
[
|
||||
"--pull-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
"--use-file-time",
|
||||
],
|
||||
@ -643,7 +660,7 @@ def test_pull_exif_no_data_use_file_time(photoslib, suspend_capture, output_file
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -668,6 +685,7 @@ def test_video_compare_exif(photoslib, suspend_capture, expected, output_file):
|
||||
[
|
||||
"--compare-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"-o",
|
||||
output_file,
|
||||
],
|
||||
@ -695,6 +713,7 @@ def test_video_date_delta(
|
||||
"--date-delta",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
@ -702,7 +721,7 @@ def test_video_date_delta(
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -726,13 +745,14 @@ def test_video_time_delta(
|
||||
"--time-delta",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -752,6 +772,7 @@ def test_video_date(photoslib, suspend_capture, input_value, expected, output_fi
|
||||
"--date",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
@ -760,7 +781,7 @@ def test_video_date(photoslib, suspend_capture, input_value, expected, output_fi
|
||||
# don't use photo.date as it will return local time instead of the time in the timezone
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -780,6 +801,7 @@ def test_video_time(photoslib, suspend_capture, input_value, expected, output_fi
|
||||
"--time",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
@ -788,7 +810,7 @@ def test_video_time(photoslib, suspend_capture, input_value, expected, output_fi
|
||||
# don't use photo.date as it will return local time instead of the time in the timezone
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -812,13 +834,14 @@ def test_video_time_zone(
|
||||
"--timezone",
|
||||
input_value,
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -840,13 +863,14 @@ def test_video_match(photoslib, suspend_capture, input_value, expected, output_f
|
||||
input_value,
|
||||
"--match-time",
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
@ -865,7 +889,7 @@ def test_video_push_exif(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -876,6 +900,7 @@ def test_video_push_exif(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--push-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
@ -884,7 +909,7 @@ def test_video_push_exif(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -904,14 +929,25 @@ def test_video_pull_exif(photoslib, suspend_capture, output_file):
|
||||
# update the photo so we know if the data is updated
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["-z", "-0500", "-D", "+1 day", "-T", "-10 hours", "-m", "-V", "--plain"],
|
||||
[
|
||||
"-z",
|
||||
"-0500",
|
||||
"-D",
|
||||
"+1 day",
|
||||
"-T",
|
||||
"-10 hours",
|
||||
"-m",
|
||||
"-V",
|
||||
"--plain",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -922,6 +958,7 @@ def test_video_pull_exif(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--pull-exif",
|
||||
"--plain",
|
||||
"--force",
|
||||
"--verbose",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
@ -930,7 +967,7 @@ def test_video_pull_exif(photoslib, suspend_capture, output_file):
|
||||
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--compare-exif", "--plain", "-o", output_file],
|
||||
["--compare-exif", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_compare_exif(output_file)
|
||||
@ -956,13 +993,14 @@ def test_function(photoslib, suspend_capture, output_file):
|
||||
[
|
||||
"--function",
|
||||
"tests/timewarp_function_example.py::get_date_time_timezone",
|
||||
"--force",
|
||||
],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
result = runner.invoke(
|
||||
timewarp,
|
||||
["--inspect", "--plain", "-o", output_file],
|
||||
["--inspect", "--plain", "--force", "-o", output_file],
|
||||
terminal_width=TERMINAL_WIDTH,
|
||||
)
|
||||
output_values = parse_inspect_output(output_file)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user