-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2659 from lunkwill42/feature/support-standard-log…
…ging-fileconfig Read logging config from logging.yml if available
- Loading branch information
Showing
3 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Tests for nav.logs module""" | ||
import os | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from nav import logs | ||
|
||
|
||
def test_get_logging_yaml(valid_logging_yaml): | ||
"""Tests the happy path. | ||
The failure path is covered implicitly by many other tests. | ||
""" | ||
with mock.patch.dict(os.environ, {"NAV_LOGGING_YAML": str(valid_logging_yaml)}): | ||
config = logs._get_logging_yaml() | ||
assert isinstance(config, dict) | ||
|
||
|
||
@pytest.fixture | ||
def valid_logging_yaml(tmp_path): | ||
"""Provides a minimally valid logging config file in YAML format""" | ||
filename = tmp_path / "logging.yml" | ||
with open(filename, "w") as yaml: | ||
yaml.write( | ||
""" | ||
version: 1 | ||
""" | ||
) | ||
yield filename |