def test_check_local_healthcheck_returns_false_on_failure(): mock_get = mock.Mock(raise_for_status=mock.Mock( side_effect=RequestException())) with mock.patch('nerve_tools.updown_service.read_service_configuration', return_value={'port': 1010}), mock.patch( 'requests.get', return_value=mock_get) as mock_http: assert not updown_service.check_local_healthcheck('service_three.main') mock_http.assert_called_once_with('http://127.0.0.1:1010/status')
def test_check_local_healthcheck_returns_true_on_success(): with contextlib.nested( mock.patch('nerve_tools.updown_service.read_service_configuration', return_value={'port': 1010}), mock.patch('requests.get', return_value=mock.Mock())) as (_, mock_http): assert updown_service.check_local_healthcheck('service_three.main') mock_http.assert_called_once_with('http://127.0.0.1:1010/status')
def test_check_local_healthcheck_returns_true_on_success(): with contextlib.nested( mock.patch('nerve_tools.updown_service.read_service_configuration', return_value={'port': 1010}), mock.patch('requests.get', return_value=mock.Mock())) as (_, mock_http): assert updown_service.check_local_healthcheck( 'service_three.main') mock_http.assert_called_once_with('http://127.0.0.1:1010/status')
def test_check_local_healthcheck_returns_false_on_failure(): mock_get = mock.Mock( raise_for_status=mock.Mock(side_effect=RequestException())) with contextlib.nested( mock.patch('nerve_tools.updown_service.read_service_configuration', return_value={'port': 1010}), mock.patch('requests.get', return_value=mock_get)) as (_, mock_http): assert not updown_service.check_local_healthcheck( 'service_three.main') mock_http.assert_called_once_with('http://127.0.0.1:1010/status')