本文整理汇总了Python中events.models.Event.clean方法的典型用法代码示例。如果您正苦于以下问题:Python Event.clean方法的具体用法?Python Event.clean怎么用?Python Event.clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类events.models.Event
的用法示例。
在下文中一共展示了Event.clean方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_different_day_events_rejected
# 需要导入模块: from events.models import Event [as 别名]
# 或者: from events.models.Event import clean [as 别名]
def test_different_day_events_rejected(self):
""" Test that events with start and end time in different days are rejected """
# Event longer than 24 hours
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 17, 0),
end=default_datetime(2016, 5, 4, 19, 0),
creator=self.user
)
event.clean()
# Event shorter than 24 hours
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 1, 23, 0),
end=default_datetime(2016, 5, 2, 1, 0),
creator=self.user
)
event.clean()
示例2: test_start_after_end_events_rejected
# 需要导入模块: from events.models import Event [as 别名]
# 或者: from events.models.Event import clean [as 别名]
def test_start_after_end_events_rejected(self):
""" Test that events with start time greater than end time are rejected """
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 19, 0),
end=default_datetime(2016, 5, 3, 17, 0),
creator=self.user
)
event.clean()
示例3: test_waiting_overlapping_events_rejected
# 需要导入模块: from events.models import Event [as 别名]
# 或者: from events.models.Event import clean [as 别名]
def test_waiting_overlapping_events_rejected(self):
""" Test that waiting overlapping events are rejected """
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.WAITING,
start=default_datetime(2016, 5, 3, 12, 00),
end=default_datetime(2016, 5, 3, 16, 00),
creator=self.user
)
event.clean()
示例4: test_approved_overlapping_events_rejected
# 需要导入模块: from events.models import Event [as 别名]
# 或者: from events.models.Event import clean [as 别名]
def test_approved_overlapping_events_rejected(self):
""" Test that approved overlapping events are rejected """
# Overlapping by 1 minute at the end
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 12, 0),
end=default_datetime(2016, 5, 3, 14, 1),
creator=self.user
)
event.clean()
# Overlapping by 1 minute at the beginning
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 15, 59),
end=default_datetime(2016, 5, 3, 17, 0),
creator=self.user
)
event.clean()
# Completely overlapping, "contained" in another event
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 15, 00),
end=default_datetime(2016, 5, 3, 15, 30),
creator=self.user
)
event.clean()
# Completely overlapping, "containing" another event
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 12, 00),
end=default_datetime(2016, 5, 3, 18, 00),
creator=self.user
)
event.clean()
示例5: test_none_date_rejected
# 需要导入模块: from events.models import Event [as 别名]
# 或者: from events.models.Event import clean [as 别名]
def test_none_date_rejected(self):
""" Test that none dates are rejected """
# Start date is none
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.REJECTED,
start=None,
end=default_datetime(2016, 5, 3, 12, 0),
creator=self.user
)
event.clean()
# End date is none
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.REJECTED,
start=default_datetime(2016, 5, 3, 16, 0),
end=None,
creator=self.user
)
event.clean()
# Both dates are none
with self.assertRaises(ValidationError):
event = Event(
room=self.room,
activity=self.activity,
status=Event.REJECTED,
start=None,
end=None,
creator=self.user
)
event.clean()
示例6: test_valid_events_accepted
# 需要导入模块: from events.models import Event [as 别名]
# 或者: from events.models.Event import clean [as 别名]
def test_valid_events_accepted(self):
""" Test that valid events are not rejected """
# A rejected overlapping event is ok
try:
event = Event(
room=self.room,
activity=self.activity,
status=Event.REJECTED,
start=default_datetime(2016, 5, 3, 14, 0),
end=default_datetime(2016, 5, 3, 16, 0),
creator=self.user
)
event.clean()
except ValidationError:
self.fail("ValidationError exception raised with rejected overlapping event")
# Overlapping with an event in a different room and with the same activity
try:
event = Event(
room=self.room2,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 14, 0),
end=default_datetime(2016, 5, 3, 16, 0),
creator=self.user
)
event.clean()
except ValidationError:
self.fail("ValidationError exception raised with overlapping event in different room")
# An approved event overlapping with a rejected event
try:
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 2, 14, 0),
end=default_datetime(2016, 5, 2, 16, 0),
creator=self.user
)
event.clean()
except ValidationError:
self.fail(
"ValidationError exception raised with event overlapping with a rejected event"
)
# Not overlapping, but immediately before another event
try:
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 12, 0),
end=default_datetime(2016, 5, 3, 14, 0),
creator=self.user
)
event.clean()
except ValidationError:
self.fail("ValidationError exception raised with not overlapping event")
# Not overlapping, but immediately after another event
try:
event = Event(
room=self.room,
activity=self.activity,
status=Event.APPROVED,
start=default_datetime(2016, 5, 3, 16, 0),
end=default_datetime(2016, 5, 3, 18, 0),
creator=self.user
)
event.clean()
except ValidationError:
self.fail("ValidationError exception raised with not overlapping event")