Example #1
0
 def test_on_get_return_correct_list(self):
     self.mock_db.search_session.return_value = [
         common.get_fake_session_0(), common.get_fake_session_1()]
     expected_result = {'sessions': [common.get_fake_session_0(),
                                     common.get_fake_session_1()]}
     self.resource.on_get(self.mock_req, self.mock_req)
     result = self.mock_req.body
     self.assertEqual(result, expected_result)
     self.assertEqual(self.mock_req.status, falcon.HTTP_200)
 def test_on_get_return_correct_list(self):
     self.mock_db.search_session.return_value = [
         common.get_fake_session_0(), common.get_fake_session_1()]
     expected_result = {'sessions': [common.get_fake_session_0(),
                                     common.get_fake_session_1()]}
     self.resource.on_get(self.mock_req, self.mock_req)
     result = self.mock_req.body
     self.assertEqual(expected_result, result)
     self.assertEqual(falcon.HTTP_200, self.mock_req.status)
Example #3
0
    def test_on_delete_removes_job_from_session_jobs(self):
        session = common.get_fake_session_0()
        updated_session = common.get_fake_session_1()
        job = common.get_fake_job_0()

        self.mock_db.get_session.return_value = session
        self.mock_db.get_job.return_value = job

        self.resource.on_delete(self.mock_req, self.mock_req,
                                session['session_id'], 'job_id_2')

        self.mock_db.replace_session.assert_called_with(
            user_id=session['user_id'],
            session_id=session['session_id'],
            doc=updated_session)
Example #4
0
    def test_on_delete_removes_job_from_session_jobs(self):
        session = common.get_fake_session_0()
        updated_session = common.get_fake_session_1()
        job = common.get_fake_job_0()

        self.mock_db.get_session.return_value = session
        self.mock_db.get_job.return_value = job

        self.resource.on_delete(self.mock_req, self.mock_req,
                                session['session_id'],
                                'job_id_2')

        self.mock_db.replace_session.assert_called_with(
            user_id=session['user_id'],
            session_id=session['session_id'],
            doc=updated_session)