Implement from_date and to_date in PhotosDB as well as query and export command. Some refactoring of CLI as well.
This commit is contained in:
@@ -786,3 +786,20 @@ def test_photosinfo_repr():
|
||||
k: str(v).encode("utf-8")
|
||||
for k, v in photo2.__dict__.items()
|
||||
}
|
||||
|
||||
|
||||
def test_from_to_date():
|
||||
import osxphotos
|
||||
import datetime as dt
|
||||
|
||||
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
|
||||
|
||||
photos = photosdb.photos(from_date=dt.datetime(2018, 10, 28))
|
||||
assert len(photos) == 2
|
||||
|
||||
photos = photosdb.photos(to_date=dt.datetime(2018, 10, 28))
|
||||
assert len(photos) == 5
|
||||
|
||||
photos = photosdb.photos(from_date=dt.datetime(2018, 9, 28),
|
||||
to_date=dt.datetime(2018, 9, 29))
|
||||
assert len(photos) == 4
|
||||
|
||||
@@ -103,3 +103,25 @@ def test_export():
|
||||
)
|
||||
files = glob.glob("*.jpg")
|
||||
assert files.sort() == CLI_EXPORT_FILENAMES.sort()
|
||||
|
||||
|
||||
def test_query_date():
|
||||
import json
|
||||
import osxphotos
|
||||
from osxphotos.__main__ import query
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
query,
|
||||
[
|
||||
"--json",
|
||||
"--db",
|
||||
"./tests/Test-10.15.1.photoslibrary",
|
||||
"--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) == 4
|
||||
Reference in New Issue
Block a user