Skip to content

Commit

Permalink
Unit test nav.logs._get_logging_yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
lunkwill42 committed Aug 11, 2023
1 parent f333b9d commit fe723e8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/unittests/logs_test.py
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

0 comments on commit fe723e8

Please sign in to comment.