toulouse-maelis: add global catalog as referential (#73730)

This commit is contained in:
Nicolas Roche 2023-01-23 15:08:51 +01:00
parent c3b25da743
commit 0be7e95b74
3 changed files with 27039 additions and 0 deletions

View File

@ -167,6 +167,26 @@ class ToulouseMaelis(BaseResource, HTTPResource):
data = self.get_referential_data('Activity', referential_name)
self.update_referential(referential_name, data, id_key, text_key)
# put activity catalog per year as referential
data = []
reference_year = utils.get_reference_year_from_date(datetime.date.today())
for year in range(reference_year, reference_year + 1):
response = self.call(
'Activity',
'readActivityList',
schoolyear=year,
dateStartCalend='%s-09-01' % year,
dateEndCalend='%s-09-01' % (year + 1),
)
data.append(
{
'id': str(year),
'text': '%s-%s' % (year, year + 1),
'data': serialize_object(response),
}
)
self.update_referential('ActivityCatalog', data, 'id', 'text')
def daily(self):
try:
self.update_family_referentials()

File diff suppressed because it is too large Load Diff

View File

@ -167,6 +167,7 @@ def django_db_setup(django_db_setup, django_db_blocker):
activity_mock.add_soap_response(
'readActivityNatureTypeList', get_xml_file('R_read_activity_nature_type_list.xml')
)
activity_mock.add_soap_response('readActivityList', get_xml_file('R_read_activity_list.xml'))
con.update_activity_referentials()
# reset change in zeep private interface to bypass clear_cache fixture
@ -322,6 +323,7 @@ def test_update_referential(mocked_get, con):
def test_cron(db):
assert Referential.objects.filter(referential_name='Category').count() == 3
assert sorted(list({x.referential_name for x in Referential.objects.all()})) == [
'ActivityCatalog',
'ActivityNatureType',
'CSP',
'Category',