2615 |
2615 |
assert resp.json['data'][3]['prefill'] is False
|
2616 |
2616 |
assert resp.json['data'][4]['prefill'] is True
|
2617 |
2617 |
|
2618 |
|
with mock_getdata(content, 'ReservationPeriode'):
|
2619 |
|
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
2620 |
|
resp = app.get(
|
2621 |
|
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
2622 |
|
'&start_date=2020-01-20&end_date=2020-01-24&activity_type=MAT')
|
2623 |
|
|
2624 |
2618 |
# again - data are in cache
|
2625 |
2619 |
resp = app.get(
|
2626 |
2620 |
'/toulouse-axel/test/clae_booking_activity_possible_days?NameID=yyy&idpersonne=3535'
|
... | ... | |
2674 |
2668 |
assert resp.json['data'][-1]['id'] == '3535:MAT:TOTO:%s' % last_date
|
2675 |
2669 |
|
2676 |
2670 |
|
|
2671 |
@freezegun.freeze_time('2019-09-01')
|
|
2672 |
def test_clae_booking_activity_annual_possible_days_endpoint_axel_error(app, resource):
|
|
2673 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
|
2674 |
with mock.patch('passerelle.contrib.toulouse_axel.schemas.enfants_activites') as operation:
|
|
2675 |
operation.side_effect = AxelError('FooBar')
|
|
2676 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=MAT')
|
|
2677 |
assert resp.json['err_desc'] == "Axel error: FooBar"
|
|
2678 |
assert resp.json['err'] == 'error'
|
|
2679 |
|
|
2680 |
|
|
2681 |
@freezegun.freeze_time('2019-09-01')
|
|
2682 |
def test_clae_booking_activity_annual_possible_days_endpoint_activity_type(app, resource):
|
|
2683 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
|
2684 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=FOO', status=400)
|
|
2685 |
assert resp.json['err_desc'] == "bad activity_type, should be MAT, MIDI, SOIR or GARD"
|
|
2686 |
assert resp.json['err'] == 'bad-request'
|
|
2687 |
|
|
2688 |
|
|
2689 |
@freezegun.freeze_time('2019-09-01')
|
|
2690 |
def test_clae_booking_activity_annual_possible_days_endpoint_no_result(app, resource):
|
|
2691 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=MAT')
|
|
2692 |
assert resp.json['err_desc'] == "Person not found"
|
|
2693 |
assert resp.json['err'] == 'not-found'
|
|
2694 |
|
|
2695 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
|
2696 |
filepath = os.path.join(os.path.dirname(__file__), 'data/toulouse_axel/child_activities.xml')
|
|
2697 |
with open(filepath) as xml:
|
|
2698 |
content = xml.read()
|
|
2699 |
with mock_getdata(content, 'EnfantsActivites'):
|
|
2700 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=4242&activity_type=MAT')
|
|
2701 |
assert resp.json['err_desc'] == "Child not found"
|
|
2702 |
assert resp.json['err'] == 'not-found'
|
|
2703 |
|
|
2704 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value={'ACTIVITE': []}):
|
|
2705 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=MAT')
|
|
2706 |
assert resp.json['err'] == 0
|
|
2707 |
assert resp.json['data'] == []
|
|
2708 |
|
|
2709 |
|
|
2710 |
@freezegun.freeze_time('2019-09-01')
|
|
2711 |
def test_clae_booking_activity_annual_possible_days_endpoint(app, resource, child_activities_data):
|
|
2712 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
|
2713 |
activities = {'ACTIVITE': [child_activities_data['ENFANT'][0]['ACTIVITE'][0]]}
|
|
2714 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
|
2715 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=MAT')
|
|
2716 |
assert resp.json['err'] == 0
|
|
2717 |
assert resp.json['data'] == [
|
|
2718 |
{
|
|
2719 |
'id': '3535:MAT:A19P1M1:monday',
|
|
2720 |
'text': 'Monday',
|
|
2721 |
'disabled': False,
|
|
2722 |
},
|
|
2723 |
{
|
|
2724 |
'id': '3535:MAT:A19P1M1:tuesday',
|
|
2725 |
'text': 'Tuesday',
|
|
2726 |
'disabled': False,
|
|
2727 |
},
|
|
2728 |
{
|
|
2729 |
'id': '3535:MAT:A19P1M1:wednesday',
|
|
2730 |
'text': 'Wednesday',
|
|
2731 |
'disabled': False,
|
|
2732 |
},
|
|
2733 |
{
|
|
2734 |
'id': '3535:MAT:A19P1M1:thursday',
|
|
2735 |
'text': 'Thursday',
|
|
2736 |
'disabled': False,
|
|
2737 |
},
|
|
2738 |
{
|
|
2739 |
'id': '3535:MAT:A19P1M1:friday',
|
|
2740 |
'text': 'Friday',
|
|
2741 |
'disabled': False,
|
|
2742 |
},
|
|
2743 |
]
|
|
2744 |
activities = {'ACTIVITE': [child_activities_data['ENFANT'][0]['ACTIVITE'][1]]}
|
|
2745 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
|
2746 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=MIDI')
|
|
2747 |
assert resp.json['err'] == 0
|
|
2748 |
assert resp.json['data'] == [
|
|
2749 |
{
|
|
2750 |
'id': '3535:MIDI:A19P1M2:monday',
|
|
2751 |
'text': 'Monday',
|
|
2752 |
'disabled': False,
|
|
2753 |
},
|
|
2754 |
{
|
|
2755 |
'id': '3535:MIDI:A19P1M2:tuesday',
|
|
2756 |
'text': 'Tuesday',
|
|
2757 |
'disabled': False,
|
|
2758 |
},
|
|
2759 |
{
|
|
2760 |
'id': '3535:MIDI:A19P1M2:wednesday',
|
|
2761 |
'text': 'Wednesday',
|
|
2762 |
'disabled': False,
|
|
2763 |
},
|
|
2764 |
{
|
|
2765 |
'id': '3535:MIDI:A19P1M2:thursday',
|
|
2766 |
'text': 'Thursday',
|
|
2767 |
'disabled': False,
|
|
2768 |
},
|
|
2769 |
{
|
|
2770 |
'id': '3535:MIDI:A19P1M2:friday',
|
|
2771 |
'text': 'Friday',
|
|
2772 |
'disabled': False,
|
|
2773 |
},
|
|
2774 |
]
|
|
2775 |
activities = {'ACTIVITE': [child_activities_data['ENFANT'][0]['ACTIVITE'][2]]}
|
|
2776 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
|
2777 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=SOIR')
|
|
2778 |
assert resp.json['err'] == 0
|
|
2779 |
assert resp.json['data'] == [
|
|
2780 |
{
|
|
2781 |
'id': '3535:SOIR:A19P1M3:monday',
|
|
2782 |
'text': 'Monday',
|
|
2783 |
'disabled': False,
|
|
2784 |
},
|
|
2785 |
{
|
|
2786 |
'id': '3535:SOIR:A19P1M3:tuesday',
|
|
2787 |
'text': 'Tuesday',
|
|
2788 |
'disabled': False,
|
|
2789 |
},
|
|
2790 |
{
|
|
2791 |
'id': '3535:SOIR:A19P1M3:wednesday',
|
|
2792 |
'text': 'Wednesday',
|
|
2793 |
'disabled': True,
|
|
2794 |
},
|
|
2795 |
{
|
|
2796 |
'id': '3535:SOIR:A19P1M3:thursday',
|
|
2797 |
'text': 'Thursday',
|
|
2798 |
'disabled': False,
|
|
2799 |
},
|
|
2800 |
{
|
|
2801 |
'id': '3535:SOIR:A19P1M3:friday',
|
|
2802 |
'text': 'Friday',
|
|
2803 |
'disabled': False,
|
|
2804 |
},
|
|
2805 |
]
|
|
2806 |
activities = {'ACTIVITE': [child_activities_data['ENFANT'][0]['ACTIVITE'][3]]}
|
|
2807 |
with mock.patch('passerelle.contrib.toulouse_axel.models.ToulouseAxel.get_child_activities', return_value=activities):
|
|
2808 |
resp = app.get('/toulouse-axel/test/clae_booking_activity_annual_possible_days?NameID=yyy&idpersonne=3535&activity_type=GARD')
|
|
2809 |
assert resp.json['err'] == 0
|
|
2810 |
assert resp.json['data'] == [
|
|
2811 |
{
|
|
2812 |
'id': '3535:GARD:A19P1M4:monday',
|
|
2813 |
'text': 'Monday',
|
|
2814 |
'disabled': True,
|
|
2815 |
},
|
|
2816 |
{
|
|
2817 |
'id': '3535:GARD:A19P1M4:tuesday',
|
|
2818 |
'text': 'Tuesday',
|
|
2819 |
'disabled': True,
|
|
2820 |
},
|
|
2821 |
{
|
|
2822 |
'id': '3535:GARD:A19P1M4:wednesday',
|
|
2823 |
'text': 'Wednesday',
|
|
2824 |
'disabled': False,
|
|
2825 |
},
|
|
2826 |
{
|
|
2827 |
'id': '3535:GARD:A19P1M4:thursday',
|
|
2828 |
'text': 'Thursday',
|
|
2829 |
'disabled': True,
|
|
2830 |
},
|
|
2831 |
{
|
|
2832 |
'id': '3535:GARD:A19P1M4:friday',
|
|
2833 |
'text': 'Friday',
|
|
2834 |
'disabled': True,
|
|
2835 |
},
|
|
2836 |
]
|
|
2837 |
|
|
2838 |
|
2677 |
2839 |
@freezegun.freeze_time('2019-09-01')
|
2678 |
2840 |
def test_clae_booking_activity_prefill_endpoint_axel_error(app, resource):
|
2679 |
2841 |
Link.objects.create(resource=resource, name_id='yyy', dui='XXX', person_id='42')
|
2680 |
|
-
|