forked from RhetTbull/osxphotos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphotoinfo_mock.py
57 lines (48 loc) · 1.44 KB
/
photoinfo_mock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Selectively mock a PhotoInfo object"""
from osxphotos import PhotoInfo
class PhotoInfoMock(PhotoInfo):
def __init__(self, photo, **kwargs):
self._photo = photo
self._db = photo._db
self._info = photo._info
self._uuid = photo.uuid
for kw in kwargs:
if hasattr(photo, kw):
setattr(self, f"_mock_{kw}", kwargs[kw])
else:
raise ValueError(f"Not a PhotoInfo attribute: {kw}")
@property
def hdr(self):
return (
self._mock_hdr
if getattr(self, "_mock_hdr", None) is not None
else self._photo.hdr
)
@property
def favorite(self):
return (
self._mock_favorite
if getattr(self, "_mock_favorite", None) is not None
else self._photo.favorite
)
@property
def hasadjustments(self):
return (
self._mock_hasadjustments
if getattr(self, "_mock_hasadjustments", None) is not None
else self._photo.hasadjustments
)
@property
def keywords(self):
return (
self._mock_keywords
if getattr(self, "_mock_keywords", None) is not None
else self._photo.keywords
)
@property
def title(self):
return (
self._mock_title
if getattr(self, "_mock_title", None) is not None
else self._photo.title
)