Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
IbraAoad committed Mar 7, 2024
1 parent 602eebb commit f7d111a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/test_alerter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

import os
import textwrap
import threading
import unittest.mock
Expand Down Expand Up @@ -30,17 +31,13 @@ def test_config_default_empty_file(fake_fs):


def test_file_not_found_error(fake_fs):

with unittest.mock.patch("cos_alerter.logger.critical") as mock_critical, unittest.mock.patch(
"sys.exit"
) as mock_exit:

with unittest.mock.patch("cos_alerter.alerter.logger") as mock_logger:
os.unlink("/etc/cos-alerter.yaml")
try:
config.reload()
except SystemExit as exc:
assert exc.code == 1
mock_critical.assert_called_once_with("Config file not found. Exiting...")
mock_exit.assert_called_once_with(1)
mock_logger.critical.assert_called_once_with("Config file not found. Exiting...")
else:
assert False

Expand Down

0 comments on commit f7d111a

Please sign in to comment.