Added test for errors when saving timezone-aware times if not supported.
This commit is contained in:
parent
f35ab74752
commit
6a5ef557f8
|
@ -25,3 +25,7 @@ class Timestamp(models.Model):
|
||||||
|
|
||||||
class AllDayEvent(models.Model):
|
class AllDayEvent(models.Model):
|
||||||
day = models.DateField()
|
day = models.DateField()
|
||||||
|
|
||||||
|
|
||||||
|
class DailyEvent(models.Model):
|
||||||
|
time = models.TimeField()
|
||||||
|
|
|
@ -37,7 +37,8 @@ from .forms import (
|
||||||
EventSplitForm,
|
EventSplitForm,
|
||||||
)
|
)
|
||||||
from .models import (
|
from .models import (
|
||||||
AllDayEvent, Event, MaybeEvent, Session, SessionEvent, Timestamp,
|
AllDayEvent, DailyEvent, Event, MaybeEvent, Session, SessionEvent,
|
||||||
|
Timestamp,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -270,6 +271,13 @@ class LegacyDatabaseTests(TestCase):
|
||||||
class NewDatabaseTests(TestCase):
|
class NewDatabaseTests(TestCase):
|
||||||
naive_warning = 'DateTimeField Event.dt received a naive datetime'
|
naive_warning = 'DateTimeField Event.dt received a naive datetime'
|
||||||
|
|
||||||
|
@skipIfDBFeature('supports_timezones')
|
||||||
|
def test_aware_time_unsupported(self):
|
||||||
|
t = datetime.time(13, 20, 30, tzinfo=EAT)
|
||||||
|
msg = 'backend does not support timezone-aware times.'
|
||||||
|
with self.assertRaisesMessage(ValueError, msg):
|
||||||
|
DailyEvent.objects.create(time=t)
|
||||||
|
|
||||||
@requires_tz_support
|
@requires_tz_support
|
||||||
def test_naive_datetime(self):
|
def test_naive_datetime(self):
|
||||||
dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
|
dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
|
||||||
|
|
Loading…
Reference in New Issue