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


Python Calendar.delete方法代码示例

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


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

示例1: TestEventViews

# 需要导入模块: from schedule.models import Calendar [as 别名]
# 或者: from schedule.models.Calendar import delete [as 别名]
class TestEventViews(LoggedInTestCase):

    def setUp(self):
        super(TestEventViews, self).setUp()
        self.cal = Calendar(
            name=random_string(),
            slug=random_string(),
        )
        self.cal.save()
        self.event = Event(
            start=timezone.now(),
            end=timezone.now() + timedelta(weeks=6),
            title=random_string(),
            calendar=self.cal,
        )
        self.event.save()

    def tearDown(self):
        super(TestEventViews, self).tearDown()
        try:
            self.cal.delete()
            self.event.delete()
        except:
            pass

    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,代码行数:60,代码来源:test_events.py

示例2: TestSchedulesViews

# 需要导入模块: from schedule.models import Calendar [as 别名]
# 或者: from schedule.models.Calendar import delete [as 别名]
class TestSchedulesViews(LoggedInTestCase):

    def setUp(self):
        super(TestSchedulesViews, self).setUp()
        self.cal = Calendar(
            name=random_string(),
            slug=random_string(),
        )
        self.cal.save()

    def tearDown(self):
        super(TestSchedulesViews, self).tearDown()
        try:
            self.cal.delete()
        except:
            pass

    def test_schedule_detail_view_works_with_query_args(self):
        response = self.client.get(
            reverse('openduty.schedules.details', args=[self.cal.slug]),
            {'month': '11', 'year': '2014'},
        )
        self.assertEqual(response.status_code, 200)
开发者ID:40a,项目名称:openduty,代码行数:25,代码来源:test_schedules.py

示例3: TestGetEscalation

# 需要导入模块: from schedule.models import Calendar [as 别名]
# 或者: from schedule.models.Calendar import delete [as 别名]
class TestGetEscalation(BaseTestCase):

    def setUp(self):
        super(TestGetEscalation, self).setUp()
        self.sp = SchedulePolicy(name=random_string(), repeat_times=1)
        self.sp.save()
        self.service = Service(name=random_string(), policy=self.sp)
        self.service.save()
        self.cal = Calendar(
            name=random_string(),
            slug=random_string(),
        )
        self.cal.save()
        self.spr = SchedulePolicyRule(
            schedule_policy=self.sp,
            position=0,
            schedule=self.cal,
            escalate_after=1,
        )
        self.spr.save()

    def tearDown(self):
        super(TestGetEscalation, self).tearDown()
        try:
            self.spr.delete()
            self.cal.delete()
            self.service.delete()
            self.sp.delete()
        except:
            pass

    def test_get_escalation_works_with_no_recurrence(self):
        event = Event(
            start = timezone.now() - timedelta(days=1),
            end = timezone.now() + timedelta(days=1),
            title = '{username},{username}'.format(username=self.username),
            calendar = self.cal,
        )
        event.save()
        try:
            events = get_escalation_for_service(self.service)
            self.assertEqual(2, len(events))
        finally:
            event.delete()

    def test_get_escalation_fails_with_no_recurrence_after_event_end(self):
        event = Event(
            start = timezone.now() - timedelta(days=2),
            end = timezone.now() - timedelta(days=1),
            title = '{username},{username}'.format(username=self.username),
            calendar = self.cal,
        )
        event.save()
        try:
            events = get_escalation_for_service(self.service)
            self.assertEqual(0, len(events))
        finally:
            event.delete()

    def test_get_escalation_empty_when_recurrance_is_not_now(self):
        rule = Rule(
            name=random_string(),
            description=random_string(),
            frequency='WEEKLY',
        )
        rule.save()
        # Active yesterday, and 1 week from now, but not today
        event = Event(
            start = timezone.now() - timedelta(days=2),
            end = timezone.now() - timedelta(days=1),
            title = '{username},{username}'.format(username=self.username),
            calendar = self.cal,
            rule = rule,
        )
        event.save()
        events = get_escalation_for_service(self.service)
        self.assertEqual(0, len(events))

    def test_get_escalation_works_when_recurrance_is_now(self):
        rule = Rule(
            name=random_string(),
            description=random_string(),
            frequency='WEEKLY',
        )
        rule.save()
        # Active last week at this time, recurring now
        event = Event(
            start = timezone.now() - timedelta(days=7, hours=5),
            end = timezone.now() + timedelta(hours=4) - timedelta(days=7),
            title = '{username},{username}'.format(username=self.username),
            calendar = self.cal,
            rule = rule,
        )
        event.save()
        events = get_escalation_for_service(self.service)
        self.assertEqual(2, len(events))

    def test_get_escalation_returns_empty_for_muted_services(self):
        event = Event(
            start = timezone.now() - timedelta(days=1),
#.........这里部分代码省略.........
开发者ID:40a,项目名称:openduty,代码行数:103,代码来源:test_escalation_helper.py


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