diff --git a/config.yml b/config.yml index ae454ca..f665398 100644 --- a/config.yml +++ b/config.yml @@ -7,6 +7,8 @@ endpoint: status: 200 - type: LATENCY threshold: 1 + - type: REGEX + regex: ".*.*" cachet: api_url: http://status.cachethq.io/api/v1/ token: my_token diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 5107219..a947299 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -21,7 +21,7 @@ class ConfigurationTest(unittest.TestCase): def test_init(self): assert len(self.configuration.data) == 3 - assert len(self.configuration.expectations) == 2 + assert len(self.configuration.expectations) == 3 def test_evaluate(self): def total_seconds(): @@ -31,6 +31,7 @@ class ConfigurationTest(unittest.TestCase): response.status_code = 200 response.elapsed = mock.Mock() response.elapsed.total_seconds = total_seconds + response.text = '' return response sys.modules['requests'].request = request @@ -47,6 +48,7 @@ class ConfigurationTest(unittest.TestCase): response.status_code = 400 response.elapsed = mock.Mock() response.elapsed.total_seconds = total_seconds + response.text = '' return response sys.modules['requests'].request = request diff --git a/tests/test_expectation.py b/tests/test_expectation.py index e3d6c35..fa96ed7 100644 --- a/tests/test_expectation.py +++ b/tests/test_expectation.py @@ -74,26 +74,26 @@ class HttpStatusTest(unittest.TestCase): class RegexTest(unittest.TestCase): def setUp(self): - self.expectation = Regex({'type': 'REGEX', 'regex': '.*(found stuff).*'}) + self.expectation = Regex({'type': 'REGEX', 'regex': '.*(find stuff).*'}) def test_init(self): - assert self.expectation.regex == re.compile('.*(found stuff).*') + assert self.expectation.regex == re.compile('.*(find stuff).*') def test_get_status_healthy(self): request = mock.Mock() - request.text = 'We cound found stuff in this body.' + request.text = 'We could find stuff in this body.' assert self.expectation.get_status(request) == 1 def test_get_status_unhealthy(self): request = mock.Mock() - request.text = 'We will not find here' + request.text = 'We will not find it here' assert self.expectation.get_status(request) == 3 def test_get_message(self): request = mock.Mock() - request.text = 'We will not find here' + request.text = 'We will not find it here' assert self.expectation.get_message(request) == ('Regex did not match ' 'anything in the body') diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index 2b2aef4..64b989e 100644 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import logging import mock import unittest import sys @@ -35,11 +34,11 @@ class AgentTest(unittest.TestCase): class SchedulerTest(unittest.TestCase): def setUp(self): - self.mock_configuration = sys.modules['cachet_url_monitor.configuration.Configuration'] + self.mock_configuration = sys.modules[('cachet_url_monitor.configuration' + '.Configuration')] self.scheduler = Scheduler('config.yml') def test_init(self): - #TODO(mtakaki|2016-05-01): We need more assertions in this test. assert self.scheduler.stop == False def test_start(self):