changeset 23:f5d7f4b40537

simplified test code
author Atul Varma <varmaa@toolness.com>
date Wed, 23 Dec 2009 22:18:00 -0800
parents 01b054bc3a27
children e61a42133a33
files test.py
diffstat 1 files changed, 12 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/test.py	Wed Dec 23 22:14:26 2009 -0800
+++ b/test.py	Wed Dec 23 22:18:00 2009 -0800
@@ -89,37 +89,33 @@
 
     _collections = ['bugs']
 
-    def test_instantiation(self):
-        search = bzapi.CachedSearch(self.FakeApi(), testdb.bugs)
+    def setUp(self):
+        _MongoTestCase.setUp(self)
+        self.api = self.FakeApi()
+        self.search = bzapi.CachedSearch(self.api, 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()
+        self.api.set('/bug', {}, {'data': {'bugs': []}})
+        self.search.update()
         self.assertEqual(testdb.bugs.find().count(), 0)
 
     def test_update_with_bug(self):
-        api = self.FakeApi()
-
         bug = {'id': '1034',
                'creation_time': '2009-06-11T22:31:24Z',
                'last_change_time': '2009-06-11T22:31:24Z'}
         response = {'data': {'bugs': [bug]},
                     'date': datetime.utcnow()}
 
-        api.set('/bug', {}, deepcopy(response))
+        self.api.set('/bug', {}, deepcopy(response))
 
         bug['comments'] = 'blah'
 
-        api.set('/bug', {'id_mode': 'include',
-                         'id': '1034',
-                         'comments': '1',
-                         'history': '1'}, deepcopy(response))
+        self.api.set('/bug', {'id_mode': 'include',
+                              'id': '1034',
+                              'comments': '1',
+                              'history': '1'}, deepcopy(response))
 
-        search = bzapi.CachedSearch(api, testdb.bugs)
-        search.update()
-
+        self.search.update()
         self.assertEqual(testdb.bugs.find({'comments': 'blah'}).count(), 1)
 
 class ApiTests(_MongoTestCase):