77from gunicorn .glogging import Logger
88
99
10+ ONE_SECOND_IN_NS = 1_000_000_000
11+
1012def test_atoms_defaults ():
1113 response = SimpleNamespace (
1214 status = '200' , response_length = 1024 ,
@@ -19,7 +21,7 @@ def test_atoms_defaults():
1921 'SERVER_PROTOCOL' : 'HTTP/1.1' ,
2022 }
2123 logger = Logger (Config ())
22- atoms = logger .atoms (response , request , environ , datetime . timedelta ( seconds = 1 ) )
24+ atoms = logger .atoms (response , request , environ , ONE_SECOND_IN_NS )
2325 assert isinstance (atoms , dict )
2426 assert atoms ['r' ] == 'GET /my/path?foo=bar HTTP/1.1'
2527 assert atoms ['m' ] == 'GET'
@@ -30,7 +32,7 @@ def test_atoms_defaults():
3032 assert atoms ['B' ] == 1024
3133 assert atoms ['{accept}i' ] == 'application/json'
3234 assert atoms ['{content-type}o' ] == 'application/json'
33-
35+ assert atoms [ 'N' ] == ONE_SECOND_IN_NS
3436
3537def test_atoms_zero_bytes ():
3638 response = SimpleNamespace (
@@ -44,7 +46,7 @@ def test_atoms_zero_bytes():
4446 'SERVER_PROTOCOL' : 'HTTP/1.1' ,
4547 }
4648 logger = Logger (Config ())
47- atoms = logger .atoms (response , request , environ , datetime . timedelta ( seconds = 1 ) )
49+ atoms = logger .atoms (response , request , environ , ONE_SECOND_IN_NS )
4850 assert atoms ['b' ] == '0'
4951 assert atoms ['B' ] == 0
5052
@@ -68,7 +70,7 @@ def test_get_username_from_basic_auth_header(auth):
6870 'HTTP_AUTHORIZATION' : auth ,
6971 }
7072 logger = Logger (Config ())
71- atoms = logger .atoms (response , request , environ , datetime . timedelta ( seconds = 1 ) )
73+ atoms = logger .atoms (response , request , environ , ONE_SECOND_IN_NS )
7274 assert atoms ['u' ] == 'brk0v'
7375
7476
@@ -87,5 +89,5 @@ def test_get_username_handles_malformed_basic_auth_header():
8789 }
8890 logger = Logger (Config ())
8991
90- atoms = logger .atoms (response , request , environ , datetime . timedelta ( seconds = 1 ) )
92+ atoms = logger .atoms (response , request , environ , ONE_SECOND_IN_NS )
9193 assert atoms ['u' ] == '-'
0 commit comments