def test_web_connectivity_client_is_not_reachable(self): wcc = WebConnectivityClient( 'https://web-connectivity.th.ooni.io') wcc.queryBackend = MagicMock() wcc.queryBackend.return_value = defer.fail(Exception()) result = yield wcc.isReachable() self.assertEqual(result, False)
def test_web_connectivity_client_is_reachable(self): wcc = WebConnectivityClient( 'https://web-connectivity.th.ooni.io') wcc.queryBackend = MagicMock() wcc.queryBackend.return_value = defer.succeed({"status": "ok"}) result = yield wcc.isReachable() self.assertEqual(result, True)
def test_web_connectivity_client_control(self): wcc = WebConnectivityClient( 'https://web-connectivity.th.ooni.io') wcc.queryBackend = MagicMock() wcc.queryBackend.return_value = defer.succeed({}) yield wcc.control("http://example.com/", ["127.0.0.1:8080", "127.0.0.1:8082"]) wcc.queryBackend.assert_called_with( 'POST', '/', query={ "http_request": "http://example.com/", "tcp_connect": ["127.0.0.1:8080", "127.0.0.1:8082"] })
def test_web_connectivity_client_control(self): wcc = WebConnectivityClient('https://web-connectivity.th.ooni.io') wcc.queryBackend = MagicMock() wcc.queryBackend.return_value = defer.succeed({}) yield wcc.control("http://example.com/", ["127.0.0.1:8080", "127.0.0.1:8082"]) wcc.queryBackend.assert_called_with( 'POST', '/', query={ "http_request": "http://example.com/", "tcp_connect": ["127.0.0.1:8080", "127.0.0.1:8082"] })
def test_web_connectivity_client_is_not_reachable(self): wcc = WebConnectivityClient('https://web-connectivity.th.ooni.io') wcc.queryBackend = MagicMock() wcc.queryBackend.return_value = defer.fail(Exception()) result = yield wcc.isReachable() self.assertEqual(result, False)
def test_web_connectivity_client_is_reachable(self): wcc = WebConnectivityClient('https://web-connectivity.th.ooni.io') wcc.queryBackend = MagicMock() wcc.queryBackend.return_value = defer.succeed({"status": "ok"}) result = yield wcc.isReachable() self.assertEqual(result, True)