Commits

Wayne Werner committed c3afdb3

Added some session stuff, need to fix

Comments (0)

Files changed (1)

     def setUpClass(cls):
         slayer.DB_PATH = os.path.join(slayer.BASE_DIR, 'test.sq3')
         slayer.make_db()
+        SlayerTests.session = slayer.make_session()
 
     @classmethod
     def tearDownClass(cls):
     ##################
     def test_whenStartIntervalIsCalledTaskDoesNotExistItShouldRaiseValueError(self):
         with self.assertRaises(ValueError):
-            slayer.start_interval(task_id=4, user_id='wango')
+            slayer.start_interval(task_id=4, user_id='wango',
+                    session=self.session)
 
     def test_whenStartIntervalIsCalledAndUserDNEThenItShouldValueError(self):
         task_id = slayer.add_task(project='default').id
         with self.assertRaises(ValueError):
-            slayer.start_interval(task_id=task_id, user_id='wango')
+            slayer.start_interval(task_id=task_id, user_id='wango',
+                    session=self.session)
 
     def test_whenStartIntervalIsCalledAndTaskAndUserExistItShouldBeAddedToUser(self):
         user_id = slayer.add_user().id
     def test_whenStartIntervalIsCalledOkItShouldReturnTheInterval(self):
         user_id = slayer.add_user().id
         task_id = slayer.add_task(project='default').id
-        interval = slayer.start_interval(task_id=task_id, user_id=user_id)
+        interval = slayer.start_interval(task_id=task_id, user_id=user_id,
+                session=self.session)
         self.assertTrue(isinstance(interval, slayer.Interval))
 
     ##############
     # Task Tests #
     ##############
     def test_whenAddTaskIsCalledItShouldReturnTheTaskWithNewId(self):
-        task = slayer.add_task(project='default')
+        task = slayer.add_task(project='default', session=self.session)
         self.assertLess(0, task.id)
 
     def test_whenAddTaskIsCalledWithDescItShouldBeSet(self):
         expected_desc = 'No real project thing'
-        id = slayer.add_task(desc=expected_desc, project='default').id
-        task = slayer.get_task(id)
+        id = slayer.add_task(desc=expected_desc, project='default',
+                session=self.session).id
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_desc, task.desc)
 
     def test_whenAddTaskIsCalledWithProjectThatExistsItShouldBeSet(self):
         expected_proj = 'Boog Slayer'
-        slayer.add_project(expected_proj)
-        id = slayer.add_task(project=expected_proj).id
-        task = slayer.get_task(id)
+        slayer.add_project(expected_proj, session=self.session)
+        id = slayer.add_task(project=expected_proj, session=self.session).id
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_proj, task.project)
 
     def test_whenAddTaskIsCalledWithProjectAndProjectDoesNotExistShouldRaiseValueError(self):
         expected_proj = 'Boog Slayer'
         with self.assertRaises(ValueError):
-            slayer.add_task(project=expected_proj)
+            slayer.add_task(project=expected_proj, session=self.session)
 
     def test_whenAddTaskIsCalledWithUserAndUserDoesNotExistShouldRaiseValueError(self):
         imaginary_user = 'some super cool id'
         with self.assertRaises(ValueError):
-            slayer.add_task(assigned_to=imaginary_user)
+            slayer.add_task(assigned_to=imaginary_user, session=self.session)
 
     def test_whenAddTaskIsCalledWithParentCaseThatDoesntExistItShouldRaiseValueError(self):
         imaginary_task_id = 42
         with self.assertRaises(ValueError):
-            slayer.add_task(parent_id=imaginary_task_id)
+            slayer.add_task(parent_id=imaginary_task_id, session=self.session)
 
     def test_whenGetTaskIsCalledWithIdItShouldReturnTask(self):
-        task_id = slayer.add_task(project='default').id
-        task = slayer.get_task(task_id=task_id)
+        task_id = slayer.add_task(project='default', session=self.session).id
+        task = slayer.get_task(task_id=task_id, session=self.session)
         self.assertEqual(task_id, task.id)
 
     def test_whenEditTaskIsCalledWithInvalidIdItShouldRaiseValueError(self):
         with self.assertRaises(ValueError):
-            slayer.edit_task(id=4)
+            slayer.edit_task(id=4, session=self.session)
 
     def test_whenEditTaskIsCalledWithDescItShouldBeSet(self):
         expected_desc = 'No real project thing'
-        id = slayer.add_task(project='default').id
-        slayer.edit_task(id, desc=expected_desc)
-        task = slayer.get_task(id)
+        id = slayer.add_task(project='default', session=self.session).id
+        slayer.edit_task(id, desc=expected_desc, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_desc, task.desc)
 
     def test_whenEditTaskIsCalledWithProjectItShouldBeSet(self):
         expected_proj = 'XTF-1234'
-        id = slayer.add_task(project='default').id
-        slayer.edit_task(id, project=expected_proj)
-        task = slayer.get_task(id)
+        id = slayer.add_task(project='default', session=self.session).id
+        slayer.edit_task(id, project=expected_proj, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_proj, task.project)
 
     def test_whenEditTaskIsCalledWithTypeItShouldBeUpdated(self):
         expected_type = 'Fnord'
-        id = slayer.add_task().id
-        slayer.edit_task(id, type=expected_type)
-        task = slayer.get_task(id)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, type=expected_type, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_type, task.type)
 
     def test_whenEditTaskIsCalledWithStatusItShouldBeUpdated(self):
         expected_status = 'Newed'
-        id = slayer.add_task().id
-        slayer.edit_task(id, status=expected_status)
-        task = slayer.get_task(id)
+        id = slayer.add_task(session=self.session).id
+        slayer.edit_task(id, status=expected_status, session=self.session)
+        task = slayer.get_task(id, session=self.session)
         self.assertEqual(expected_status, task.status)
 
     def test_whenEditTaskIsCalledWithAssignedToItShouldBeUpdated(self):
         expected_assigned_to = 'Puff, the magic dragon'
-        id = slayer.add_task().id
-        slayer.edit_task(id, assigned_to=expected_assigned_to)
-        task = slayer.get_task(id)
-        self.assertEqual(expected_assigned_to, task.assigned_to)
+        id = slayer.add_task(session=self.session).id
+        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)
 
     def test_whenEditTaskIsCalledWithContactItShouldBeUpdated(self):
         expected_contact = '3-2-1'
         self.assertEqual(expected_user, actual_user)
 
     def test_whenEditUserIsCalledWithNoneNewIdAndNoneNameItShouldStaySame(self):
-        user_id = slayer.add_user(user_id='waynerd', name="Wango Tango").id
-        slayer.edit_user(user_id, new_id=None, new_name=None)
-        user = slayer.get_user(user_id=user_id)
+        user_id = slayer.add_user(user_id='waynerd', name="Wango Tango",
+                session=self.session).id
+        slayer.edit_user(user_id, new_id=None, new_name=None,
+                session=self.session)
+        user = slayer.get_user(user_id=user_id, session=self.session)
         self.assertEqual('waynerd', user.id)
         self.assertEqual('Wango Tango', user.name)