Skip to content

Commit

Permalink
Merge pull request #19 from jitsuin-inc/dev/eccles/cache-subclasses-f…
Browse files Browse the repository at this point in the history
…or-efficiency

Dev/eccles/cache subclasses for efficiency
  • Loading branch information
leflambeur authored May 12, 2021
2 parents 35851dc + 1d3cef4 commit d530250
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
36 changes: 32 additions & 4 deletions archivist/archivist.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,38 @@ def __init__(self, url, *, auth=None, cert=None, verify=True):

self._cert = cert

self.assets = _AssetsClient(self)
self.events = _EventsClient(self)
self.locations = _LocationsClient(self)
self.attachments = _AttachmentsClient(self)
self._assets = None
self._events = None
self._locations = None
self._attachments = None

@property
def assets(self):
"""docstring"""
if self._assets is None:
self._assets = _AssetsClient(self)
return self._assets

@property
def events(self):
"""docstring"""
if self._events is None:
self._events = _EventsClient(self)
return self._events

@property
def locations(self):
"""docstring"""
if self._locations is None:
self._locations = _LocationsClient(self)
return self._locations

@property
def attachments(self):
"""docstring"""
if self._attachments is None:
self._attachments = _AttachmentsClient(self)
return self._attachments

@property
def headers(self):
Expand Down
24 changes: 24 additions & 0 deletions unittests/testarchivist.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ def test_archivist(self):
Test default archivist creation
"""
arch = Archivist("url", auth="authauthauth")
self.assertIsNotNone(
arch.assets,
msg="Incorrect assets",
)
self.assertIsNotNone(
arch.events,
msg="Incorrect events",
)
self.assertIsNotNone(
arch.locations,
msg="Incorrect locations",
)
self.assertIsNotNone(
arch.locations,
msg="Incorrect locations",
)
self.assertIsNotNone(
arch.attachments,
msg="Incorrect attachments",
)
self.assertIsNotNone(
arch.attachments,
msg="Incorrect attachments",
)
self.assertEqual(
arch.url,
"url",
Expand Down

0 comments on commit d530250

Please sign in to comment.