Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cache_object(self):
cache_key = 1
ticket = self.cache_item(id=cache_key)
self.assertIs(self.cache.get(get_object_type(ticket), cache_key), ticket)
def format_key(self, key, parent):
if key == 'result':
key = "{}_result".format(get_object_type(parent))
elif key in ('metadata', 'from', 'system', 'photo', 'thumbnails'):
key = '{}'.format(key)
return key
def build_payload(self, translation):
return {get_object_type(translation): self.api._serialize(translation)}
def build_payload(self, help_centre_object):
return {get_object_type(help_centre_object): self.api._serialize(help_centre_object)}
def in_cache(self, zenpy_object):
""" Determine whether or not this object is in the cache """
object_type = get_object_type(zenpy_object)
cache_key_attr = self._cache_key_attribute(object_type)
return self.get(object_type, getattr(zenpy_object, cache_key_attr)) is not None
def build_payload(self, translation):
return {get_object_type(translation): self.api._serialize(translation)}
def build_payload(self, account):
return {get_object_type(account): self.api._serialize(account)}
def should_cache(self, zenpy_object):
""" Determine whether or not this object should be cached (ie, a cache exists for it's object_type) """
return get_object_type(zenpy_object) in self.mapping