def test_cached_get(self, m): cache = Cache() client = TestClient(API_KEY, cache=cache) url = 'http://duedil.io/v3/12345.json' m.register_uri('GET', (url + '?api_key=' + API_KEY), json={'name': 'Duedil', 'id': '12345'}) client.get('12345') self.assertEqual(cache.get_url(url), {'name': 'Duedil', 'id': '12345'})
def test_get_with_params(self, m): cache = Cache() client = TestClient(API_KEY, cache=cache) params = {'filters': {'name': 'Duedil Ltd'}} url = 'http://duedil.io/v3/12345.json' m.register_uri('GET', url, json={'name': 'Duedil', 'id': '12345'}) client.get('12345', data=params) cached = cache.get_url('http://duedil.io/v3/12345.json', url_params=params) self.assertEqual(cached, {'name': 'Duedil', 'id': '12345'})
def test_cached_get(self, m): cache = Cache() client = TestClient(API_KEY, cache=cache) url = 'http://duedil.io/v3/12345.json' m.register_uri('GET', (url + '?api_key=' + API_KEY), json={ 'name': 'Duedil', 'id': '12345' }) client.get('12345') self.assertEqual(cache.get_url(url), {'name': 'Duedil', 'id': '12345'})
class CacheTestCase(unittest.TestCase): cache = Cache() def test_get_cached(self): url = 'http://duedil.io/v3/uk/companies/06999618' data = {'name': 'Duedil Limited', 'company_number': '06999618'} self.cache.set_url(url, data) self.assertEqual(data, self.cache.get_url(url)) def test_get_uncached(self): url = 'http://duedil.io/v3/uk/companies/07071234' self.assertIsNone(self.cache.get_url(url))