コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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"]
         })
コード例 #4
0
 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"]
         })
コード例 #5
0
 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)
コード例 #6
0
 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)