0001-caluire-axel-hide-closed-days-55743.patch
passerelle/contrib/caluire_axel/models.py | ||
---|---|---|
617 | 617 |
activity_type = self.get_activity_type(activity_id) |
618 | 618 |
days = result.json_response['DATA']['PORTAIL']['GETAGENDA'].get('JOUR', []) |
619 | 619 |
for day in days: |
620 |
if day.get('FERME'): |
|
621 |
# hide closed days |
|
622 |
continue |
|
620 | 623 |
day_date = datetime.datetime.strptime(day['JOURDATE'], axel.json_date_format).date() |
621 | 624 |
if day_date.weekday() == 2 and ignore_wednesday: |
622 | 625 |
continue |
tests/test_caluire_axel.py | ||
---|---|---|
1101 | 1101 |
] |
1102 | 1102 | |
1103 | 1103 | |
1104 |
@pytest.mark.parametrize( |
|
1105 |
'value, ignored', |
|
1106 |
[ |
|
1107 |
('O', True), |
|
1108 |
('N', False), |
|
1109 |
], |
|
1110 |
) |
|
1111 |
def test_get_agenda_endpoint_closed(app, resource, family_data, activities, value, ignored): |
|
1112 |
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42') |
|
1113 |
content = ( |
|
1114 |
'''<PORTAIL> |
|
1115 |
<GETAGENDA> |
|
1116 |
<CODE>1</CODE> |
|
1117 |
<JOUR> |
|
1118 |
<JOURDATE>30/10/2020</JOURDATE> |
|
1119 |
<MATIN>.</MATIN> |
|
1120 |
<MIDI></MIDI> |
|
1121 |
<APRESMIDI></APRESMIDI> |
|
1122 |
<FERME>%s</FERME> |
|
1123 |
</JOUR> |
|
1124 |
</GETAGENDA> |
|
1125 |
</PORTAIL>''' |
|
1126 |
% value |
|
1127 |
) |
|
1128 |
with mock_data(content, 'GetAgenda'): |
|
1129 |
with mock.patch( |
|
1130 |
'passerelle.contrib.caluire_axel.models.CaluireAxel.get_family_data', |
|
1131 |
return_value=family_data, |
|
1132 |
): |
|
1133 |
with mock.patch( |
|
1134 |
'passerelle.contrib.caluire_axel.models.CaluireAxel.get_child_activities', |
|
1135 |
return_value=activities, |
|
1136 |
): |
|
1137 |
resp = app.get( |
|
1138 |
'/caluire-axel/test/get_agenda?NameID=yyy&idpersonne=50632&activity_id=ELEM&start_date=2020-09-01&end_date=2021-08-31' |
|
1139 |
) |
|
1140 |
if ignored: |
|
1141 |
assert len(resp.json['data']) == 0 |
|
1142 |
else: |
|
1143 |
assert resp.json['data'][0] |
|
1144 | ||
1145 | ||
1104 | 1146 |
@pytest.mark.parametrize( |
1105 | 1147 |
'value, expected', |
1106 | 1148 |
[ |
1107 |
- |