Skip to content

Commit

Permalink
Add test coverage for get_log_path
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Jul 18, 2024
1 parent bd27593 commit f302252
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/unittests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,21 @@ def test_get_logs_config(self):
self.assertEqual(get_logs_config("test_service", logging_config),
expected_config)

def test_get_log_path(self):
@patch("ovos_utils.log.get_logs_config")
def test_get_log_path(self, get_config):
from ovos_utils.log import get_log_path

# Test with multiple populated directories
real_log_path = join(dirname(__file__), "test_logs")
test_paths = [self.test_dir, dirname(__file__), real_log_path]

# Test with specified empty directory
# Test with multiple populated directories
self.assertEqual(get_log_path("real", test_paths), real_log_path)
self.assertIsNone(get_log_path("fake", test_paths))

# Test path from configuration
get_config.return_value = {"path": self.test_dir}
self.assertEqual(get_log_path("test"), self.test_dir)
get_config.assert_called_once_with(service_name="test")

@patch('ovos_utils.log.get_log_path')
def test_get_log_paths(self, get_log_path):
Expand Down
Empty file.

0 comments on commit f302252

Please sign in to comment.