changeset 20:d9f82ab24604

added another trivial cached search test
author Atul Varma <varmaa@toolness.com>
date Wed, 23 Dec 2009 21:51:41 -0800
parents 2dc7c31d8174
children e191d30033d8
files test.py
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test.py	Wed Dec 23 21:45:55 2009 -0800
+++ b/test.py	Wed Dec 23 21:51:41 2009 -0800
@@ -76,10 +76,26 @@
         self._reset_collections()
 
 class CachedSearchTests(_MongoTestCase):
+    class FakeApi(object):
+        def __init__(self):
+            self._urls = {}
+
+        def set(self, url, params, response):
+            self._urls[url + json.dumps(params)] = response
+
+        def get(self, url, **kwargs):
+            return self._urls[url + json.dumps(kwargs)]
+
     _collections = ['bugs']
 
     def test_instantiation(self):
-        search = bzapi.CachedSearch(None, testdb.bugs)
+        search = bzapi.CachedSearch(self.FakeApi(), testdb.bugs)
+
+    def test_update_with_no_bugs(self):
+        api = self.FakeApi()
+        api.set('/bug', {}, {'data': {'bugs': {}}})
+        search = bzapi.CachedSearch(api, testdb.bugs)
+        search.update()
 
 class ApiTests(_MongoTestCase):
     class FakeOpenUrl(object):