-
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.
Creating more tests for Configuration
- Loading branch information
Showing
1 changed file
with
22 additions
and
3 deletions.
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
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 |