def test_check_internet_ioerror(settings):
    settings['check_connectivity_url'] = 'test_url'
    with mock.patch('diagnostics.diagnostics.tornado.httpclient.AsyncHTTPClient') as client:
        fut = Future()
        fut.set_exception(IOError('ERROR TEST'))
        client.return_value.fetch.return_value = fut
        status = yield diagnostics._check_internet(settings)
        assert 'ERROR TEST' in status['reason']
        assert 'test_url' in status['reason']
        assert status['status'] is False
def test_check_internet_wrong_status_code(settings):
    settings['check_connectivity_url'] = 'test_url'
    with mock.patch('diagnostics.diagnostics.tornado.httpclient.AsyncHTTPClient') as client:
        result = mock.MagicMock()
        result.code = 555
        fut = Future()
        fut.set_result(result)
        client.return_value.fetch.return_value = fut
        status = yield diagnostics._check_internet(settings)
        assert '555' in status['reason']
        assert status['status'] is False
Exemple #3
0
def test_check_internet(settings):
    status = yield diagnostics._check_internet(settings)
    assert status['reason'] == ''
    assert status['status'] is True
def test_check_internet(settings):
    status = yield diagnostics._check_internet(settings)
    assert status['reason'] == ''
    assert status['status'] is True