-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Agent unit test and asserting calls to logging.
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
import mock | ||
import unittest | ||
import sys | ||
sys.modules['schedule'] = mock.Mock() | ||
from cachet_url_monitor.scheduler import Agent | ||
|
||
|
||
class AgentTest(unittest.TestCase): | ||
def setUp(self): | ||
self.configuration = mock.Mock() | ||
self.agent = Agent(self.configuration) | ||
|
||
def test_init(self): | ||
assert self.agent.configuration == self.configuration | ||
|
||
def test_execute(self): | ||
evaluate = self.configuration.evaluate | ||
push_status_and_metrics = self.configuration.push_status_and_metrics | ||
self.agent.execute() | ||
|
||
evaluate.assert_called_once() | ||
push_status_and_metrics.assert_called_once() | ||
|
||
def test_start(self): | ||
every = sys.modules['schedule'].every | ||
self.configuration.data = {'frequency': 5} | ||
|
||
self.agent.start() | ||
|
||
every.assert_called_with(5) |