#10 - Creating auxiliary client class to generate configuration class (#78)

* #10 - Creating auxiliary client class to generate configuration class based on cachet's component list.

* Updating the python version in codacy to reduce false positives

* Moving some of the cachet operations to the client class to clean up the configuration class and making better constants

* Refactoring status to have proper classes and adding more tests. Refactoring the requests tests to use requests-mock.

* Removing unused imports from test_scheduler

* Adding more tests and the ability to run the client from command line

* Updating README and client arg parsing

* Fixing broken unit tests
This commit is contained in:
mtakaki
2020-01-18 13:55:07 -08:00
committed by GitHub
parent bcafbd64f7
commit 5be0217c00
13 changed files with 530 additions and 269 deletions
+32 -3
View File
@@ -3,7 +3,6 @@ import sys
import unittest
import mock
from yaml import load, SafeLoader
sys.modules['schedule'] = mock.Mock()
from cachet_url_monitor.scheduler import Agent, Scheduler
@@ -46,13 +45,43 @@ class SchedulerTest(unittest.TestCase):
mock_requests.get = get
self.scheduler = Scheduler(load(open('config.yml', 'r'), SafeLoader), 0)
self.agent = mock.MagicMock()
self.scheduler = Scheduler(
{
'endpoints': [
{
'name': 'foo',
'url': 'http://localhost:8080/swagger',
'method': 'GET',
'expectation': [
{
'type': 'HTTP_STATUS',
'status_range': '200 - 300',
'incident': 'MAJOR',
}
],
'allowed_fails': 0,
'component_id': 1,
'action': ['CREATE_INCIDENT', 'UPDATE_STATUS'],
'public_incidents': True,
'latency_unit': 'ms',
'frequency': 30
}
],
'cachet': {
'api_url': 'https: // demo.cachethq.io / api / v1',
'token': 'my_token'
}
}, self.agent)
def test_init(self):
assert self.scheduler.stop == False
self.assertFalse(self.scheduler.stop)
def test_start(self):
# TODO(mtakaki|2016-05-01): We need a better way of testing this method.
# Leaving it as a placeholder.
self.scheduler.stop = True
self.scheduler.start()
self.agent.start.assert_called()