357 |
357 |
assert resp.json == get_json_file('child_activities')
|
358 |
358 |
status = [x['user_subscribing_status'] for x in resp.json['data']]
|
359 |
359 |
assert len([x for x in status if x == 'subscribed']) == nb_subscribed
|
360 |
360 |
assert len([x for x in status if x == 'not-subscribed']) == nb_not_subscribed
|
361 |
361 |
|
362 |
362 |
|
363 |
363 |
@pytest.mark.parametrize('parameters, err_desc', [
|
364 |
364 |
('&childID=99999', 'Child not found'),
|
365 |
|
('&childID=21293&subscribingStatus=not-a-status', 'wrong value for subscribingStatus'),
|
366 |
|
("&childID=21293&queryDate=2020-02-31", 'not a valid date'),
|
367 |
|
("&childID=21293&queryDate=not-a-date", 'YYYY-MM-DD expected'),
|
|
365 |
('&subscribingStatus=not-a-status', 'wrong value for subscribingStatus'),
|
|
366 |
("&queryDate=2020-02-31", 'not a valid date'),
|
|
367 |
("&queryDate=not-a-date", 'YYYY-MM-DD expected'),
|
368 |
368 |
])
|
369 |
369 |
@mock.patch('passerelle.utils.Request.get')
|
370 |
370 |
@mock.patch('passerelle.utils.Request.post')
|
371 |
371 |
def test_child_activities_errors(mocked_post, mocked_get, parameters, err_desc,
|
372 |
372 |
catalog_mocked_get, catalog_mocked_post, connector, app):
|
373 |
373 |
mocked_get.side_effect = catalog_mocked_get
|
374 |
374 |
mocked_post.side_effect = catalog_mocked_post
|
375 |
375 |
Link.objects.create(resource=connector, family_id='3264', name_id='local')
|
376 |
|
url = '/maelis/test/child-activities?NameID=local'
|
|
376 |
url = '/maelis/test/child-activities?NameID=local&childID=21293'
|
377 |
377 |
url += parameters
|
378 |
378 |
resp = app.get(url)
|
379 |
379 |
assert resp.json['err']
|
380 |
380 |
assert err_desc in resp.json['err_desc']
|
381 |
381 |
|
382 |
382 |
|
383 |
383 |
@mock.patch('passerelle.utils.Request.get')
|
384 |
384 |
@mock.patch('passerelle.utils.Request.post')
|
... | ... | |
447 |
447 |
resp = app.get(url)
|
448 |
448 |
if parameters == '&direction=':
|
449 |
449 |
assert resp.json == get_json_file('bus_lines')
|
450 |
450 |
assert len(resp.json['data']) == nb_bus_lines
|
451 |
451 |
|
452 |
452 |
|
453 |
453 |
@pytest.mark.parametrize('parameters, err_desc', [
|
454 |
454 |
('&childID=99999', 'Child not found'),
|
455 |
|
('&childID=21293&queryDate=2020-02-31', 'not a valid date'),
|
456 |
|
('&childID=21293&queryDate=not-a-date', 'YYYY-MM-DD expected'),
|
457 |
|
('&childID=21293&direction=heaven', 'wrong value for direction'),
|
|
455 |
('&queryDate=2020-02-31', 'not a valid date'),
|
|
456 |
('&queryDate=not-a-date', 'YYYY-MM-DD expected'),
|
|
457 |
('&direction=heaven', 'wrong value for direction'),
|
458 |
458 |
])
|
459 |
459 |
@mock.patch('passerelle.utils.Request.get')
|
460 |
460 |
@mock.patch('passerelle.utils.Request.post')
|
461 |
461 |
def test_child_activities_errors(mocked_post, mocked_get, parameters, err_desc,
|
462 |
462 |
catalog_mocked_get, catalog_mocked_post, connector, app):
|
463 |
463 |
mocked_get.side_effect = catalog_mocked_get
|
464 |
464 |
mocked_post.side_effect = catalog_mocked_post
|
465 |
465 |
Link.objects.create(resource=connector, family_id='3264', name_id='local')
|
466 |
|
url = '/maelis/test/bus-lines?NameID=local&activityID=1&unitID=2'
|
|
466 |
url = '/maelis/test/bus-lines?NameID=local&childID=21293&activityID=1&unitID=2'
|
|
467 |
url += parameters
|
|
468 |
resp = app.get(url)
|
|
469 |
assert resp.json['err']
|
|
470 |
assert err_desc in resp.json['err_desc']
|
|
471 |
|
|
472 |
|
|
473 |
@mock.patch('passerelle.utils.Request.get')
|
|
474 |
@mock.patch('passerelle.utils.Request.post')
|
|
475 |
def test_bus_stops(mocked_post, mocked_get,
|
|
476 |
catalog_mocked_get, catalog_mocked_post, connector, app):
|
|
477 |
mocked_get.side_effect = catalog_mocked_get
|
|
478 |
mocked_post.side_effect = catalog_mocked_post
|
|
479 |
Link.objects.create(resource=connector, family_id='3264', name_id='local')
|
|
480 |
url = '/maelis/test/bus-stops?NameID=local&childID=21293'
|
|
481 |
url += '&busActivityID=A10003151396&busUnitID=A10003151402&queryDate=2020-12-15'
|
|
482 |
resp = app.get(url)
|
|
483 |
assert resp.json == get_json_file('bus_stops')
|
|
484 |
assert len(resp.json['data']) == 6
|
|
485 |
|
|
486 |
|
|
487 |
@pytest.mark.parametrize('parameters, err_desc', [
|
|
488 |
('&childID=99999', 'Child not found'),
|
|
489 |
('&queryDate=2020-02-31', 'not a valid date'),
|
|
490 |
('&queryDate=not-a-date', 'YYYY-MM-DD expected'),
|
|
491 |
('&busActivityID=1', 'Bus activity not found: 1'),
|
|
492 |
('&busUnitID=2', 'Bus unit not found: 2'),
|
|
493 |
])
|
|
494 |
@mock.patch('passerelle.utils.Request.get')
|
|
495 |
@mock.patch('passerelle.utils.Request.post')
|
|
496 |
def test_bus_stops_errors(mocked_post, mocked_get, parameters, err_desc,
|
|
497 |
catalog_mocked_get, catalog_mocked_post, connector, app):
|
|
498 |
mocked_get.side_effect = catalog_mocked_get
|
|
499 |
mocked_post.side_effect = catalog_mocked_post
|
|
500 |
Link.objects.create(resource=connector, family_id='3264', name_id='local')
|
|
501 |
url = '/maelis/test/bus-stops?NameID=local&childID=21293'
|
|
502 |
url += '&busActivityID=A10003151396&busUnitID=A10003151402'
|
467 |
503 |
url += parameters
|
468 |
504 |
resp = app.get(url)
|
469 |
505 |
assert resp.json['err']
|
470 |
506 |
assert err_desc in resp.json['err_desc']
|
471 |
|
-
|