Projet

Général

Profil

0001-test-add-a-recurent-event-providing-int-as-recurrent.patch

Nicolas Roche, 27 janvier 2022 17:06

Télécharger (2,54 ko)

Voir les différences:

Subject: [PATCH 1/2] test: add a recurent event providing int as
 recurrent_days (#60351)

 tests/api/test_event.py | 53 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
tests/api/test_event.py
333 333
        '2021-12-02',
334 334
        '2021-12-04',
335 335
        '2021-12-13',
336 336
        '2021-12-16',
337 337
        '2021-12-18',
338 338
    ]
339 339

  
340 340

  
341
def test_add_event_serialiser(app, user):
342
    app.authorization = ('Basic', ('john.doe', 'password'))
343
    agenda = Agenda(label='Foo bar')
344
    agenda.maximal_booking_delay = 0
345
    agenda.save()
346
    api_url = '/api/agenda/%s/event/' % (agenda.slug)
347

  
348
    params = {
349
        'start_datetime': '2022-01-27 16:00',
350
        'places': 12,
351
        'recurrence_days': '2',
352
    }
353
    resp = app.post(api_url, params=params)
354
    assert not resp.json['err']
355
    assert Event.objects.filter(agenda=agenda).count() == 1
356

  
357
    params = {
358
        'start_datetime': '2022-01-27 16:00',
359
        'places': 12,
360
        'recurrence_days': 2,
361
    }
362
    resp = app.post(api_url, params=params)
363
    assert not resp.json['err']
364
    assert Event.objects.filter(agenda=agenda).count() == 2
365

  
366
    params = {
367
        'start_datetime': '2022-01-27 16:00',
368
        'places': 12,
369
        'recurrence_days': ['0', '3', '5'],
370
    }
371
    resp = app.post(api_url, params=params)
372
    assert not resp.json['err']
373
    assert Event.objects.filter(agenda=agenda).count() == 3
374

  
375
    params = {
376
        'start_datetime': '2022-01-27 16:00',
377
        'places': 12,
378
        'recurrence_days': [0, 3, 5],
379
    }
380
    resp = app.post(api_url, params=params)
381
    assert not resp.json['err']
382
    assert Event.objects.filter(agenda=agenda).count() == 4
383

  
384
    params = {
385
        'start_datetime': '2022-01-27 16:00',
386
        'places': 12,
387
        'recurrence_days': '0, 3, 5',
388
    }
389
    resp = app.post(api_url, params=params)
390
    assert not resp.json['err']
391
    assert Event.objects.filter(agenda=agenda).count() == 5
392

  
393

  
341 394
@pytest.mark.freeze_time('2021-11-01')
342 395
def test_update_event(app, user):
343 396
    api_url = '/api/agenda/%s/event/%s/' % ('nop', 'nop')
344 397

  
345 398
    # no authentication
346 399
    resp = app.patch(api_url, status=401)
347 400
    assert resp.json['detail'] == 'Authentication credentials were not provided.'
348 401

  
349
-