440 |
440 |
assert resp.json['data'][0]['description']
|
441 |
441 |
|
442 |
442 |
|
443 |
|
def test_datetimes_api_wrong_kind(app, some_data):
|
444 |
|
agenda = Agenda.objects.filter(label=u'Foo bar')[0]
|
445 |
|
agenda.kind = 'meetings'
|
446 |
|
agenda.save()
|
447 |
|
resp = app.get('/api/agenda/%s/datetimes/' % agenda.id, status=404)
|
|
443 |
def test_datetimes_api_wrong_kind(app):
|
|
444 |
agenda = Agenda.objects.create(label='Foo bar', kind='meetings')
|
|
445 |
app.get('/api/agenda/%s/datetimes/' % agenda.slug, status=404)
|
448 |
446 |
|
449 |
447 |
|
450 |
|
def test_datetime_api_fr(app, some_data):
|
451 |
|
agenda_id = Agenda.objects.filter(label=u'Foo bar')[0].id
|
|
448 |
def test_datetime_api_fr(app):
|
|
449 |
agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0)
|
|
450 |
Event.objects.create(
|
|
451 |
slug='event-slug',
|
|
452 |
start_datetime=localtime((now() + datetime.timedelta(days=5))).replace(hour=17, minute=0),
|
|
453 |
places=5,
|
|
454 |
agenda=agenda,
|
|
455 |
)
|
452 |
456 |
with override_settings(LANGUAGE_CODE='fr-fr'):
|
453 |
|
resp = app.get('/api/agenda/%s/datetimes/' % agenda_id)
|
|
457 |
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
|
454 |
458 |
# no seconds, hh:mm in 24-hour formats
|
455 |
459 |
assert resp.json['data'][0]['text'].endswith(' 17:00')
|
456 |
460 |
assert resp.json['data'][0]['datetime'].endswith(' 17:00:00')
|
457 |
461 |
assert 'data' in resp.json
|
458 |
462 |
|
459 |
463 |
|
460 |
|
def test_datetime_api_label(app, some_data):
|
461 |
|
agenda_id = Agenda.objects.filter(label=u'Foo bar 2')[0].id
|
462 |
|
event = Event.objects.filter(agenda=agenda_id)[0]
|
463 |
|
event.label = 'Hello world'
|
464 |
|
event.save()
|
465 |
|
resp = app.get('/api/agenda/%s/datetimes/' % agenda_id)
|
|
464 |
def test_datetime_api_label(app):
|
|
465 |
agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0)
|
|
466 |
Event.objects.create(
|
|
467 |
label='Hello world',
|
|
468 |
slug='event-slug',
|
|
469 |
start_datetime=(now() + datetime.timedelta(days=1)),
|
|
470 |
places=5,
|
|
471 |
agenda=agenda,
|
|
472 |
)
|
|
473 |
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
|
466 |
474 |
assert 'Hello world' in [x['text'] for x in resp.json['data']]
|
467 |
475 |
|
468 |
476 |
|
469 |
|
-
|