Commit 1ee54fb8 by Sergey Petrunin

Added test for DateTimeField validation when server has timezone with DST and…

Added test for DateTimeField validation when server has timezone with DST and input is a native time in a DST shift interval.
Added pytz to requirements-testing.txt to reproduce the case.
parent 3b466fab
......@@ -2,3 +2,4 @@
pytest==3.0.5
pytest-django==3.1.2
pytest-cov==2.4.0
pytz==2016.10
......@@ -9,7 +9,7 @@ import pytest
from django.http import QueryDict
from django.test import TestCase, override_settings
from django.utils import six
from django.utils.timezone import utc
from django.utils.timezone import utc, pytz
import rest_framework
from rest_framework import serializers
......@@ -1205,6 +1205,23 @@ class TestNaiveDateTimeField(FieldValues):
field = serializers.DateTimeField(default_timezone=None)
class TestNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues):
"""
Invalid values for `DateTimeField` with datetime in DST shift (non-existing or ambiguous) and timezone with DST.
Timezone America/New_York has DST shift from 2017-03-12T02:00:00 to 2017-03-12T03:00:00 and
from 2017-11-05T02:00:00 to 2017-11-05T01:00:00 in 2017.
"""
valid_inputs = {}
invalid_inputs = {
'2017-03-12T02:30:00': [
'Datetime can not be converted to server timezone due to NonExistentTimeError.'],
'2017-11-05T01:30:00': [
'Datetime can not be converted to server timezone due to AmbiguousTimeError.']
}
outputs = {}
field = serializers.DateTimeField(default_timezone=pytz.timezone('America/New_York'))
class TestTimeField(FieldValues):
"""
Valid and invalid values for `TimeField`.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment