| 12 | |
| 13 | |
| 14 | def test_atoms_defaults(): |
| 15 | response = SimpleNamespace( |
| 16 | status='200', response_length=1024, |
| 17 | headers=(('Content-Type', 'application/json'),), sent=1024, |
| 18 | ) |
| 19 | request = SimpleNamespace(headers=(('Accept', 'application/json'),)) |
| 20 | environ = { |
| 21 | 'REQUEST_METHOD': 'GET', 'RAW_URI': '/my/path?foo=bar', |
| 22 | 'PATH_INFO': '/my/path', 'QUERY_STRING': 'foo=bar', |
| 23 | 'SERVER_PROTOCOL': 'HTTP/1.1', |
| 24 | } |
| 25 | logger = Logger(Config()) |
| 26 | atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1)) |
| 27 | assert isinstance(atoms, dict) |
| 28 | assert atoms['r'] == 'GET /my/path?foo=bar HTTP/1.1' |
| 29 | assert atoms['m'] == 'GET' |
| 30 | assert atoms['U'] == '/my/path' |
| 31 | assert atoms['q'] == 'foo=bar' |
| 32 | assert atoms['H'] == 'HTTP/1.1' |
| 33 | assert atoms['b'] == '1024' |
| 34 | assert atoms['B'] == 1024 |
| 35 | assert atoms['{accept}i'] == 'application/json' |
| 36 | assert atoms['{content-type}o'] == 'application/json' |
| 37 | |
| 38 | |
| 39 | def test_atoms_zero_bytes(): |