toulouse-smart: use post-transition time to resolve reverting from DST (#70309)
This commit is contained in:
parent
acfd6898b6
commit
6b68a148b4
|
@ -19,7 +19,7 @@ from django.utils.timezone import localtime, make_aware, make_naive, utc
|
||||||
|
|
||||||
|
|
||||||
def localtz_to_utc(date_time_string):
|
def localtz_to_utc(date_time_string):
|
||||||
aware_dt_in_utc = make_aware(parse_datetime(date_time_string)).astimezone(utc)
|
aware_dt_in_utc = make_aware(parse_datetime(date_time_string), is_dst=False).astimezone(utc)
|
||||||
return aware_dt_in_utc.isoformat()
|
return aware_dt_in_utc.isoformat()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ from passerelle.contrib.toulouse_smart.models import (
|
||||||
WcsRequest,
|
WcsRequest,
|
||||||
WcsRequestFile,
|
WcsRequestFile,
|
||||||
)
|
)
|
||||||
|
from passerelle.contrib.toulouse_smart.utils import localtz_to_utc, utc_to_localtz
|
||||||
from tests.test_manager import login
|
from tests.test_manager import login
|
||||||
|
|
||||||
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'toulouse_smart')
|
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'toulouse_smart')
|
||||||
|
@ -130,6 +131,13 @@ def get_media_file(filename):
|
||||||
return desc.read()
|
return desc.read()
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_daylight_time_change(settings):
|
||||||
|
settings.TIME_ZONE = 'Europe/Paris'
|
||||||
|
settings.USE_TZ = True
|
||||||
|
assert localtz_to_utc('2022-10-30T02:19:48') == '2022-10-30T01:19:48+00:00'
|
||||||
|
assert utc_to_localtz('2022-10-30T01:19:48+00:00') == '2022-10-30T02:19:48'
|
||||||
|
|
||||||
|
|
||||||
@mock_response(['/v1/type-intervention', None, b'<List></List>'])
|
@mock_response(['/v1/type-intervention', None, b'<List></List>'])
|
||||||
def test_empty_intervention_types(smart):
|
def test_empty_intervention_types(smart):
|
||||||
assert smart.get_intervention_types() == []
|
assert smart.get_intervention_types() == []
|
||||||
|
|
Loading…
Reference in New Issue