diff --git a/tests/test_api.py b/tests/test_api.py index 2fe575d9..c7169ae6 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -440,29 +440,37 @@ def test_datetimes_api(app, some_data): assert resp.json['data'][0]['description'] -def test_datetimes_api_wrong_kind(app, some_data): - agenda = Agenda.objects.filter(label=u'Foo bar')[0] - agenda.kind = 'meetings' - agenda.save() - resp = app.get('/api/agenda/%s/datetimes/' % agenda.id, status=404) +def test_datetimes_api_wrong_kind(app): + agenda = Agenda.objects.create(label='Foo bar', kind='meetings') + app.get('/api/agenda/%s/datetimes/' % agenda.slug, status=404) -def test_datetime_api_fr(app, some_data): - agenda_id = Agenda.objects.filter(label=u'Foo bar')[0].id +def test_datetime_api_fr(app): + agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0) + Event.objects.create( + slug='event-slug', + start_datetime=localtime((now() + datetime.timedelta(days=5))).replace(hour=17, minute=0), + places=5, + agenda=agenda, + ) with override_settings(LANGUAGE_CODE='fr-fr'): - resp = app.get('/api/agenda/%s/datetimes/' % agenda_id) + resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug) # no seconds, hh:mm in 24-hour formats assert resp.json['data'][0]['text'].endswith(' 17:00') assert resp.json['data'][0]['datetime'].endswith(' 17:00:00') assert 'data' in resp.json -def test_datetime_api_label(app, some_data): - agenda_id = Agenda.objects.filter(label=u'Foo bar 2')[0].id - event = Event.objects.filter(agenda=agenda_id)[0] - event.label = 'Hello world' - event.save() - resp = app.get('/api/agenda/%s/datetimes/' % agenda_id) +def test_datetime_api_label(app): + agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0) + Event.objects.create( + label='Hello world', + slug='event-slug', + start_datetime=(now() + datetime.timedelta(days=1)), + places=5, + agenda=agenda, + ) + resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug) assert 'Hello world' in [x['text'] for x in resp.json['data']]