def __init__(self, email, password, audience=None, with_client_state=False, server_url=FXA_ACCOUNT_URL, cache=True, ttl=None): self.email = email self.password = password self.audience = audience self.with_client_state = with_client_state self.server_url = server_url self.cache = cache if self.cache is True: if ttl is None: ttl = DEFAULT_CACHE_EXPIRY - 1 self.cache = MemoryCache(ttl)
def __init__(self, client_id=None, client_secret=None, server_url=None, cache=True, ttl=DEFAULT_CACHE_EXPIRY): self.client_id = client_id self.client_secret = client_secret if server_url is None: server_url = DEFAULT_SERVER_URL server_url = server_url.rstrip('/') if not server_url.endswith(VERSION_SUFFIXES): server_url += VERSION_SUFFIXES[0] if isinstance(server_url, string_types): self.apiclient = APIClient(server_url) else: self.apiclient = server_url self.cache = cache if self.cache is True: self.cache = MemoryCache(ttl)
def __init__(self, email, password, scopes=None, client_id=None, account_server_url=FXA_ACCOUNT_URL, oauth_server_url=FXA_OAUTH_URL, cache=True, ttl=DEFAULT_CACHE_EXPIRY): self.email = email self.password = password if scopes is None: scopes = ['profile'] self.scopes = scopes self.client_id = client_id self.account_server_url = account_server_url self.oauth_server_url = oauth_server_url self.cache = cache if self.cache is True: self.cache = MemoryCache(ttl)
def test_can_change_default_cache(self): cache = MemoryCache(0.01) self.client = Client(cache=cache) self.assertEqual(self.client.cache, cache) self.assertEqual(self.client.cache.ttl, 0.01)
def setUp(self): self.cache = MemoryCache()
def test_delete_expires(self): self.cache = MemoryCache(0.01) self.cache.set('Foo', 'Bar') self.cache.delete('Foo') self.assertIsNone(self.cache.get('Foo'))
def test_expires(self): self.cache = MemoryCache(0.01) self.cache.set('Foo', 'Bar') time.sleep(0.01) self.assertIsNone(self.cache.get('Foo'))