示例#1
0
class SchedulerTest(unittest.TestCase):
    @mock.patch("requests.get")
    def setUp(self, mock_requests):
        def get(url, headers):
            get_return = mock.Mock()
            get_return.ok = True
            get_return.json = mock.Mock()
            get_return.json.return_value = {"data": {"status": 1}}
            return get_return

        mock_requests.get = get

        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):
        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()
示例#2
0
class SchedulerTest(unittest.TestCase):
    @mock.patch('requests.get')
    def setUp(self, mock_requests):
        def get(url, headers):
            get_return = mock.Mock()
            get_return.ok = True
            get_return.json = mock.Mock()
            get_return.json.return_value = {'data': {'status': 1}}
            return get_return

        mock_requests.get = get

        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):
        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()
    def setUp(self, mock_requests):
        def get(url, headers):
            get_return = mock.Mock()
            get_return.ok = True
            get_return.json = mock.Mock()
            get_return.json.return_value = {'data': {'status': 1}}
            return get_return

        mock_requests.get = get

        self.scheduler = Scheduler('config.yml')
示例#4
0
    def setUp(self, mock_requests):
        def get(url, headers):
            get_return = mock.Mock()
            get_return.ok = True
            get_return.json = mock.Mock()
            get_return.json.return_value = {"data": {"status": 1}}
            return get_return

        mock_requests.get = get

        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,
        )
示例#5
0
    def setUp(self, mock_requests):
        def get(url, headers):
            get_return = mock.Mock()
            get_return.ok = True
            get_return.json = mock.Mock()
            get_return.json.return_value = {'data': {'status': 1}}
            return get_return

        mock_requests.get = get

        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)
class SchedulerTest(unittest.TestCase):
    @mock.patch('requests.get')
    def setUp(self, mock_requests):
        def get(url, headers):
            get_return = mock.Mock()
            get_return.ok = True
            get_return.json = mock.Mock()
            get_return.json.return_value = {'data': {'status': 1}}
            return get_return

        mock_requests.get = get

        self.scheduler = Scheduler('config.yml')

    def test_init(self):
        assert self.scheduler.stop == False

    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()