Commits

Wayne Werner committed c3b4280

Added session to tests in hopes of speeding things up

Comments (0)

Files changed (3)

 SQLAlchemy==0.7.8
 argparse==1.2.1
-distribute==0.6.24
 mock==1.0b1
 wsgiref==0.1.2
     session.add(task)
     session.commit()
 
-def get_task(task_id):
+def get_task(task_id, session=None):
     '''Return the task with the given task_id. If the task does not exist,
     return None instead.
 
     '''
-    session = make_session()
+    if session is None:
+        session = make_session()
     task = session.query(Task).filter_by(id=task_id).first()
     return task
 
 import os
 import pdb
 import time
-import mock
 import unittest
 import contextlib
 
         slayer.edit_task(id, assigned_to=expected_assigned_to,
                 session=self.session)
         task = slayer.get_task(id, session=self.session)
-        self.assertEqual(expected_assigned_to, task.assigned_to,
-                session=self.session)
+        self.assertEqual(expected_assigned_to, task.assigned_to)
 
     def test_whenEditTaskIsCalledWithContactItShouldBeUpdated(self):
         expected_contact = '3-2-1'
         id = slayer.add_task().id
-        slayer.edit_task(id, contact=expected_contact)
-        task = slayer.get_task(id)
+        slayer.edit_task(id, contact=expected_contact, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_contact, task.contact)
 
     def test_whenEditTaskIsCalledWithPriorityItShouldBeUpdated(self):
         expected_priority = 1
         id = slayer.add_task().id
-        slayer.edit_task(id, priority=expected_priority)
-        task = slayer.get_task(id)
+        slayer.edit_task(id, priority=expected_priority, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_priority, task.priority)
 
     def test_whenEditTaskIsCalledWithDueItShouldBeUpdated(self):
         expected_due = datetime(1984, 8, 26)
         id = slayer.add_task().id
-        slayer.edit_task(id, due=expected_due)
-        task = slayer.get_task(id)
+        slayer.edit_task(id, due=expected_due, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_due, task.due)
 
     def test_whenEditTaskIsCalledWithOriginalEstimateItShouldBeUpdated(self):
         expected_original_estimate = 13
-        id = slayer.add_task().id
-        slayer.edit_task(id, original_estimate=expected_original_estimate)
-        task = slayer.get_task(id)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, original_estimate=expected_original_estimate,
+                session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_original_estimate, task.original_estimate)
 
     def test_whenEditTaskIsCalledWithCurrentEstimateItShouldBeUpdated(self):
         expected_current_estimate = 13
-        id = slayer.add_task().id
-        slayer.edit_task(id, current_estimate=expected_current_estimate)
-        task = slayer.get_task(id)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, current_estimate=expected_current_estimate,
+                session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_current_estimate, task.current_estimate)
 
     def test_whenEditTaskIsCalledWithVersionItShouldBeUpdated(self):
         expected_version = '1.4'
-        id = slayer.add_task().id
-        slayer.edit_task(id, version=expected_version)
-        task = slayer.get_task(id)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, version=expected_version, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_version, task.version)
 
     def test_whenEditTaskIsCalledWithBacklogOrderItShouldBeUpdated(self):
         expected_backlog_order = 42
-        id = slayer.add_task().id
-        slayer.edit_task(id, backlog_order=expected_backlog_order)
-        task = slayer.get_task(id)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, backlog_order=expected_backlog_order,
+                session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_backlog_order, task.backlog_order)
 
     def test_whenEditTaskIsCalledWithAreaItShouldBeUpdated(self):
         expected_area = 'some area'
-        id = slayer.add_task().id
-        slayer.edit_task(id, area=expected_area)
-        task = slayer.get_task(id)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, area=expected_area, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_area, task.area)
 
     def test_whenEditTaskIsCalledWithParentCaseItShouldBeUpdated(self):
         expected_parent_case = slayer.add_task().id
-        id = slayer.add_task().id
-        slayer.edit_task(id, parent_case=expected_parent_case)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, parent_case=expected_parent_case,
+                session=self.session)
         task = slayer.get_task(id)
         self.assertEqual(expected_parent_case, task.parent_case)