• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Rule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中schedule.models.Rule的典型用法代码示例。如果您正苦于以下问题:Python Rule类的具体用法?Python Rule怎么用?Python Rule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setUp

 def setUp(self):
     rule = Rule(frequency="WEEKLY")
     rule.save()
     cal = Calendar(name="MyCal")
     cal.save()
     self.recurring_data = {
         'title': 'Recent Event',
         'start': datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
         'end': datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
         'end_recurring_period': datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
         'rule': rule,
         'calendar': cal
     }
     self.data = {
         'title': 'Recent Event',
         'start': datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
         'end': datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
         'end_recurring_period': datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
         'calendar': cal
     }
     self.near_periodend_recurring_data = {
         'title': 'Special Event',
         'start': datetime.datetime(2014, 5, 1, 8, 0, tzinfo=pytz.utc),
         'end': datetime.datetime(2014, 5, 1, 9, 0, tzinfo=pytz.utc),
         'end_recurring_period': datetime.datetime(2014, 5, 8, 9, 0, tzinfo=pytz.utc),
         'rule': rule,
         'calendar': cal
     }
     self.recurring_event = Event.objects.create(**self.recurring_data)
     self.start = datetime.datetime(2008, 1, 12, 0, 0, tzinfo=pytz.utc)
     self.end = datetime.datetime(2008, 1, 27, 0, 0, tzinfo=pytz.utc)
开发者ID:jrutila,项目名称:django-schedule,代码行数:31,代码来源:test_occurrence.py


示例2: setUp

    def setUp(self):
        self.day = Day(events=Event.objects.all(),
                       date=datetime.datetime(datetime.datetime.now().year, 2, 7, 0, 0, tzinfo=pytz.utc))
        self.day_out_of_limit = Day(events=Event.objects.all(),
                       date=datetime.datetime(datetime.datetime.now().year + 3, 2, 7, 0, 0, tzinfo=pytz.utc))
        self.day_out_of_limit_lower = Day(events=Event.objects.all(),
                       date=datetime.datetime(datetime.datetime.now().year - 3, 2, 7, 0, 0, tzinfo=pytz.utc))

        rule = Rule(frequency='WEEKLY')
        rule.save()
        self.cal = Calendar(name='MyCal', slug='MyCalSlug')
        self.cal.save()

        data = {
            'title': 'Recent Event',
            'start': datetime.datetime(datetime.datetime.now().year, 1, 5, 8, 0, tzinfo=pytz.utc),
            'end': datetime.datetime(datetime.datetime.now().year, 1, 5, 9, 0, tzinfo=pytz.utc),
            'end_recurring_period': datetime.datetime(datetime.datetime.now().year, 5, 5, 0, 0, tzinfo=pytz.utc),
            'rule': rule,
            'calendar': self.cal,
        }
        recurring_event = Event(**data)
        recurring_event.save()
        self.period = Period(events=Event.objects.all(),
                             start=datetime.datetime(datetime.datetime.now().year, 1, 4, 7, 0, tzinfo=pytz.utc),
                             end=datetime.datetime(datetime.datetime.now().year, 1, 21, 7, 0, tzinfo=pytz.utc))
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:26,代码来源:test_templatetags.py


示例3: test_recurring_event_get_occurrence_in_timezone

    def test_recurring_event_get_occurrence_in_timezone(self):
        cal = Calendar(name="MyCal")
        cal.save()
        rule = Rule(frequency = "WEEKLY")
        rule.save()

        # Event start and end are UTC because that is what is coming
        # from the database
        event = self.__create_recurring_event(
                    'Recurrent event test get_occurrence',
                    datetime.datetime(2014, 3, 21, 6, 0, tzinfo=pytz.utc),
                    datetime.datetime(2014, 3, 21, 8, 0, tzinfo=pytz.utc),
                    datetime.datetime(2014, 4, 11, 0, 0, tzinfo=pytz.utc),
                    rule,
                    cal,
                    )
        event.save()
        tzinfo = pytz.timezone('Europe/Helsinki')
        start = tzinfo.localize(datetime.datetime(2014, 3, 28, 8, 0)) # +2
        occurrence = event.get_occurrence(start)
        self.assertEqual(occurrence.start, start)
        occurrence.save()
        # DST change on March 30th from +2 to +3
        start = tzinfo.localize(datetime.datetime(2014, 4, 4, 8, 0)) # +3
        occurrence = event.get_occurrence(start)
        self.assertEqual(occurrence.start, start)
开发者ID:jrutila,项目名称:django-scheduler,代码行数:26,代码来源:test_event.py


示例4: test_recurring_event_with_moved_get_occurrences_after

    def test_recurring_event_with_moved_get_occurrences_after(self):

        cal = Calendar(name="MyCal")
        cal.save()
        rule = Rule(frequency="WEEKLY")
        rule.save()
        recurring_event= self.__create_recurring_event(
                    'Recurrent event test get_occurrence',
                    datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
                    rule,
                    cal,
                    )

        recurring_event.save()
        occurrence = recurring_event.get_occurrence(datetime.datetime(2008, 1, 12, 8, 0, tzinfo=pytz.utc))
        occurrence.move(
          datetime.datetime(2008, 1, 15, 8, 0, tzinfo=pytz.utc),
          datetime.datetime(2008, 1, 15, 9, 0, tzinfo=pytz.utc))
        gen = recurring_event.occurrences_after(
          datetime.datetime(2008, 1, 14, 8, 0, tzinfo=pytz.utc))
        occurrence2 = next(gen)
        #    end = datetime.datetime(2008, 1, 6, tzinfo=pytz.utc))
        #occurrence = occurrences[0]
        #occurrence2 = recurring_event.occurrences_after(datetime.datetime(2008, 1, 5, tzinfo=pytz.utc)).next()
        self.assertEqual(occurrence, occurrence2)
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:27,代码来源:test_event.py


示例5: test_event_can_be_recurring

 def test_event_can_be_recurring(self):
     rule = Rule(
         name=random_string(),
         description=random_string(),
         frequency='WEEKLY',
     )
     rule.save()
     try:
         url = reverse(
             'openduty.events.create_or_edit_event',
             kwargs = {
                 'calendar_slug': self.cal.slug,
                 'event_id': str(self.event.id),
             },
         )
         response = self.client.post(
             path = url,
             data = {
                 "start_0": self.event.start.strftime('%Y-%m-%d'),
                 "start_1": "09:00",
                 "end_0": self.event.end.strftime('%Y-%m-%d'),
                 "end_1": "23:00",
                 "description": "desc",
                 "rule": str(rule.id),
                 "oncall": "foo",
                 "fallback": "bar",
             },
         )
         self.assertEqual(302, response.status_code)
         e = Event.objects.get(id=self.event.id)
         self.assertEqual(rule, e.rule)
     finally:
         rule.delete()
开发者ID:40a,项目名称:openduty,代码行数:33,代码来源:test_events.py


示例6: test_get_calendar_for_object

 def test_get_calendar_for_object(self):
     calendar = Calendar(name='My Cal')
     calendar.save()
     rule = Rule()
     rule.save()
     calendar.create_relation(rule)
     result = Calendar.objects.get_calendar_for_object(rule)
     self.assertEqual(result.name, 'My Cal')
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:8,代码来源:test_calendar.py


示例7: test_get_or_create_calendar_for_object_withouth_name

 def test_get_or_create_calendar_for_object_withouth_name(self):
     """
         Test with already created calendar
     """
     rule = Rule()
     rule.save()
     calendar = Calendar.objects.get_or_create_calendar_for_object(rule)
     calendar_from_rule = Calendar.objects.get_calendars_for_object(rule)[0]
     self.assertEqual(calendar, calendar_from_rule)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:9,代码来源:test_calendar.py


示例8: test_get_or_create_calendar_for_object_without_calendar

 def test_get_or_create_calendar_for_object_without_calendar(self):
     """
         Creation test
     """
     rule = Rule()
     rule.save()
     calendar = Calendar.objects.get_or_create_calendar_for_object(rule, name='My Cal')
     self.assertEqual(calendar.name, 'My Cal')
     calendar_from_rule = Calendar.objects.get_calendars_for_object(rule)[0]
     self.assertEqual(calendar, calendar_from_rule)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:10,代码来源:test_calendar.py


示例9: test_get_calendar_for_object_with_more_than_one_calendar

 def test_get_calendar_for_object_with_more_than_one_calendar(self):
     calendar_1 = Calendar(name='My Cal 1')
     calendar_1.save()
     calendar_2 = Calendar(name='My Cal 2')
     calendar_2.save()
     rule = Rule()
     rule.save()
     calendar_1.create_relation(rule)
     calendar_2.create_relation(rule)
     with self.assertRaises(AssertionError):
         result = Calendar.objects.get_calendar_for_object(rule)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:11,代码来源:test_calendar.py


示例10: test_calendar_absolute_and_event_url

    def test_calendar_absolute_and_event_url(self):
        """
            this test seems to not make too much send, just added since an
            url was with wrong reverse name.

        """
        rule = Rule()
        rule.save()
        calendar = Calendar.objects.get_or_create_calendar_for_object(rule, name='My Cal', distinction='owner')
        abs_url = calendar.get_absolute_url()
        calendar.add_event_url()
        relation = CalendarRelation.objects.create_relation(calendar, rule)
开发者ID:Gustavosdo,项目名称:django-scheduler,代码行数:12,代码来源:test_calendar.py


示例11: setUp

 def setUp(self):
     rule = Rule(frequency = "WEEKLY")
     rule.save()
     data = {
             'title': 'Recent Event',
             'start': datetime.datetime(2008, 1, 5, 8, 0),
             'end': datetime.datetime(2008, 1, 5, 9, 0),
             'end_recurring_period' : datetime.datetime(2008, 5, 5, 0, 0),
             'rule': rule,
            }
     recurring_event = Event(**data)
     recurring_event.save()
     self.month = Month(events=Event.objects.all(),
                        date=datetime.datetime(2008, 2, 7, 9, 0))
开发者ID:schacon,项目名称:django-schedule,代码行数:14,代码来源:tests.py


示例12: setUp

 def setUp(self):
     rule = Rule(frequency="WEEKLY")
     rule.save()
     cal = Room(name="MyCal")
     cal.save()
     data = {
         "title": "Recent Reservation",
         "start": datetime.datetime(2008, 1, 5, 8, 0),
         "end": datetime.datetime(2008, 1, 5, 9, 0),
         "end_recurring_period": datetime.datetime(2008, 5, 5, 0, 0),
         "rule": rule,
         "room": cal,
     }
     self.recurring_reservation = Reservation(**data)
     self.recurring_reservation.save()
开发者ID:bjdag1234,项目名称:django-schedule-rooms,代码行数:15,代码来源:test_periods.py


示例13: setUp

 def setUp(self):
     rule = Rule(frequency="WEEKLY")
     rule.save()
     cal = Calendar(name="MyCal")
     cal.save()
     data = {
         "title": "Recent Event",
         "start": datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
         "end": datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
         "end_recurring_period": datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
         "rule": rule,
         "calendar": cal,
     }
     self.recurring_event = Event(**data)
     self.recurring_event.save()
开发者ID:RossLote,项目名称:fuzzy-ninja,代码行数:15,代码来源:test_periods.py


示例14: setUp

 def setUp(self):
     rule = Rule(frequency = "WEEKLY")
     rule.save()
     cal = Calendar(name="MyCal")
     cal.save()
     data = {
             'title': 'Recent Event',
             'start': datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
             'end': datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
             'end_recurring_period' : datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
             'rule': rule,
             'calendar': cal
            }
     self.recurring_event = Event(**data)
     self.recurring_event.save()
开发者ID:Gustavosdo,项目名称:django-scheduler,代码行数:15,代码来源:test_periods.py


示例15: test_occurences_with_recurrent_event_end_recurring_period_edge_case

    def test_occurences_with_recurrent_event_end_recurring_period_edge_case(self):

        cal = Calendar(name='MyCal')

        rule = Rule(frequency = "DAILY")
        rule.save()
        start = timezone.now() + datetime.timedelta(days=1)
        event = self.__create_recurring_event(
                            'Non recurring event test get_occurrence',
                            start,
                            start + datetime.timedelta(hours=1),
                            start + datetime.timedelta(days=10),
                            rule,
                            cal)
        occurrences = list(event.occurrences_after())
        self.assertEqual(len(occurrences), 11)
开发者ID:JoshLabs,项目名称:django-scheduler,代码行数:16,代码来源:test_event.py


示例16: test_prevent_type_error_when_comparing_dates_when_tz_off

    def test_prevent_type_error_when_comparing_dates_when_tz_off(self):
        cal = Calendar(name="MyCal")
        cal.save()
        rule = Rule(frequency="WEEKLY")
        rule.save()

        event = self.__create_recurring_event(
                    'Recurrent event test get_occurrence',
                    datetime.datetime(2008, 1, 5, 8, 0),
                    datetime.datetime(2008, 1, 5, 9, 0),
                    datetime.datetime(2008, 5, 5, 0, 0),
                    rule,
                    cal,
                    )
        naive_date = datetime.datetime(2008, 1, 20, 0, 0)
        self.assertIsNone(event.get_occurrence(naive_date))
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:16,代码来源:test_event.py


示例17: setUp

 def setUp(self):
     rule = Rule(frequency="WEEKLY")
     rule.save()
     cal = Calendar(name="MyCal")
     cal.save()
     data = {
         "title": "Recent Event",
         "start": datetime.datetime(2008, 1, 5, 8, 0),
         "end": datetime.datetime(2008, 1, 5, 9, 0),
         "end_recurring_period": datetime.datetime(2008, 5, 5, 0, 0),
         "rule": rule,
         "calendar": cal,
     }
     recurring_event = Event(**data)
     recurring_event.save()
     self.month = Month(events=Event.objects.all(), date=datetime.datetime(2008, 2, 7, 9, 0))
开发者ID:senyai,项目名称:django-schedule,代码行数:16,代码来源:test_periods.py


示例18: test_get_absolute

 def test_get_absolute(self):
     cal = Calendar(name='MyCal')
     cal.save()
     rule = Rule(frequency="DAILY")
     rule.save()
     start = timezone.now() + datetime.timedelta(days=1)
     event = self.__create_recurring_event(
                         'Non recurring event test get_occurrence',
                         start,
                         start + datetime.timedelta(hours=1),
                         start + datetime.timedelta(days=10),
                         rule,
                         cal)
     event.save()
     url = event.get_absolute_url()
     self.assertEqual(reverse('event', kwargs={'event_id': event.id}), url)
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:16,代码来源:test_event.py


示例19: test_recurring_event_get_occurrences_after

    def test_recurring_event_get_occurrences_after(self):

        cal = Calendar(name="MyCal")
        cal.save()
        rule = Rule(frequency="WEEKLY")
        rule.save()
        recurring_event= self.__create_recurring_event(
                    'Recurrent event test get_occurrence',
                    datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
                    rule,
                    cal,
                    )

        recurring_event.save()
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:16,代码来源:test_event.py


示例20: test_prevent_type_error_when_comparing_naive_and_aware_dates

    def test_prevent_type_error_when_comparing_naive_and_aware_dates(self):
        # this only test if the TypeError is raised
        cal = Calendar(name="MyCal")
        cal.save()
        rule = Rule(frequency="WEEKLY")
        rule.save()

        event = self.__create_recurring_event(
                    'Recurrent event test get_occurrence',
                    datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
                    datetime.datetime(2008, 5, 5, 0, 0, tzinfo=pytz.utc),
                    rule,
                    cal,
                    )
        naive_date = datetime.datetime(2008, 1, 20, 0, 0)
        self.assertIsNone(event.get_occurrence(naive_date))
开发者ID:nwaxiomatic,项目名称:django-scheduler,代码行数:17,代码来源:test_event.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python periods.Month类代码示例发布时间:2022-05-27
下一篇:
Python models.Event类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap