File: test_set_get_del_context.py

package info (click to toggle)
python-django-guid 3.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 664 kB
  • sloc: python: 1,267; makefile: 16
file content (23 lines) | stat: -rw-r--r-- 942 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest


async def test_api(async_client, caplog, mock_uuid):
    await async_client.get('/api-usage')
    expected = [
        ('async middleware called', None),
        (
            'Header `Correlation-ID` was not found in the incoming request. Generated '
            'new GUID: 704ae5472cae4f8daa8f2cc5a5a8mock',
            None,
        ),
        ('Current GUID: 704ae5472cae4f8daa8f2cc5a5a8mock', '704ae5472cae4f8daa8f2cc5a5a8mock'),
        (
            'Changing the guid ContextVar from 704ae5472cae4f8daa8f2cc5a5a8mock to another guid',
            '704ae5472cae4f8daa8f2cc5a5a8mock',
        ),
        ('Current GUID: another guid', 'another guid'),
        ('Clearing another guid from the guid ContextVar', 'another guid'),
        ('Current GUID: None', None),
        ('Received signal `request_finished`, clearing guid', None),
    ]
    assert [(x.message, x.correlation_id) for x in caplog.records] == expected