Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
add missing tests file
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Feb 18, 2019
1 parent a076c02 commit 95625fb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_shutdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from unittest.mock import MagicMock

from kube_janitor.shutdown import GracefulShutdown


def test_graceful_shutdown(monkeypatch):
handler = GracefulShutdown()
assert not handler.safe_to_exit
with handler.safe_exit():
assert handler.safe_to_exit

assert not handler.shutdown_now
# this would be called by SIGINT or SIGTERM
handler.exit_gracefully(None, None)
assert handler.shutdown_now

mock_exit = MagicMock()
monkeypatch.setattr('sys.exit', mock_exit)
with handler.safe_exit():
handler.exit_gracefully(None, None)

mock_exit.assert_called_once_with(0)

0 comments on commit 95625fb

Please sign in to comment.