26 |
26 |
import os
|
27 |
27 |
import xml.etree.ElementTree as ET
|
28 |
28 |
|
|
29 |
from django.core.cache import cache
|
|
30 |
|
29 |
31 |
import freezegun
|
30 |
32 |
import pytest
|
31 |
33 |
import xmlschema
|
... | ... | |
2326 |
2328 |
}
|
2327 |
2329 |
|
2328 |
2330 |
# test wrong and missing IDACTIVITE
|
|
2331 |
cache.clear()
|
2329 |
2332 |
content = """<PORTAIL>
|
2330 |
2333 |
<DUI>
|
2331 |
2334 |
<IDDUI>XXX</IDDUI>
|
... | ... | |
2540 |
2543 |
]
|
2541 |
2544 |
|
2542 |
2545 |
|
|
2546 |
@freezegun.freeze_time('2019-09-01')
|
2543 |
2547 |
def test_clae_booking_activity_possible_days_endpoint_axel_error(app, resource):
|
2544 |
2548 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2545 |
2549 |
with mock.patch('passerelle.contrib.toulouse_axel.models.enfants_activites') as operation:
|
2546 |
2550 |
operation.side_effect = AxelError('FooBar')
|
2547 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2551 |
resp = app.get(
|
|
2552 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2553 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2548 |
2554 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
2549 |
2555 |
assert resp.json['err'] == 'error'
|
2550 |
2556 |
|
... | ... | |
2554 |
2560 |
with mock_getdata(content, 'EnfantsActivites'):
|
2555 |
2561 |
with mock.patch('passerelle.contrib.toulouse_axel.models.reservation_periode') as operation:
|
2556 |
2562 |
operation.side_effect = AxelError('FooBar')
|
2557 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2563 |
resp = app.get(
|
|
2564 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2565 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2558 |
2566 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
2559 |
2567 |
assert resp.json['err'] == 'error'
|
2560 |
2568 |
|
2561 |
2569 |
|
|
2570 |
@freezegun.freeze_time('2019-09-01')
|
2562 |
2571 |
@pytest.mark.parametrize('value', ['foo', '20/01/2020', '2020'])
|
2563 |
2572 |
def test_clae_booking_activity_possible_days_endpoint_bad_date_format(app, resource, value):
|
2564 |
2573 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2565 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=%s&activity_type=MAT' % value, status=400)
|
|
2574 |
resp = app.get(
|
|
2575 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2576 |
'&start_date=%s&end_date=2020-01-24&activity_type=MAT' % value, status=400)
|
|
2577 |
assert resp.json['err_desc'] == "bad date format, should be YYYY-MM-DD"
|
|
2578 |
assert resp.json['err'] == 'bad-request'
|
|
2579 |
resp = app.get(
|
|
2580 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2581 |
'&start_date=2020-02-20&end_date=%s&activity_type=MAT' % value, status=400)
|
2566 |
2582 |
assert resp.json['err_desc'] == "bad date format, should be YYYY-MM-DD"
|
2567 |
2583 |
assert resp.json['err'] == 'bad-request'
|
2568 |
2584 |
|
2569 |
2585 |
|
|
2586 |
@freezegun.freeze_time('2019-09-01')
|
2570 |
2587 |
def test_clae_booking_activity_possible_days_endpoint_activity_type(app, resource):
|
2571 |
2588 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2572 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=FOO', status=400)
|
|
2589 |
resp = app.get(
|
|
2590 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2591 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=FOO', status=400)
|
2573 |
2592 |
assert resp.json['err_desc'] == "bad activity_type, should be MAT, MIDI, SOIR or GARD"
|
2574 |
2593 |
assert resp.json['err'] == 'bad-request'
|
2575 |
2594 |
|
2576 |
2595 |
|
|
2596 |
@freezegun.freeze_time('2019-09-01')
|
2577 |
2597 |
def test_clae_booking_activity_possible_days_endpoint_no_result(app, resource, child_activities_data):
|
2578 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2598 |
resp = app.get(
|
|
2599 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2600 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2579 |
2601 |
assert resp.json['err_desc'] == "Person not found"
|
2580 |
2602 |
assert resp.json['err'] == 'not-found'
|
2581 |
2603 |
|
... | ... | |
2586 |
2608 |
with mock_getdata(content, 'EnfantsActivites'):
|
2587 |
2609 |
with mock.patch('passerelle.contrib.toulouse_axel.models.reservation_periode') as operation:
|
2588 |
2610 |
operation.side_effect = AxelError('FooBar')
|
2589 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=4242&booking_date=2020-01-20&activity_type=MAT')
|
|
2611 |
resp = app.get(
|
|
2612 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=4242'
|
|
2613 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2590 |
2614 |
assert resp.json['err_desc'] == "Child not found"
|
2591 |
2615 |
assert resp.json['err'] == 'not-found'
|
2592 |
2616 |
|
... | ... | |
2606 |
2630 |
activities = child_activities_data['ENFANT'][0]
|
2607 |
2631 |
with mock_getdata(content, 'ReservationPeriode'):
|
2608 |
2632 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
2609 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2633 |
resp = app.get(
|
|
2634 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2635 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2610 |
2636 |
assert resp.json['err_desc'] == "Child not found"
|
2611 |
2637 |
assert resp.json['err'] == 'not-found'
|
2612 |
2638 |
|
2613 |
|
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.clae_booking_activities_info') as activities_info:
|
2614 |
|
activities_info.return_value = {'data': []}
|
2615 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2639 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_booking_data') as activities_info:
|
|
2640 |
activities_info.return_value = {'ACTIVITE': []}
|
|
2641 |
resp = app.get(
|
|
2642 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2643 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2616 |
2644 |
assert resp.json['err'] == 0
|
2617 |
2645 |
assert resp.json['data'] == []
|
2618 |
2646 |
|
2619 |
2647 |
|
|
2648 |
@freezegun.freeze_time('2019-09-01')
|
2620 |
2649 |
def test_clae_booking_activity_possible_days_endpoint(app, resource, child_activities_data):
|
2621 |
2650 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2622 |
2651 |
content = """<PORTAIL>
|
... | ... | |
2635 |
2664 |
activities = child_activities_data['ENFANT'][0]
|
2636 |
2665 |
with mock_getdata(content, 'ReservationPeriode'):
|
2637 |
2666 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
2638 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2667 |
resp = app.get(
|
|
2668 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2669 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2639 |
2670 |
assert resp.json['err'] == 0
|
2640 |
2671 |
assert len(resp.json['data']) == 5
|
2641 |
2672 |
assert set(resp.json['data'][0].keys()) == set(['id', 'text', 'disabled', 'prefill', 'details'])
|
2642 |
|
assert resp.json['data'][0]['id'] == '3535-MAT-A19P1M1-monday'
|
2643 |
|
assert resp.json['data'][1]['id'] == '3535-MAT-A19P1M1-tuesday'
|
2644 |
|
assert resp.json['data'][2]['id'] == '3535-MAT-A19P1M1-wednesday'
|
2645 |
|
assert resp.json['data'][3]['id'] == '3535-MAT-A19P1M1-thursday'
|
2646 |
|
assert resp.json['data'][4]['id'] == '3535-MAT-A19P1M1-friday'
|
2647 |
|
assert resp.json['data'][0]['text'] == 'Monday'
|
2648 |
|
assert resp.json['data'][1]['text'] == 'Tuesday'
|
2649 |
|
assert resp.json['data'][2]['text'] == 'Wednesday'
|
2650 |
|
assert resp.json['data'][3]['text'] == 'Thursday'
|
2651 |
|
assert resp.json['data'][4]['text'] == 'Friday'
|
|
2673 |
assert resp.json['data'][0]['id'] == '3535-MAT-A19P1M1-2020-01-20'
|
|
2674 |
assert resp.json['data'][1]['id'] == '3535-MAT-A19P1M1-2020-01-21'
|
|
2675 |
assert resp.json['data'][2]['id'] == '3535-MAT-A19P1M1-2020-01-22'
|
|
2676 |
assert resp.json['data'][3]['id'] == '3535-MAT-A19P1M1-2020-01-23'
|
|
2677 |
assert resp.json['data'][4]['id'] == '3535-MAT-A19P1M1-2020-01-24'
|
|
2678 |
assert resp.json['data'][0]['text'] == 'Monday 20 January 2020'
|
|
2679 |
assert resp.json['data'][1]['text'] == 'Tuesday 21 January 2020'
|
|
2680 |
assert resp.json['data'][2]['text'] == 'Wednesday 22 January 2020'
|
|
2681 |
assert resp.json['data'][3]['text'] == 'Thursday 23 January 2020'
|
|
2682 |
assert resp.json['data'][4]['text'] == 'Friday 24 January 2020'
|
2652 |
2683 |
assert resp.json['data'][0]['disabled'] is False
|
2653 |
2684 |
assert resp.json['data'][1]['disabled'] is False
|
2654 |
2685 |
assert resp.json['data'][2]['disabled'] is True
|
... | ... | |
2660 |
2691 |
assert resp.json['data'][3]['prefill'] is False
|
2661 |
2692 |
assert resp.json['data'][4]['prefill'] is True
|
2662 |
2693 |
|
|
2694 |
with mock_getdata(content, 'ReservationPeriode'):
|
|
2695 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
|
2696 |
resp = app.get(
|
|
2697 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2698 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2663 |
2699 |
|
|
2700 |
# again - data are in cache
|
|
2701 |
resp = app.get(
|
|
2702 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2703 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
|
2704 |
assert resp.json['err'] == 0
|
|
2705 |
assert len(resp.json['data']) == 5
|
|
2706 |
|
|
2707 |
|
|
2708 |
@pytest.mark.parametrize('today, start_date, first_date, end_date, last_date', [
|
|
2709 |
# today is start date -> + 8 days
|
|
2710 |
('2020-03-26', '2020-03-26', '2020-04-03', '2020-04-17', '2020-04-17'),
|
|
2711 |
# start date is a friday => starts friday
|
|
2712 |
('2020-03-26', '2020-04-03', '2020-04-03', '2020-04-17', '2020-04-17'),
|
|
2713 |
# start date is a saturday => starts on next monday
|
|
2714 |
('2020-03-26', '2020-04-04', '2020-04-06', '2020-04-17', '2020-04-17'),
|
|
2715 |
# start date is a sunday => starts on next monday
|
|
2716 |
('2020-03-26', '2020-04-05', '2020-04-06', '2020-04-17', '2020-04-17'),
|
|
2717 |
# start date is a monday => starts on monday
|
|
2718 |
('2020-03-26', '2020-04-06', '2020-04-06', '2020-04-17', '2020-04-17'),
|
|
2719 |
# start date is a tuesday => starts on tuesday
|
|
2720 |
('2020-03-26', '2020-04-07', '2020-04-07', '2020-04-17', '2020-04-17'),
|
|
2721 |
# end date is a not a friday => ends on friday
|
|
2722 |
('2020-03-26', '2020-04-07', '2020-04-07', '2020-04-13', '2020-04-17'),
|
|
2723 |
('2020-03-26', '2020-04-07', '2020-04-07', '2020-04-14', '2020-04-17'),
|
|
2724 |
('2020-03-26', '2020-04-07', '2020-04-07', '2020-04-15', '2020-04-17'),
|
|
2725 |
('2020-03-26', '2020-04-07', '2020-04-07', '2020-04-16', '2020-04-17'),
|
|
2726 |
# except if end date is saturday or sunday => ends on previous friday
|
|
2727 |
('2020-03-26', '2020-04-07', '2020-04-07', '2020-04-18', '2020-04-17'),
|
|
2728 |
('2020-03-26', '2020-04-07', '2020-04-07', '2020-04-19', '2020-04-17'),
|
|
2729 |
# start date is after end date, same week
|
|
2730 |
('2020-03-26', '2020-04-16', '2020-04-16', '2020-04-15', '2020-04-17'),
|
|
2731 |
# start date is after end date, not the same week => result is empty
|
|
2732 |
('2020-03-26', '2020-04-16', None, '2020-04-12', None),
|
|
2733 |
])
|
|
2734 |
def test_clae_booking_activity_possible_days_period(app, resource, child_activities_data, today, start_date, first_date, end_date, last_date):
|
|
2735 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
|
2736 |
|
|
2737 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_booking_data') as activities_info:
|
|
2738 |
activities_info.return_value = {'ACTIVITE': [{
|
|
2739 |
'id': 'TOTO',
|
|
2740 |
'booking': {'days': {'monday': True, 'tuesday': True, 'wednesday': True, 'thursday': True, 'friday': True}}
|
|
2741 |
}]}
|
|
2742 |
with freezegun.freeze_time(today):
|
|
2743 |
resp = app.get(
|
|
2744 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
|
2745 |
'&start_date=%s&end_date=%s&activity_type=MAT' % (start_date, end_date))
|
|
2746 |
if first_date is None:
|
|
2747 |
assert resp.json['data'] == []
|
|
2748 |
else:
|
|
2749 |
assert resp.json['data'][0]['id'] == '3535-MAT-TOTO-%s' % first_date
|
|
2750 |
assert resp.json['data'][-1]['id'] == '3535-MAT-TOTO-%s' % last_date
|
|
2751 |
|
|
2752 |
|
|
2753 |
@freezegun.freeze_time('2019-09-01')
|
2664 |
2754 |
def test_clae_booking_activity_prefill_endpoint_axel_error(app, resource):
|
2665 |
2755 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2666 |
2756 |
with mock.patch('passerelle.contrib.toulouse_axel.models.enfants_activites') as operation:
|
2667 |
2757 |
operation.side_effect = AxelError('FooBar')
|
2668 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2758 |
resp = app.get(
|
|
2759 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2760 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2669 |
2761 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
2670 |
2762 |
assert resp.json['err'] == 'error'
|
2671 |
2763 |
|
... | ... | |
2675 |
2767 |
with mock_getdata(content, 'EnfantsActivites'):
|
2676 |
2768 |
with mock.patch('passerelle.contrib.toulouse_axel.models.reservation_periode') as operation:
|
2677 |
2769 |
operation.side_effect = AxelError('FooBar')
|
2678 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2770 |
resp = app.get(
|
|
2771 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2772 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2679 |
2773 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
2680 |
2774 |
assert resp.json['err'] == 'error'
|
2681 |
2775 |
|
2682 |
2776 |
|
|
2777 |
@freezegun.freeze_time('2019-09-01')
|
2683 |
2778 |
@pytest.mark.parametrize('value', ['foo', '20/01/2020', '2020'])
|
2684 |
2779 |
def test_clae_booking_activity_prefill_endpoint_bad_date_format(app, resource, value):
|
2685 |
2780 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2686 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=%s&activity_type=MAT' % value, status=400)
|
|
2781 |
resp = app.get(
|
|
2782 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2783 |
'&start_date=%s&end_date=2020-01-24&activity_type=MAT' % value, status=400)
|
|
2784 |
assert resp.json['err_desc'] == "bad date format, should be YYYY-MM-DD"
|
|
2785 |
assert resp.json['err'] == 'bad-request'
|
|
2786 |
resp = app.get(
|
|
2787 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2788 |
'&start_date=2020-01-20&end_date=%s&activity_type=MAT' % value, status=400)
|
2687 |
2789 |
assert resp.json['err_desc'] == "bad date format, should be YYYY-MM-DD"
|
2688 |
2790 |
assert resp.json['err'] == 'bad-request'
|
2689 |
2791 |
|
2690 |
2792 |
|
|
2793 |
@freezegun.freeze_time('2019-09-01')
|
2691 |
2794 |
def test_clae_booking_activity_prefill_endpoint_activity_type(app, resource):
|
2692 |
2795 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2693 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=FOO', status=400)
|
|
2796 |
resp = app.get(
|
|
2797 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2798 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=FOO', status=400)
|
2694 |
2799 |
assert resp.json['err_desc'] == "bad activity_type, should be MAT, MIDI, SOIR or GARD"
|
2695 |
2800 |
assert resp.json['err'] == 'bad-request'
|
2696 |
2801 |
|
2697 |
2802 |
|
|
2803 |
@freezegun.freeze_time('2019-09-01')
|
2698 |
2804 |
def test_clae_booking_activity_prefill_endpoint_no_result(app, resource, child_activities_data):
|
2699 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2805 |
resp = app.get(
|
|
2806 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2807 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2700 |
2808 |
assert resp.json['err_desc'] == "Person not found"
|
2701 |
2809 |
assert resp.json['err'] == 'not-found'
|
2702 |
2810 |
|
... | ... | |
2707 |
2815 |
with mock_getdata(content, 'EnfantsActivites'):
|
2708 |
2816 |
with mock.patch('passerelle.contrib.toulouse_axel.models.reservation_periode') as operation:
|
2709 |
2817 |
operation.side_effect = AxelError('FooBar')
|
2710 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=4242&booking_date=2020-01-20&activity_type=MAT')
|
|
2818 |
resp = app.get(
|
|
2819 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=4242'
|
|
2820 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2711 |
2821 |
assert resp.json['err_desc'] == "Child not found"
|
2712 |
2822 |
assert resp.json['err'] == 'not-found'
|
2713 |
2823 |
|
... | ... | |
2727 |
2837 |
activities = child_activities_data['ENFANT'][0]
|
2728 |
2838 |
with mock_getdata(content, 'ReservationPeriode'):
|
2729 |
2839 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
2730 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2840 |
resp = app.get(
|
|
2841 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2842 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2731 |
2843 |
assert resp.json['err_desc'] == "Child not found"
|
2732 |
2844 |
assert resp.json['err'] == 'not-found'
|
2733 |
2845 |
|
2734 |
2846 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.clae_booking_activity_possible_days') as possible_days:
|
2735 |
2847 |
possible_days.return_value = {'data': []}
|
2736 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2848 |
resp = app.get(
|
|
2849 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2850 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2737 |
2851 |
assert resp.json['err'] == 0
|
2738 |
2852 |
assert resp.json['data'] == []
|
2739 |
2853 |
|
2740 |
2854 |
|
2741 |
|
def test_clae_booking_activity_prefill_endpoint(app, resource, child_activities_data):
|
|
2855 |
def test_clae_booking_activity_prefill_endpoint(app, resource):
|
2742 |
2856 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2743 |
2857 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.clae_booking_activity_possible_days') as possible_days:
|
2744 |
2858 |
possible_days.return_value = {
|
2745 |
2859 |
'data': [
|
2746 |
2860 |
{
|
2747 |
|
'id': '3535-MAT-A19P1M1-monday',
|
|
2861 |
'id': '3535-MAT-A19P1M1-2020-01-20',
|
2748 |
2862 |
'prefill': True,
|
2749 |
2863 |
},
|
2750 |
2864 |
{
|
2751 |
|
'id': '3535-MAT-A19P1M1-tuesday',
|
|
2865 |
'id': '3535-MAT-A19P1M1-2020-01-21',
|
2752 |
2866 |
'prefill': False,
|
2753 |
2867 |
},
|
2754 |
2868 |
{
|
2755 |
|
'id': '3535-MAT-A19P1M1-wednesday',
|
|
2869 |
'id': '3535-MAT-A19P1M1-2020-01-22',
|
2756 |
2870 |
'prefill': None,
|
2757 |
2871 |
},
|
2758 |
2872 |
{
|
2759 |
|
'id': '3535-MAT-A19P1M1-thursday',
|
|
2873 |
'id': '3535-MAT-A19P1M1-2020-01-23',
|
2760 |
2874 |
'prefill': False,
|
2761 |
2875 |
},
|
2762 |
2876 |
{
|
2763 |
|
'id': '3535-MAT-A19P1M1-friday',
|
|
2877 |
'id': '3535-MAT-A19P1M1-2020-01-24',
|
2764 |
2878 |
'prefill': True,
|
2765 |
2879 |
},
|
2766 |
2880 |
]
|
2767 |
2881 |
}
|
2768 |
|
resp = app.get('/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535&booking_date=2020-01-20&activity_type=MAT')
|
|
2882 |
resp = app.get(
|
|
2883 |
'/toulouse-axel/test/clae_booking_activity_prefill?NameID=yyy&idpersonne=3535'
|
|
2884 |
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2769 |
2885 |
assert resp.json['err'] == 0
|
2770 |
|
assert resp.json['data'] == ['3535-MAT-A19P1M1-monday', '3535-MAT-A19P1M1-friday']
|
|
2886 |
assert resp.json['data'] == ['3535-MAT-A19P1M1-2020-01-20', '3535-MAT-A19P1M1-2020-01-24']
|
2771 |
2887 |
|
2772 |
2888 |
|
2773 |
2889 |
def test_are_children_registered_axel_error(resource):
|
2774 |
|
-
|