def mock(init_config, instance): check = MesosMaster(common.CHECK_NAME, init_config, [instance]) check._get_master_roles = lambda v, x: json.loads( read_fixture('roles.json')) check._get_master_stats = lambda v, x: json.loads( read_fixture('stats.json')) check._get_master_state = lambda v, x: json.loads( read_fixture('state.json')) return check
def check(): check = MesosMaster(CHECK_NAME, {}, {}) check._get_master_roles = lambda v, x, y, z: json.loads( read_fixture('roles.json')) check._get_master_stats = lambda v, x, y, z: json.loads( read_fixture('stats.json')) check._get_master_state = lambda v, x, y, z: json.loads( read_fixture('state.json')) return check
def test_can_connect_service_check(instance, aggregator, test_case_name, request_mock_side_effects, expected_status, expected_tags, expect_exception): check = MesosMaster('mesos_master', {}, [instance]) with mock.patch('datadog_checks.base.utils.http.requests') as r: r.get.side_effect = request_mock_side_effects try: check._get_master_state('http://hello.com', ['my:tag']) exception_raised = False except CheckException: exception_raised = True assert expect_exception == exception_raised aggregator.assert_service_check('mesos_master.can_connect', count=1, status=expected_status, tags=expected_tags)