mirror of
https://github.com/mtan93/cachet-url-monitor.git
synced 2026-03-08 05:31:58 +00:00
Creating more tests for Configuration
This commit is contained in:
@@ -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 test_init(self):
|
||||
configuration = Configuration('config.yml')
|
||||
def setUp(self):
|
||||
self.configuration = Configuration('config.yml')
|
||||
|
||||
assert len(configuration.data) == 3
|
||||
assert len(configuration.expectations) == 2
|
||||
def test_init(self):
|
||||
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 self.configuration.status == 1
|
||||
|
||||
Reference in New Issue
Block a user