def test_can_connect_service_check_state(instance, aggregator, test_case_name, request_mock_effects, expected_tags, expect_exception, expected_status): check = MesosSlave('mesos_slave', {}, [instance]) with mock.patch('datadog_checks.base.utils.http.requests') as r: r.get.side_effect = request_mock_effects try: check._process_state_info('http://hello.com', instance['tasks'], 5050, instance['tags']) assert expect_exception is False except CheckException: assert expect_exception is True aggregator.assert_service_check('mesos_slave.can_connect', count=1, status=expected_status, tags=expected_tags)
def test_can_connect_service_with_instance_cluster_name(instance, aggregator): instance['cluster_name'] = 'test-cluster' expected_tags = ['url:http://hello.com/state' ] + cluster_name_tag + additional_tags expected_status = AgentCheck.OK check = MesosSlave('mesos_slave', {}, [instance]) with mock.patch('datadog_checks.base.utils.http.requests') as r: r.get.side_effect = [mock.MagicMock(status_code=200, content='{}')] try: check._process_state_info('http://hello.com', instance['tasks'], 5050, instance['tags']) assert not False except Exception: if not False: raise aggregator.assert_service_check('mesos_slave.can_connect', count=1, status=expected_status, tags=expected_tags)