Skip to content

Commit

Permalink
Creating more tests for Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mtakaki committed Apr 29, 2016
1 parent c552045 commit a24c69c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a24c69c

Please sign in to comment.