From 742c1b15a5e4d212d18aaf1bcbebc3e08db0216e Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 29 Jun 2022 17:13:46 +0200 Subject: [PATCH 1/2] agendas: add date start field to shared custody agenda (#66330) --- .../0134_sharedcustodyagenda_date_start.py | 20 +++++++ chrono/agendas/models.py | 1 + chrono/api/serializers.py | 5 +- .../datetimes/test_events_multiple_agendas.py | 20 +++++-- tests/api/datetimes/test_recurring_events.py | 8 ++- .../fillslot/test_events_multiple_agendas.py | 4 +- tests/api/fillslot/test_recurring_events.py | 8 ++- tests/api/test_shared_custody.py | 10 +++- tests/manager/test_shared_custody_agenda.py | 29 +++++++--- tests/test_agendas.py | 56 ++++++++++++++----- 10 files changed, 127 insertions(+), 34 deletions(-) create mode 100644 chrono/agendas/migrations/0134_sharedcustodyagenda_date_start.py diff --git a/chrono/agendas/migrations/0134_sharedcustodyagenda_date_start.py b/chrono/agendas/migrations/0134_sharedcustodyagenda_date_start.py new file mode 100644 index 00000000..70a198d3 --- /dev/null +++ b/chrono/agendas/migrations/0134_sharedcustodyagenda_date_start.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.26 on 2022-06-29 13:14 + +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agendas', '0133_auto_20220628_1600'), + ] + + operations = [ + migrations.AddField( + model_name='sharedcustodyagenda', + name='date_start', + field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Start'), + preserve_default=False, + ), + ] diff --git a/chrono/agendas/models.py b/chrono/agendas/models.py index bd0f9827..1427534d 100644 --- a/chrono/agendas/models.py +++ b/chrono/agendas/models.py @@ -3210,6 +3210,7 @@ class SharedCustodyAgenda(models.Model): Person, verbose_name=_('Second guardian'), on_delete=models.CASCADE, related_name='+' ) children = models.ManyToManyField(Person, related_name='agendas') + date_start = models.DateTimeField(_('Start')) @property def label(self): diff --git a/chrono/api/serializers.py b/chrono/api/serializers.py index 1bdc862c..62cb5338 100644 --- a/chrono/api/serializers.py +++ b/chrono/api/serializers.py @@ -593,6 +593,9 @@ class SharedCustodyAgendaSerializer(serializers.Serializer): other_guardian_id = serializers.CharField(max_length=250) children = PersonSerializer(many=True) weeks = serializers.ChoiceField(required=False, choices=['', 'even', 'odd']) + date_start = serializers.DateTimeField( + required=True, input_formats=['iso-8601', '%Y-%m-%d'] + ) # input_formats default pas ok ? settings_url = serializers.SerializerMethodField() @@ -651,7 +654,7 @@ class SharedCustodyAgendaSerializer(serializers.Serializer): ) self.agenda = SharedCustodyAgenda.objects.create( - first_guardian=guardian, second_guardian=other_guardian + first_guardian=guardian, second_guardian=other_guardian, date_start=validated_data['date_start'] ) children = [] diff --git a/tests/api/datetimes/test_events_multiple_agendas.py b/tests/api/datetimes/test_events_multiple_agendas.py index 8cffabd1..5603af98 100644 --- a/tests/api/datetimes/test_events_multiple_agendas.py +++ b/tests/api/datetimes/test_events_multiple_agendas.py @@ -420,7 +420,9 @@ def test_datetimes_multiple_agendas_queries(app): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='xxx', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() - datetime.timedelta(days=5) + ) agenda.children.add(child) SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=list(range(7)), weeks='even') @@ -723,7 +725,9 @@ def test_datetimes_multiple_agendas_shared_custody(app): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) father_rule = SharedCustodyRule.objects.create( @@ -848,7 +852,9 @@ def test_datetimes_multiple_agendas_shared_custody_other_rules(app): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) father_rule = SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=[0, 1, 2]) @@ -937,7 +943,9 @@ def test_datetimes_multiple_agendas_shared_custody_recurring_event(app): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) father_rule = SharedCustodyRule.objects.create( @@ -1140,7 +1148,9 @@ def test_datetimes_multiple_agendas_shared_custody_holiday_rules(app): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) SharedCustodyRule.objects.create(agenda=agenda, days=list(range(7)), weeks='even', guardian=father) diff --git a/tests/api/datetimes/test_recurring_events.py b/tests/api/datetimes/test_recurring_events.py index 9be6c1fa..77a73fbe 100644 --- a/tests/api/datetimes/test_recurring_events.py +++ b/tests/api/datetimes/test_recurring_events.py @@ -145,7 +145,9 @@ def test_recurring_events_api_list_shared_custody(app): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe') - custody_agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + custody_agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) custody_agenda.children.add(child) SharedCustodyRule.objects.create(agenda=custody_agenda, guardian=father, days=[0], weeks='even') @@ -330,7 +332,9 @@ def test_recurring_events_api_list_multiple_agendas_queries(app): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='xxx', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=list(range(7)), weeks='even') diff --git a/tests/api/fillslot/test_events_multiple_agendas.py b/tests/api/fillslot/test_events_multiple_agendas.py index 65df798e..2eb8c862 100644 --- a/tests/api/fillslot/test_events_multiple_agendas.py +++ b/tests/api/fillslot/test_events_multiple_agendas.py @@ -602,7 +602,9 @@ def test_api_events_fillslots_multiple_agendas_shared_custody(app, user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=[0, 1, 2]) diff --git a/tests/api/fillslot/test_recurring_events.py b/tests/api/fillslot/test_recurring_events.py index 1e6f522f..d767d55f 100644 --- a/tests/api/fillslot/test_recurring_events.py +++ b/tests/api/fillslot/test_recurring_events.py @@ -1297,7 +1297,9 @@ def test_recurring_events_api_fillslots_multiple_agendas_queries(app, user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='xxx', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=list(range(7)), weeks='even') @@ -1331,7 +1333,9 @@ def test_recurring_events_api_fillslots_shared_custody(app, user, freezer): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) agenda.children.add(child) SharedCustodyRule.objects.create(agenda=agenda, guardian=father, weeks='odd', days=[0, 1, 2]) diff --git a/tests/api/test_shared_custody.py b/tests/api/test_shared_custody.py index 54e548b7..145544c3 100644 --- a/tests/api/test_shared_custody.py +++ b/tests/api/test_shared_custody.py @@ -1,5 +1,6 @@ import pytest from django.core.files.base import ContentFile +from django.utils.timezone import now from chrono.agendas.models import Person, SharedCustodyAgenda, SharedCustodySettings, UnavailabilityCalendar @@ -32,6 +33,7 @@ def test_add_shared_custody_agenda(app, user, settings): 'user_external_id': '123', }, ], + 'date_start': '2020-10-20', } resp = app.post_json('/api/shared-custody/', params=params) @@ -65,6 +67,7 @@ def test_add_shared_custody_agenda(app, user, settings): 'user_external_id': 'bruce', }, ], + 'date_start': '2020-10-20', } resp = app.post_json('/api/shared-custody/', params=params) assert resp.json['data']['id'] != agenda.pk @@ -96,6 +99,7 @@ def test_add_shared_custody_agenda_with_rules(app, user, settings): 'user_external_id': 'zzz', }, ], + 'date_start': '2020-10-20', } resp = app.post_json('/api/shared-custody/', params={'weeks': '', **params}) @@ -194,7 +198,9 @@ def test_add_shared_custody_agenda_with_rules(app, user, settings): def test_shared_custody_agenda_add_child(app, user, settings): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) app.authorization = ('Basic', ('john.doe', 'password')) params = { @@ -236,7 +242,7 @@ def test_shared_custody_agenda_add_child(app, user, settings): user_external_id='other_mother_id', first_name='Jane', last_name='Doe' ) other_agenda = SharedCustodyAgenda.objects.create( - first_guardian=other_father, second_guardian=other_mother + first_guardian=other_father, second_guardian=other_mother, date_start=now() ) resp = app.post_json('/api/shared-custody/%s/add-child/' % other_agenda.pk, params=params) diff --git a/tests/manager/test_shared_custody_agenda.py b/tests/manager/test_shared_custody_agenda.py index 576798b8..824e4a2c 100644 --- a/tests/manager/test_shared_custody_agenda.py +++ b/tests/manager/test_shared_custody_agenda.py @@ -4,6 +4,7 @@ import pytest from django.core.files.base import ContentFile from django.db import connection from django.test.utils import CaptureQueriesContext +from django.utils.timezone import now from chrono.agendas.models import ( Person, @@ -28,7 +29,9 @@ with open('tests/data/holidays.ics') as f: def test_shared_custody_agenda_settings_rules(app, admin_user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) app = login(app) resp = app.get('/manage/shared-custody/%s/' % agenda.pk).follow() @@ -77,7 +80,9 @@ def test_shared_custody_agenda_settings_rules(app, admin_user): def test_shared_custody_agenda_settings_periods(app, admin_user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) app = login(app) resp = app.get('/manage/shared-custody/%s/settings/' % agenda.pk) @@ -118,7 +123,9 @@ def test_shared_custody_agenda_settings_periods(app, admin_user): def test_shared_custody_agenda_month_view(app, admin_user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=list(range(7)), weeks='even') app = login(app) @@ -174,7 +181,9 @@ def test_shared_custody_agenda_month_view(app, admin_user): def test_shared_custody_agenda_month_view_queries(app, admin_user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=[0, 1, 2], weeks='even') SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=[3, 4, 5, 6], weeks='odd') SharedCustodyRule.objects.create(agenda=agenda, guardian=mother, days=[0, 1, 2], weeks='odd') @@ -211,7 +220,9 @@ def test_shared_custody_agenda_month_view_queries(app, admin_user): def test_shared_custody_agenda_holiday_rules(app, admin_user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) app = login(app) resp = app.get('/manage/shared-custody/%s/settings/' % agenda.pk) @@ -311,7 +322,9 @@ def test_shared_custody_settings_feature_flag(app, admin_user, settings): def test_shared_custody_settings_management_role(app, admin_user, manager_user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) app = login(app, username='manager', password='manager') app.get('/manage/shared-custody/%s/settings/' % agenda.pk, status=403) @@ -332,7 +345,9 @@ def test_shared_custody_settings_management_role(app, admin_user, manager_user): def test_shared_custody_agenda_delete(app, admin_user, manager_user): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) SharedCustodySettings.objects.create(management_role=manager_user.groups.all()[0]) app = login(app, username='manager', password='manager') diff --git a/tests/test_agendas.py b/tests/test_agendas.py index 570140d4..e009fa40 100644 --- a/tests/test_agendas.py +++ b/tests/test_agendas.py @@ -2770,7 +2770,9 @@ def test_recurring_events_create_past_recurrences(freezer): def test_shared_custody_agenda(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) SharedCustodyRule.objects.create(agenda=agenda, days=list(range(7)), weeks='even', guardian=father) SharedCustodyRule.objects.create(agenda=agenda, days=list(range(7)), weeks='odd', guardian=mother) @@ -2826,7 +2828,9 @@ def test_shared_custody_agenda(): def test_shared_custody_agenda_different_periodicity(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) SharedCustodyRule.objects.create(agenda=agenda, days=[1, 2, 3], guardian=father) SharedCustodyRule.objects.create(agenda=agenda, days=[0, 4, 5, 6], guardian=mother) @@ -2875,7 +2879,9 @@ def test_shared_custody_agenda_different_periodicity(): def test_shared_custody_agenda_is_complete(rules, complete): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) for i, rule in enumerate(rules): guardian = father if i % 2 else mother @@ -2905,7 +2911,9 @@ def test_shared_custody_agenda_is_complete(rules, complete): def test_shared_custody_agenda_rule_overlaps(rules, days, weeks, overlaps): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) for i, rule in enumerate(rules): guardian = father if i % 2 else mother @@ -2919,7 +2927,9 @@ def test_shared_custody_agenda_holiday_rule_overlaps(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) summer_holiday = TimePeriodExceptionGroup.objects.create( unavailability_calendar=calendar, label='Summer', slug='summer' @@ -2989,7 +2999,9 @@ def test_shared_custody_agenda_holiday_rule_overlaps(): def test_shared_custody_agenda_period_overlaps(periods, date_start, date_end, overlaps): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) for i, dates in enumerate(periods): guardian = father if i % 2 else mother @@ -3005,7 +3017,9 @@ def test_shared_custody_agenda_period_holiday_rule_no_overlaps(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) summer_holiday = TimePeriodExceptionGroup.objects.create( unavailability_calendar=calendar, label='Summer', slug='summer' @@ -3022,7 +3036,9 @@ def test_shared_custody_agenda_period_holiday_rule_no_overlaps(): def test_shared_custody_agenda_rule_label(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) rule = SharedCustodyRule.objects.create(agenda=agenda, guardian=father, days=list(range(7))) assert rule.label == 'daily' @@ -3054,7 +3070,9 @@ def test_shared_custody_agenda_holiday_rule_label(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) summer_holiday = TimePeriodExceptionGroup.objects.create( unavailability_calendar=calendar, label='Summer Holidays', slug='summer' @@ -3092,7 +3110,9 @@ def test_shared_custody_agenda_holiday_rule_label(): def test_shared_custody_agenda_period_label(freezer): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) period = SharedCustodyPeriod.objects.create( agenda=agenda, @@ -3112,7 +3132,9 @@ def test_shared_custody_agenda_holiday_rule_create_periods(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) summer_holiday = TimePeriodExceptionGroup.objects.create( unavailability_calendar=calendar, label='Summer', slug='summer' @@ -3215,7 +3237,9 @@ def test_shared_custody_agenda_holiday_rule_create_periods_christmas_holidays(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) christmas_holiday = TimePeriodExceptionGroup.objects.create( unavailability_calendar=calendar, label='Christmas', slug='christmas' @@ -3275,7 +3299,9 @@ def test_shared_custody_agenda_holiday_rules_application(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) christmas_holiday = TimePeriodExceptionGroup.objects.create( unavailability_calendar=calendar, label='Christmas', slug='christmas' @@ -3322,7 +3348,9 @@ def test_shared_custody_agenda_update_holiday_rules_command(): father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe') mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe') - agenda = SharedCustodyAgenda.objects.create(first_guardian=father, second_guardian=mother) + agenda = SharedCustodyAgenda.objects.create( + first_guardian=father, second_guardian=mother, date_start=now() + ) christmas_holiday = TimePeriodExceptionGroup.objects.create( unavailability_calendar=calendar, label='Christmas', slug='christmas' -- 2.30.2