Project

General

Profile

Development #68268

Test flaky sur /api/agendas/

Added by A. B. about 2 years ago. Updated about 2 years ago.

Status:
Nouveau
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
18 August 2022
Due date:
% Done:

0%

Estimated time:
Patch proposed:
No
Planning:
No

Description

Découvert pendant #68260, deux autres tests qui clignotent sur Jenkins, sans que j'arrive à reproduire de manière fiable :


__________________________ test_booking_api_fillslots __________________________
[gw2] linux -- Python 3.9.2 /tmp/tox-jenkins/chrono/wip/68260-Test-flaky-sur-api-agendas-recur/py3-django22-codestyle-coverage/bin/python

app = <django_webtest.DjangoTestApp object at 0x7f5f2d4a4370>
user = <User: john.doe>

    def test_booking_api_fillslots(app, user):
        agenda = Agenda.objects.create(label='Foo bar', kind='events')
        events = []
        for i in range(3):
            events.append(
                Event.objects.create(
                    label='Event', start_datetime=now() + datetime.timedelta(days=5 + i), places=20, agenda=agenda
                )
            )
        events_ids = [x.id for x in events]
        events_slugs = [x.slug for x in events]
        event = events[0]

        # unauthenticated
        resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug, status=401)

        for agenda_key in (agenda.slug, agenda.id):  # acces datetimes via agenda slug or id (legacy)
            resp_datetimes = app.get('/api/agenda/%s/datetimes/' % agenda_key)
            api_event_slugs = [x['id'] for x in resp_datetimes.json['data']]
>           assert api_event_slugs == events_slugs
E           AssertionError: assert ['event-1', '...t', 'event-2'] == ['event', 'ev...1', 'event-2']
E             At index 0 diff: 'event-1' != 'event'
E             Use -v to get more diff

tests/api/fillslot/test_all.py:449: AssertionError
------------------------------ Captured log call -------------------------------
WARNING  django.request:log.py:224 Unauthorized: /api/agenda/foo-bar/fillslots/
__________________________ test_booking_api_available __________________________
[gw2] linux -- Python 3.9.2 /tmp/tox-jenkins/chrono/wip/68260-Test-flaky-sur-api-agendas-recur/py3-django22-codestyle-coverage/bin/python

app = <django_webtest.DjangoTestApp object at 0x7f5f2d7d4400>
user = <User: john.doe>

    def test_booking_api_available(app, user):
        agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0)
        for i in range(0, 10):
            event = Event.objects.create(
                slug='event-slug%i' % i,
                start_datetime=(now() + datetime.timedelta(days=5)).replace(hour=10, minute=i),
                places=20,
                agenda=agenda,
            )
        app.authorization = ('Basic', ('john.doe', 'password'))

        with CaptureQueriesContext(connection) as ctx:
            resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
            assert len(ctx.captured_queries) == 3
        assert resp.json['data'][-1]['places']['total'] == 20
        assert resp.json['data'][-1]['places']['available'] == 20
        assert resp.json['data'][-1]['places']['reserved'] == 0
        assert resp.json['data'][-1]['places']['full'] is False
        assert 'waiting_list_total' not in resp.json['data'][-1]['places']

        resp = app.post_json('/api/agenda/%s/fillslot/%s/' % (agenda.pk, event.pk))
        assert resp.json['err'] == 0
        assert resp.json['places']['total'] == 20
        assert resp.json['places']['available'] == 19
        assert resp.json['places']['reserved'] == 1
        assert resp.json['places']['full'] is False
        assert 'waiting_list_total' not in resp.json['places']

        resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
        assert resp.json['data'][-1]['places']['total'] == 20
>       assert resp.json['data'][-1]['places']['available'] == 19
E       assert 20 == 19

tests/api/fillslot/test_all.py:1022: AssertionError
=============================== warnings summary ===============================

Related issues

Related to Chrono - Development #68260: Test flaky sur /api/agendas/recurring-events/Fermé18 August 2022

Actions

History

#1

Updated by A. B. about 2 years ago

Also available in: Atom PDF