Skip to content

Commit cdd5996

Browse files
authored
Merge pull request #9 from kilobyteno/renamed-uvicorn-config
2 parents 4eb4d48 + aa746df commit cdd5996

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

tests/test_konfig.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import pytest
44

5-
from tunsberg.konfig import uvicorn_config
5+
from tunsberg.konfig import uvicorn_log_config
66

77

8-
class TestUvicornConfig:
8+
class TestUvicornLogConfig:
99
def test_default_config(self):
1010
log_lvl = logging.NOTSET
11-
config = uvicorn_config(log_level=log_lvl)
11+
config = uvicorn_log_config(log_level=log_lvl)
1212
assert config['version'] == 1
1313
assert not config['disable_existing_loggers']
1414
assert config['formatters']['default']['format'] == '%(asctime)s - %(levelname)s - %(name)s - %(message)s'
@@ -29,29 +29,29 @@ def test_default_config(self):
2929

3030
def test_invalid_log_level(self):
3131
with pytest.raises(ValueError):
32-
uvicorn_config(log_level=999)
32+
uvicorn_log_config(log_level=999)
3333

3434
def test_empty_log_format(self):
3535
with pytest.raises(ValueError):
36-
uvicorn_config(log_level=logging.NOTSET, log_format='')
36+
uvicorn_log_config(log_level=logging.NOTSET, log_format='')
3737

3838
def test_empty_log_file_path(self):
3939
with pytest.raises(ValueError):
40-
uvicorn_config(log_level=logging.NOTSET, log_file_path='')
40+
uvicorn_log_config(log_level=logging.NOTSET, log_file_path='')
4141

4242
def test_custom_log_format(self):
4343
log_format = '%(asctime)s - %(levelname)s - %(name)s - %(message)s - %(filename)s - %(lineno)s'
44-
config = uvicorn_config(log_level=logging.NOTSET, log_format=log_format)
44+
config = uvicorn_log_config(log_level=logging.NOTSET, log_format=log_format)
4545
assert config['formatters']['default']['format'] == log_format
4646

4747
def test_custom_log_file_path(self):
4848
log_file_path = 'custom.log'
49-
config = uvicorn_config(log_level=logging.NOTSET, log_file_path=log_file_path)
49+
config = uvicorn_log_config(log_level=logging.NOTSET, log_file_path=log_file_path)
5050
assert config['handlers']['file']['filename'] == log_file_path
5151

5252
def test_custom_log_level(self):
5353
log_lvl = logging.INFO
54-
config = uvicorn_config(log_level=log_lvl)
54+
config = uvicorn_log_config(log_level=log_lvl)
5555
assert config['loggers']['uvicorn']['level'] == logging.getLevelName(log_lvl)
5656
assert config['loggers']['uvicorn.error']['level'] == logging.getLevelName(log_lvl)
5757
assert config['loggers']['uvicorn.access']['level'] == logging.getLevelName(log_lvl)

tunsberg/konfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33

4-
def uvicorn_config(
4+
def uvicorn_log_config(
55
log_level: int = logging.DEBUG, log_file_path: str = 'uvicorn.log', log_format: str = '%(asctime)s - %(levelname)s - %(name)s - %(message)s'
66
) -> dict:
77
"""

0 commit comments

Comments
 (0)