mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
add test_atom_defaults()
This commit is contained in:
parent
e755dde2c0
commit
87474ffce1
27
tests/test_006-logger.py
Normal file
27
tests/test_006-logger.py
Normal file
@ -0,0 +1,27 @@
|
||||
import datetime
|
||||
|
||||
import t
|
||||
|
||||
from gunicorn.config import Config
|
||||
from gunicorn.glogging import Logger
|
||||
|
||||
|
||||
class Mock():
|
||||
def __init__(self, **kwargs):
|
||||
for attr in kwargs:
|
||||
setattr(self, attr, kwargs[attr])
|
||||
|
||||
|
||||
def test_atoms_defaults():
|
||||
response = Mock(status='200', response_length=1024,
|
||||
headers=(('Content-Type', 'application/json'), ))
|
||||
request = Mock(headers=(('Accept', 'application/json'), ))
|
||||
environ = {'REQUEST_METHOD': 'GET', 'RAW_URI': 'http://my.uri',
|
||||
'SERVER_PROTOCOL': 'HTTP/1.1'}
|
||||
logger = Logger(Config())
|
||||
atoms = logger.atoms(response, request, environ,
|
||||
datetime.timedelta(seconds=1))
|
||||
t.istype(atoms, dict)
|
||||
t.eq(atoms['r'], 'GET http://my.uri HTTP/1.1')
|
||||
t.eq(atoms['{accept}i'], 'application/json')
|
||||
t.eq(atoms['{content-type}o'], 'application/json')
|
||||
Loading…
x
Reference in New Issue
Block a user