toulouse_smart: do not try to localize None dates (#76624)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
43847c831d
commit
eba52f2804
|
@ -24,5 +24,7 @@ def localtz_to_utc(date_time_string):
|
||||||
|
|
||||||
|
|
||||||
def utc_to_localtz(date_time_string):
|
def utc_to_localtz(date_time_string):
|
||||||
|
if date_time_string is None:
|
||||||
|
return None
|
||||||
aware_dt_in_local_tz = localtime(parse_datetime(date_time_string))
|
aware_dt_in_local_tz = localtime(parse_datetime(date_time_string))
|
||||||
return make_naive(aware_dt_in_local_tz).isoformat()
|
return make_naive(aware_dt_in_local_tz).isoformat()
|
||||||
|
|
|
@ -1207,3 +1207,21 @@ def test_pk_change_migration(migration):
|
||||||
assert WcsRequest.objects.get(pk=job.parameters['pk'])
|
assert WcsRequest.objects.get(pk=job.parameters['pk'])
|
||||||
assert wcs_request.files.get().resource_id == wcs_request.uuid
|
assert wcs_request.files.get().resource_id == wcs_request.uuid
|
||||||
assert wcs_request.smart_requests.get().resource_id == wcs_request.uuid
|
assert wcs_request.smart_requests.get().resource_id == wcs_request.uuid
|
||||||
|
|
||||||
|
|
||||||
|
CREATE_INTERNVENTION_WITH_NONE = json.dumps(
|
||||||
|
dict(json.loads(get_json_file('create_intervention')), interventionCreated=None)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_response(
|
||||||
|
['/v1/type-intervention', None, INTERVENTION_TYPES],
|
||||||
|
['/v1/intervention', CREATE_INTERVENTION_QUERY, CREATE_INTERNVENTION_WITH_NONE],
|
||||||
|
)
|
||||||
|
@mock.patch("django.db.models.fields.UUIDField.get_default", return_value=UUID)
|
||||||
|
def test_create_intervention_none_dates(mocked_uuid4, app, smart):
|
||||||
|
app.post_json(URL + 'create-intervention/', params=CREATE_INTERVENTION_PAYLOAD)
|
||||||
|
wcs_request = smart.wcs_requests.get(uuid=UUID)
|
||||||
|
assert wcs_request.result['interventionCreated'] is None
|
||||||
|
assert wcs_request.result['interventionDesired'] == '2021-06-30T18:08:05'
|
||||||
|
assert wcs_request.status == 'sent'
|
||||||
|
|
Loading…
Reference in New Issue