diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 28aa9c8..d9ecf63 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -1,11 +1,30 @@ #!/usr/bin/env python +import mock import unittest +import sys +sys.modules['requests'] = mock.Mock() from cachet_url_monitor.configuration import Configuration class ConfigurationTest(unittest.TestCase): + def setUp(self): + self.configuration = Configuration('config.yml') + def test_init(self): - configuration = Configuration('config.yml') + assert len(self.configuration.data) == 3 + assert len(self.configuration.expectations) == 2 + + def test_evaluate(self): + def total_seconds(): + return 0.1 + def request(method, url, timeout=None): + response = mock.Mock() + response.status_code = 200 + response.elapsed = mock.Mock() + response.elapsed.total_seconds = total_seconds + return response + + sys.modules['requests'].request = request + self.configuration.evaluate() - assert len(configuration.data) == 3 - assert len(configuration.expectations) == 2 + assert self.configuration.status == 1