当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.flush方法代码示例

本文整理汇总了Python中stalker.db.DBSession.flush方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.flush方法的具体用法?Python DBSession.flush怎么用?Python DBSession.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stalker.db.DBSession的用法示例。


在下文中一共展示了DBSession.flush方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_creating_a_time_log_for_a_task_whose_dependent_tasks_has_not_finished_yet

# 需要导入模块: from stalker.db import DBSession [as 别名]
# 或者: from stalker.db.DBSession import flush [as 别名]
    def test_creating_a_time_log_for_a_task_whose_dependent_tasks_has_not_finished_yet(self):
        """testing if a HTTPServer error will be raised when a time log tried
        to be created for a Task whose dependent tasks has not finished yet
        """
        # create a new task
        task2 = Task(
            name='Test Task 2',
            project=self.proj1,
            depends=[self.task1],
            resources=[self.user1],
            schedule_timing=4,
            schedule_unit='d',
            schedule_model='effort',
            status_list=self.task_status_list
        )
        DBSession.add(task2)
        DBSession.flush()
        transaction.commit()

        # now because task2 is depending on to the task1
        # and task1 is not finished yet (where the status is not
        # set to Complete, we should expect an HTTPServerError()
        # to be raised
        request = testing.DummyRequest()
        request.params['task_id'] = task2.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 01 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 01 Nov 2013 17:00:00 GMT"

        response = time_log.create_time_log(request)
        self.assertEqual(
            response.status_int, 500
        )
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:35,代码来源:test_time_log.py

示例2: test_deleting_time_log_for_a_task_with_status_complete

# 需要导入模块: from stalker.db import DBSession [as 别名]
# 或者: from stalker.db.DBSession import flush [as 别名]
    def test_deleting_time_log_for_a_task_with_status_complete(self):
        """testing if it is not allowed to delete a time log of a task with
        status completed
        """
        # TODO: This is also testing some functionality from view.task, slit it
        # create two new task
        task0 = Task(
            name='Test Task 0',
            project=self.proj1,
            status_list=self.task_status_list
        )
        task1 = Task(
            name='Test Task 1',
            parent=task0,
            status_list=self.task_status_list,
            resources=[self.user1]
        )
        task1.status = self.status_wip
        DBSession.add_all([task0, task1])
        DBSession.commit()
        DBSession.flush()
        transaction.commit()

        self.assertEqual(task0.status, self.status_new)
        self.assertEqual(task1.status, self.status_wip)

        # now add a time log for task3 through create_time_log view
        request = testing.DummyRequest()

        # patch get_logged_in_user
        admins = Group.query.filter(Group.name == 'admins').first()
        self.user1.groups.append(admins)
        m = mocker.Mocker()
        obj = m.replace("stalker_pyramid.views.auth.get_logged_in_user")
        obj(request)
        m.result(self.user1)
        m.count(1, 1000000000)
        m.replay()
        request.route_url = lambda x, id=1: 'view_user'

        request.params['task_id'] = task1.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 19 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 19 Nov 2013 17:00:00 GMT"
        response = time_log.create_time_log(request)
        self.assertEqual(response.status_int, 200)

        # set it to complete
        task1.status = self.status_cmpl

        # now try to remove it
        request.matchdict['id'] = task1.time_logs[0].id
        response = time_log.delete_time_log(request)
        self.assertEqual(response.status_int, 500)
        self.assertEqual(
            response.body,
            'Error: You can not delete a TimeLog of a Task with status CMPL'
        )
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:60,代码来源:test_time_log.py

示例3: test_creating_a_time_log_for_a_task_whose_dependending_tasks_already_has_time_logs

# 需要导入模块: from stalker.db import DBSession [as 别名]
# 或者: from stalker.db.DBSession import flush [as 别名]
    def test_creating_a_time_log_for_a_task_whose_dependending_tasks_already_has_time_logs(self):
        """testing if a HTTPServer error will be raised when a time log tried
        to be for a task whose depending tasks already has time logs created
        (This test should be in Stalker)
        """
        # create a new task
        task2 = Task(
            name='Test Task 2',
            project=self.proj1,
            depends=[self.task1],
            resources=[self.user1],
            schedule_timing=4,
            schedule_unit= 'd',
            schedule_model='effort',
            status_list=self.task_status_list
        )
        DBSession.add(task2)
        DBSession.flush()
        transaction.commit()

        # set the status of task1 to complete
        self.task1.status = self.status_cmpl
        # artificially update task2 status to rts
        task2.status = self.status_rts
        DBSession.flush()
        transaction.commit()

        # and now create time logs for task2
        request = testing.DummyRequest()
        request.params['task_id'] = task2.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 01 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 01 Nov 2013 17:00:00 GMT"
        response = time_log.create_time_log(request)
        self.assertEqual(response.status_int, 200)
        DBSession.add(task2)
        DBSession.flush()
        transaction.commit()

        # now because task2 is depending on to the task1
        # and task2 has now started, entering any new time logs to task1
        # is forbidden
        request = testing.DummyRequest()
        request.params['task_id'] = self.task1.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 02 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 02 Nov 2013 17:00:00 GMT"

        response = time_log.create_time_log(request)
        self.assertEqual(
            response.status_int, 500
        )
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:54,代码来源:test_time_log.py

示例4: test_creating_a_time_log_for_a_leaf_task_will_set_its_parents_status_to_wip

# 需要导入模块: from stalker.db import DBSession [as 别名]
# 或者: from stalker.db.DBSession import flush [as 别名]
    def test_creating_a_time_log_for_a_leaf_task_will_set_its_parents_status_to_wip(self):
        """testing if the status of the parent task will turn to wip if time
        log is entered to a child task
        """
        # TODO: This is also testing some functionality from view.task, slit it
        # create two new task
        task0 = Task(
            name='Test Task 0',
            project=self.proj1,
            status_list=self.task_status_list
        )
        task1 = Task(
            name='Test Task 1',
            parent=task0,
            status_list=self.task_status_list
        )
        task2 = Task(
            name='Test Task 2',
            parent=task1,
            resources=[self.user1],
            status_list=self.task_status_list,
            status=self.status_rts
        )
        task3 = Task(
            name='Test Task 3',
            parent=task1,
            resources=[self.user1],
            status_list=self.task_status_list,
            status=self.status_rts
        )
        task4 = Task(
            name='Test Task 4',
            parent=task0,
            resources=[self.user1],
            status_list=self.task_status_list,
            status=self.status_rts
        )
        DBSession.add_all([task0, task1, task2, task3, task4])
        DBSession.commit()
        DBSession.flush()
        transaction.commit()

        self.assertEqual(task0.status, self.status_new)
        self.assertEqual(task1.status, self.status_new)
        self.assertEqual(task2.status, self.status_rts)
        self.assertEqual(task3.status, self.status_rts)
        self.assertEqual(task4.status, self.status_rts)

        # now add a time log for task3 through create_time_log view
        request = testing.DummyRequest()

        # patch get_logged_in_user
        admins = Group.query.filter(Group.name == 'admins').first()
        self.user1.groups.append(admins)
        m = mocker.Mocker()
        obj = m.replace("stalker_pyramid.views.auth.get_logged_in_user")
        obj(request)
        m.result(self.user1)
        m.count(1, 1000000000)
        m.replay()
        request.route_url = lambda x, id=1: 'view_user'

        request.params['task_id'] = task3.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 19 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 19 Nov 2013 17:00:00 GMT"
        response = time_log.create_time_log(request)
        self.assertEqual(response.status_int, 200)

        # now expect to have the status of task1 to be wip
        self.assertEqual(task3.status, self.status_wip)
        self.assertEqual(task2.status, self.status_rts)
        self.assertEqual(task1.status, self.status_wip)
        self.assertEqual(task0.status, self.status_wip)
        self.assertEqual(task4.status, self.status_rts)

        request.params['task_id'] = task2.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 18 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 18 Nov 2013 17:00:00 GMT"
        response = time_log.create_time_log(request)
        self.assertEqual(response.status_int, 200)

        # now expect to have the status of task1 to be wip
        self.assertEqual(task3.status, self.status_wip)
        self.assertEqual(task2.status, self.status_wip)
        self.assertEqual(task1.status, self.status_wip)
        self.assertEqual(task0.status, self.status_wip)
        self.assertEqual(task4.status, self.status_rts)

        # now request a review and approve the task2 and task3 and expect the
        # task1 status is complete
        from stalker_pyramid.views.task import request_review, review_task
        #request = testing.DummyRequest()
        request.matchdict['id'] = task2.id
        request.params['send_email'] = 0
        request.route_url = lambda x, id: 'localhost:6453/tasks/23/view'
        request.route_path = lambda x, id: '/tasks/23/view'

        response = request_review(request)
#.........这里部分代码省略.........
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:103,代码来源:test_time_log.py


注:本文中的stalker.db.DBSession.flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。