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


Python Request.find方法代码示例

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


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

示例1: test_post_send_rtt_usage_not_enough_ko

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_rtt_usage_not_enough_ko(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        def mock_get_rtt_usage(self, session):
            """ Get rrt usage for a user """
            return {'allowed': 10, 'left': 0.5, 'state': 'error',
                    'taken': 9.5, 'year': 2014}

        orig_get_rtt_usage = User.get_rtt_usage
        User.get_rtt_usage = mock_get_rtt_usage
        user = User.by_login(self.session, u'janedoe')
        rtt_data = user.get_rtt_usage(self.session)
        self.assertTrue(rtt_data)

        request = self.create_request({'days': 1,
                                       'date_from': '05/05/2015 - 05/05/2015',
                                       'type': '2',
                                       'breakdown': 'FULL',
                                       })
        view = Send(request)()
        self.assertIsRedirect(view)
        # no new requests were made
        self.assertEqual(Request.find(self.session, count=True), total_req)
        expected = ['error;You only have 0.5 RTT to use.']
        self.assertEqual(request.session.pop_flash(), expected)
        User.get_rtt_usage = orig_get_rtt_usage
开发者ID:doyousoft,项目名称:pyvac,代码行数:32,代码来源:test_request.py

示例2: test_post_send_exception_reason_length_ko

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_exception_reason_length_ko(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        with freeze_time('2015-10-01',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 1,
                'date_from': '12/11/2015 - 12/11/2015',
                'type': '6',
                'breakdown': 'FULL',
                'exception_text': "I need to see Star Wars, I'm a huge fan"
                                  "please, please, please, please, please, "
                                  "please, please, please, please, please, "
                                  "please, please, please, please, please, "
                                  "please, please, please, please, please, "
                                  "please, please, please, please, please, "
                                  "please, please, please, please, please, ",
            })
            view = Send(request)()

        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req)
        expected = [u'error;Exceptionnel reason must not exceed 140 '
                    'characters']
        self.assertEqual(request.session.pop_flash(), expected)
开发者ID:doyousoft,项目名称:pyvac,代码行数:32,代码来源:test_request.py

示例3: test_post_send_rtt_usage_empty_ok

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_rtt_usage_empty_ok(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request, User
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        def mock_get_rtt_usage(self, session):
            """ Get rrt usage for a user """
            return

        orig_get_rtt_usage = User.get_rtt_usage
        User.get_rtt_usage = mock_get_rtt_usage
        user = User.by_login(self.session, u'janedoe')
        rtt_data = user.get_rtt_usage(self.session)
        self.assertIsNone(rtt_data)

        view = Send(self.create_request({
            'days': 1,
            'date_from': '05/05/2015 - 05/05/2015',
            'type': '2',
            'breakdown': 'AM',
        }))()
        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req + 1)
        User.get_rtt_usage = orig_get_rtt_usage
开发者ID:doyousoft,项目名称:pyvac,代码行数:28,代码来源:test_request.py

示例4: test_post_send_recovery_ok

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_recovery_ok(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        msg = u"I need to see Star Wars, because I'm a really huge fan !!!"
        with freeze_time('2015-10-01',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 1,
                'date_from': '12/11/2015 - 12/11/2015',
                'type': '4',
                'breakdown': 'FULL',
                'exception_text': msg,
            })
            view = Send(request)()

        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req + 1)
        last_req = Request.find(self.session)[-1]
        self.assertEqual(last_req.type, u'Récupération')
        self.assertEqual(last_req.message, msg)
        self.session.delete(last_req)
开发者ID:doyousoft,项目名称:pyvac,代码行数:28,代码来源:test_request.py

示例5: test_post_send_wrong_date_ko

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
 def test_post_send_wrong_date_ko(self):
     self.config.testing_securitypolicy(userid=u'janedoe',
                                        permissive=True)
     from pyvac.models import Request
     from pyvac.views.request import Send
     total_req = Request.find(self.session, count=True)
     view = Send(self.create_request({'date_from': 'foo'}))()
     self.assertIsRedirect(view)
     self.assertEqual(Request.find(self.session, count=True), total_req)
开发者ID:doyousoft,项目名称:pyvac,代码行数:11,代码来源:test_request.py

示例6: test_post_send_ok

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
 def test_post_send_ok(self):
     self.config.testing_securitypolicy(userid=u'janedoe',
                                        permissive=True)
     from pyvac.models import Request
     from pyvac.views.request import Send
     total_req = Request.find(self.session, count=True)
     view = Send(self.create_request({'days': 4,
                                      'date_from': '05/05/2014 - 10/05/2014',
                                      'type': 'CP',
                                      }))()
     self.assertIsRedirect(view)
     self.assertEqual(Request.find(self.session, count=True), total_req + 1)
开发者ID:grigouze,项目名称:pyvac,代码行数:14,代码来源:test_request.py

示例7: test_post_send_vacation_type_visibility_ko

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_vacation_type_visibility_ko(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        request = self.create_request({'days': 1,
                                       'date_from': '05/05/2015 - 05/05/2015',
                                       'type': '5',
                                       'breakdown': 'FULL',
                                       })
        view = Send(request)()
        self.assertIsRedirect(view)
        # no new requests were made
        self.assertEqual(Request.find(self.session, count=True), total_req)
        expected = [u'error;You are not allowed to use type: Maladie']
        self.assertEqual(request.session.pop_flash(), expected)
开发者ID:doyousoft,项目名称:pyvac,代码行数:20,代码来源:test_request.py

示例8: test_post_send_vacation_type_visibility_ok

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_vacation_type_visibility_ok(self):
        self.config.testing_securitypolicy(userid=u'admin',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        request = self.create_request({'days': 1,
                                       'date_from': '05/05/2015 - 05/05/2015',
                                       'type': '5',
                                       'breakdown': 'FULL',
                                       'sudo_user': -1,
                                       })
        view = Send(request)()
        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req + 1)
        last_req = Request.find(self.session)[-1]
        self.assertEqual(last_req.type, u'Maladie')
        self.session.delete(last_req)
开发者ID:doyousoft,项目名称:pyvac,代码行数:21,代码来源:test_request.py

示例9: test_post_send_sudo_unknown_ok

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
 def test_post_send_sudo_unknown_ok(self):
     self.config.testing_securitypolicy(userid=u'admin',
                                        permissive=True)
     from pyvac.models import Request, User
     from pyvac.views.request import Send
     total_req = Request.find(self.session, count=True)
     view = Send(self.create_request({'days': 4,
                                      'date_from': '05/05/2015 - 10/05/2015',
                                      'type': '1',
                                      'breakdown': 'FULL',
                                      'sudo_user': '200',
                                      }))()
     self.assertIsRedirect(view)
     self.assertEqual(Request.find(self.session, count=True), total_req + 1)
     last_req = Request.find(self.session)[-1]
     admin_user = User.by_login(self.session, u'admin')
     self.assertEqual(last_req.user_id, admin_user.id)
     self.assertEqual(last_req.status, u'PENDING')
     self.assertFalse(last_req.notified)
开发者ID:baloo,项目名称:pyvac,代码行数:21,代码来源:test_request.py

示例10: replay

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
def replay(settings):

    with open(settings["pyvac.celery.yaml"]) as fdesc:
        Conf = yaml.load(fdesc, YAMLLoader)
    caldav_url = Conf.get("caldav").get("url")

    # XXX Register the database
    create_engine(settings, scoped=True)
    session = DBSession()

    calendar = get_calendar(caldav_url)
    requests = Request.find(session, where=(Request.status == "APPROVED_ADMIN",), order_by=Request.user_id)
    print "total requests", len(requests)
    print ""

    req_to_add = []

    # for each requests
    for req in requests:
        print "-" * 10
        print req.id, req.summarycal, req.date_from, req.date_to
        # check if entry in caldav exists
        results = calendar.date_search(req.date_from, req.date_to)
        if not results:
            # need to add missing entry in caldav
            print "need to insert request"
            req_to_add.append(req.id)
        else:
            summaries = []
            for event in results:
                try:
                    parse_event(event)
                except Exception:
                    continue
                event.load()
                # XXX: if needed to delete entries
                # uid = event.instance.vevent.uid.value
                # ics = '%s/%s.ics' % (caldav_url, uid)
                # print delFromCal(caldav_url, ics)
                summary = event.instance.vevent.summary.value
                summaries.append(summary)
            if req.summarycal not in summaries:
                print "need to insert request"
                req_to_add.append(req.id)

    for req_id in set(req_to_add):
        req = Request.by_id(session, req_id)
        print "processing", req.id, req.summarycal, req.date_from, req.date_to
        ics_url = addToCal(caldav_url, req.date_from, req.date_to, req.summarycal)
        # save ics url in request
        req.ics_url = ics_url
        session.add(req)

    session.flush()
    transaction.commit()
开发者ID:doyousoft,项目名称:pyvac,代码行数:57,代码来源:replay.py

示例11: test_post_send_rtt_ok

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_rtt_ok(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        with freeze_time('2015-10-01',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 1,
                'date_from': '05/05/2015 - 05/05/2015',
                'type': '2',
                'breakdown': 'AM',
            })
            view = Send(request)()

        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req + 1)
开发者ID:doyousoft,项目名称:pyvac,代码行数:22,代码来源:test_request.py

示例12: test_post_send_overlap_ko

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_overlap_ko(self):
        self.config.testing_securitypolicy(userid=u'manager3',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        with freeze_time('2015-04-01',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 8,
                'date_from': '22/04/2015 - 30/04/2015',
                'type': '1',
                'breakdown': 'FULL',
            })
            view = Send(request)()

        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req)
        expected = ['error;Invalid period: days already requested.']
        self.assertEqual(request.session.pop_flash(), expected)
开发者ID:doyousoft,项目名称:pyvac,代码行数:24,代码来源:test_request.py

示例13: test_post_send_holiday_ko

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_holiday_ko(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        with freeze_time('2015-10-01',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 1,
                'date_from': '11/11/2015 - 11/11/2015',
                'type': '1',
                'breakdown': 'FULL',
            })
            view = Send(request)()

        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req)
        expected = ['error;Invalid value for days.']
        self.assertEqual(request.session.pop_flash(), expected)
开发者ID:doyousoft,项目名称:pyvac,代码行数:24,代码来源:test_request.py

示例14: test_post_send_rtt_year_ko

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_rtt_year_ko(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        with freeze_time('2015-10-01',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 1,
                'date_from': '06/05/2016 - 06/05/2016',
                'type': '2',
                'breakdown': 'AM',
            })
            view = Send(request)()

        self.assertIsRedirect(view)
        # no new requests were made
        self.assertEqual(Request.find(self.session, count=True), total_req)
        expected = ['error;RTT can only be used for year 2015.']
        self.assertEqual(request.session.pop_flash(), expected)
开发者ID:doyousoft,项目名称:pyvac,代码行数:25,代码来源:test_request.py

示例15: test_post_send_rtt_holiday_ok

# 需要导入模块: from pyvac.models import Request [as 别名]
# 或者: from pyvac.models.Request import find [as 别名]
    def test_post_send_rtt_holiday_ok(self):
        self.config.testing_securitypolicy(userid=u'janedoe',
                                           permissive=True)
        from pyvac.models import Request
        from pyvac.views.request import Send
        total_req = Request.find(self.session, count=True)

        with freeze_time('2016-10-01',
                         ignore=['celery', 'psycopg2', 'sqlalchemy',
                                 'icalendar']):
            request = self.create_request({
                'days': 5,
                'date_from': '11/07/2016 - 15/07/2016',
                'type': '2',
                'breakdown': 'FULL',
            })
            view = Send(request)()

        self.assertIsRedirect(view)
        self.assertEqual(Request.find(self.session, count=True), total_req + 1)
        last_req = Request.find(self.session)[-1]
        self.assertEqual(last_req.status, u'PENDING')
        self.assertEqual(last_req.days, 4.0)
开发者ID:doyousoft,项目名称:pyvac,代码行数:25,代码来源:test_request.py


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