Fixed from_date and to_date to be timezone aware, closes #193

This commit is contained in:
Rhet Turnbull
2020-08-08 21:01:53 -07:00
parent 2628c1f2d2
commit fc416ea0b7
14 changed files with 199 additions and 96 deletions

View File

@@ -46,13 +46,6 @@ def test_db_version():
assert photosdb.db_version == "2622"
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -130,13 +130,6 @@ def test_db_version():
assert photosdb.db_version == "6000"
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -138,13 +138,6 @@ def test_db_version():
assert photosdb.db_version == "6000"
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -164,13 +164,6 @@ def test_db_version():
assert photosdb.db_version == "6000"
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -697,13 +697,18 @@ def test_export_edited_suffix():
assert sorted(files) == sorted(CLI_EXPORT_FILENAMES_EDITED_SUFFIX)
def test_query_date():
def test_query_date_1():
""" Test --from-date and --to-date """
import json
import osxphotos
import os
import os.path
import time
from osxphotos.__main__ import query
os.environ['TZ'] = "US/Pacific"
time.tzset()
runner = CliRunner()
cwd = os.getcwd()
result = runner.invoke(
@@ -721,6 +726,64 @@ def test_query_date():
json_got = json.loads(result.output)
assert len(json_got) == 4
def test_query_date_2():
""" Test --from-date and --to-date """
import json
import osxphotos
import os
import os.path
import time
from osxphotos.__main__ import query
os.environ['TZ'] = "Asia/Jerusalem"
time.tzset()
runner = CliRunner()
cwd = os.getcwd()
result = runner.invoke(
query,
[
"--json",
"--db",
os.path.join(cwd, CLI_PHOTOS_DB),
"--from-date=2018-09-28",
"--to-date=2018-09-28T23:00:00",
],
)
assert result.exit_code == 0
json_got = json.loads(result.output)
assert len(json_got) == 2
def test_query_date_timezone():
""" Test --from-date, --to-date with ISO 8601 timezone """
import json
import osxphotos
import os
import os.path
import time
from osxphotos.__main__ import query
os.environ['TZ'] = "US/Pacific"
time.tzset()
runner = CliRunner()
cwd = os.getcwd()
result = runner.invoke(
query,
[
"--json",
"--db",
os.path.join(cwd, CLI_PHOTOS_DB),
"--from-date=2018-09-28T00:00:00-07:00",
"--to-date=2018-09-28T23:00:00-07:00",
],
)
assert result.exit_code == 0
json_got = json.loads(result.output)
assert len(json_got) == 4
def test_query_keyword_1():
"""Test query --keyword """

View File

@@ -29,13 +29,6 @@ def test_db_version():
assert photosdb.db_version == "4025"
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -46,13 +46,6 @@ def test_db_version():
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -47,13 +47,6 @@ def test_db_version():
assert photosdb.db_version == "4016"
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections

View File

@@ -1,4 +1,3 @@
import pytest
from osxphotos._constants import _UNKNOWN_PERSON
@@ -82,13 +81,6 @@ def test_db_len():
assert len(photosdb) == PHOTOS_DB_LEN
def test_os_version():
import osxphotos
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
import osxphotos
import collections
@@ -272,6 +264,7 @@ def test_not_hidden():
def test_location_1():
# test photo with lat/lon info
import osxphotos
import pytest
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
photos = photosdb.photos(uuid=["3Jn73XpSQQCluzRBMWRsMA"])