Remove deprecated .has_key()
This commit is contained in:
parent
e09c480980
commit
181ad7b6c9
|
@ -986,15 +986,15 @@ class _ShelfCacheBackend(object):
|
|||
def __init__(self, file_path=None):
|
||||
self.shelf = shelve.open(file_path)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.shelf.keys())
|
||||
|
||||
def get_xml(self, key):
|
||||
return self.shelf[key]
|
||||
|
||||
def set_xml(self, key, xml_string):
|
||||
self.shelf[key] = xml_string
|
||||
|
||||
def has_key(self, key):
|
||||
return key in self.shelf.keys()
|
||||
|
||||
|
||||
class _Request(object):
|
||||
"""Representing an abstract web service operation."""
|
||||
|
@ -1073,7 +1073,7 @@ class _Request(object):
|
|||
def _is_cached(self):
|
||||
"""Returns True if the request is already in cache."""
|
||||
|
||||
return self.cache.has_key(self._get_cache_key())
|
||||
return self._get_cache_key() in self.cache
|
||||
|
||||
def _download_response(self):
|
||||
"""Returns a response body string from the server."""
|
||||
|
|
|
@ -1393,6 +1393,21 @@ class TestPyLast(unittest.TestCase):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(albums, pylast.Album)
|
||||
|
||||
def test_caching(self):
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
# Act
|
||||
self.network.enable_caching()
|
||||
shouts1 = user.get_shouts(limit=1, cacheable=True)
|
||||
shouts2 = user.get_shouts(limit=1, cacheable=True)
|
||||
|
||||
# Assert
|
||||
self.assertTrue(self.network.is_caching_enabled())
|
||||
self.assertEqual(shouts1, shouts2)
|
||||
self.network.disable_caching()
|
||||
self.assertFalse(self.network.is_caching_enabled())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
Loading…
Reference in a new issue