346 |
346 |
'submitterType': 'usager',
|
347 |
347 |
'external_number': '42-2',
|
348 |
348 |
'external_status': 'statut-1-wcs',
|
349 |
349 |
'address': 'https://wcs.example.com/backoffice/management/foo/2/',
|
350 |
350 |
'interventionData': {'FIELD1': 'Candélabre', 'FIELD2': 42},
|
351 |
351 |
'geom': {'type': 'Point', 'coordinates': [2.323349, 48.833708], 'crs': 'EPSG:4326'},
|
352 |
352 |
'interventionTypeId': '1234',
|
353 |
353 |
'notificationUrl': 'http://testserver/toulouse-smart/test/update-intervention?uuid=%s' % str(UUID),
|
|
354 |
'notification_url': 'http://testserver/toulouse-smart/test/update-intervention?uuid=%s' % str(UUID),
|
354 |
355 |
'onPrivateLand': 'true',
|
355 |
356 |
'safeguardRequired': 'true',
|
356 |
357 |
}
|
357 |
358 |
|
358 |
359 |
|
359 |
360 |
@mock_response(
|
360 |
361 |
['/v1/type-intervention', None, INTERVENTION_TYPES],
|
361 |
362 |
['/v1/intervention', CREATE_INTERVENTION_QUERY, get_json_file('create_intervention')],
|
362 |
363 |
)
|
363 |
364 |
@mock.patch("django.db.models.fields.UUIDField.get_default", return_value=UUID)
|
364 |
365 |
def test_create_intervention(mocked_uuid4, app, smart):
|
365 |
366 |
with pytest.raises(WcsRequest.DoesNotExist):
|
366 |
367 |
smart.wcs_requests.get(uuid=UUID)
|
367 |
368 |
|
368 |
369 |
resp = app.post_json(URL + 'create-intervention/', params=CREATE_INTERVENTION_PAYLOAD)
|
369 |
|
assert str(UUID) in CREATE_INTERVENTION_QUERY['notificationUrl']
|
|
370 |
assert str(UUID) in CREATE_INTERVENTION_QUERY['notification_url']
|
370 |
371 |
assert not resp.json['err']
|
371 |
372 |
assert resp.json['data']['uuid'] == str(UUID)
|
372 |
373 |
assert resp.json['data']['wcs_form_api_url'] == 'https://wcs.example.com/api/forms/foo/2/'
|
373 |
374 |
wcs_request = smart.wcs_requests.get(uuid=UUID)
|
374 |
375 |
assert wcs_request.wcs_form_api_url == 'https://wcs.example.com/api/forms/foo/2/'
|
375 |
376 |
assert wcs_request.wcs_form_number == '42-2'
|
376 |
377 |
assert wcs_request.payload == CREATE_INTERVENTION_QUERY
|
377 |
378 |
assert wcs_request.result == json.loads(get_json_file('create_intervention'))
|
... | ... | |
571 |
572 |
['/v1/intervention', CREATE_INTERVENTION_QUERY, get_json_file('create_intervention')],
|
572 |
573 |
['/api/forms/foo/2/hooks/update_intervention/', UPDATE_INTERVENTION_QUERY, WCS_RESPONSE_SUCCESS],
|
573 |
574 |
)
|
574 |
575 |
@mock.patch("django.db.models.fields.UUIDField.get_default", return_value=UUID)
|
575 |
576 |
def test_update_intervention(mocked_uuid, app, smart, wcs_service):
|
576 |
577 |
resp = app.post_json(URL + 'create-intervention/', params=CREATE_INTERVENTION_PAYLOAD)
|
577 |
578 |
assert not resp.json['err']
|
578 |
579 |
assert CREATE_INTERVENTION_QUERY[
|
579 |
|
'notificationUrl'
|
|
580 |
'notification_url'
|
580 |
581 |
] == 'http://testserver/toulouse-smart/test/update-intervention?uuid=%s' % str(UUID)
|
581 |
582 |
wcs_request = smart.wcs_requests.get(uuid=UUID)
|
582 |
583 |
|
583 |
584 |
mocked_push = mock.patch(
|
584 |
585 |
"passerelle.contrib.toulouse_smart.models.SmartRequest.push",
|
585 |
586 |
return_value=False,
|
586 |
587 |
)
|
587 |
588 |
mocked_push.start()
|
... | ... | |
832 |
833 |
)
|
833 |
834 |
|
834 |
835 |
# smart and wcs are down
|
835 |
836 |
mocked_wcs_request_push.start()
|
836 |
837 |
mocked_smart_request_push.start()
|
837 |
838 |
|
838 |
839 |
assert Job.objects.count() == 0
|
839 |
840 |
resp = app.post_json(URL + 'create-intervention/', params=CREATE_INTERVENTION_PAYLOAD)
|
840 |
|
assert str(UUID) in CREATE_INTERVENTION_QUERY['notificationUrl']
|
|
841 |
assert str(UUID) in CREATE_INTERVENTION_QUERY['notification_url']
|
841 |
842 |
assert not resp.json['err']
|
842 |
843 |
assert resp.json['data']['uuid'] == str(UUID)
|
843 |
844 |
assert resp.json['data']['wcs_form_api_url'] == 'https://wcs.example.com/api/forms/foo/2/'
|
844 |
845 |
wcs_request = smart.wcs_requests.get(uuid=UUID)
|
845 |
846 |
assert wcs_request.wcs_form_api_url == 'https://wcs.example.com/api/forms/foo/2/'
|
846 |
847 |
assert wcs_request.wcs_form_number == '42-2'
|
847 |
848 |
assert wcs_request.payload == CREATE_INTERVENTION_QUERY
|
848 |
849 |
assert wcs_request.status == 'registered'
|
849 |
|
-
|