mirror of
https://github.com/kennethreitz-archive/py-reqcache.git
synced 2026-06-05 23:30:17 +00:00
23 lines
580 B
Python
23 lines
580 B
Python
import testify
|
|
import requests
|
|
from reqcache.models import ReqCache
|
|
|
|
|
|
class ReqCacheTestCase(testify.TestCase):
|
|
|
|
@testify.setup
|
|
def create_cache(self):
|
|
self.rcache = ReqCache("test", "memory")
|
|
|
|
@testify.teardown
|
|
def clear_cache(self):
|
|
self.rcache = None
|
|
|
|
def test_basic_caching(self):
|
|
|
|
r = requests.get('http://github.com', hooks=self.rcache.hooks)
|
|
self.assertFalse(getattr(r, "from_cache", False))
|
|
|
|
r = requests.get('http://github.com', hooks=self.rcache.hooks)
|
|
self.assertTrue(getattr(r, "from_cache", False))
|