Commit 7c56771f authored by zhifan huang's avatar zhifan huang

chore: reformat code, rmove trailing space

parent 2d99db22
...@@ -21,7 +21,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -21,7 +21,6 @@ class testBaseTunnelManager(unittest.TestCase):
cls.cert = x509.Cert("ca.cert", "node.key", "node.cert") cls.cert = x509.Cert("ca.cert", "node.key", "node.cert")
cls.control_socket = "babeld.sock" cls.control_socket = "babeld.sock"
def setUp(self): def setUp(self):
patcher = patch("re6st.cache.Cache") patcher = patch("re6st.cache.Cache")
pacher_sock = patch("socket.socket") pacher_sock = patch("socket.socket")
...@@ -39,7 +38,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -39,7 +38,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.tunnel.close() self.tunnel.close()
del self.tunnel del self.tunnel
@patch("re6st.tunnel.BaseTunnelManager._babel_dump_one", create=True) @patch("re6st.tunnel.BaseTunnelManager._babel_dump_one", create=True)
@patch("re6st.tunnel.BaseTunnelManager._babel_dump_two", create=True) @patch("re6st.tunnel.BaseTunnelManager._babel_dump_two", create=True)
def test_babel_dump(self, two, one): def test_babel_dump(self, two, one):
...@@ -53,8 +51,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -53,8 +51,6 @@ class testBaseTunnelManager(unittest.TestCase):
one.assert_called_once() one.assert_called_once()
two.assert_called_once() two.assert_called_once()
@patch("re6st.ctl.Babel.request_dump") @patch("re6st.ctl.Babel.request_dump")
def test_request_dump_empty(self, request_dump): def test_request_dump_empty(self, request_dump):
"""case when self.__requesting_dump is None or empty""" """case when self.__requesting_dump is None or empty"""
...@@ -65,7 +61,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -65,7 +61,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(self.tunnel._BaseTunnelManager__requesting_dump, set([reason])) self.assertEqual(self.tunnel._BaseTunnelManager__requesting_dump, set([reason]))
request_dump.assert_called_once() request_dump.assert_called_once()
@patch("re6st.ctl.Babel.request_dump") @patch("re6st.ctl.Babel.request_dump")
def test___request_dump_not_empty(self, request_dump): def test___request_dump_not_empty(self, request_dump):
"""case when self.__requesting_dump is not empty""" """case when self.__requesting_dump is not empty"""
...@@ -77,7 +72,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -77,7 +72,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(self.tunnel._BaseTunnelManager__requesting_dump, set([reason, "rina"])) self.assertEqual(self.tunnel._BaseTunnelManager__requesting_dump, set([reason, "rina"]))
request_dump.assert_not_called() request_dump.assert_not_called()
def test_selectTimeout_add_callback(self): def test_selectTimeout_add_callback(self):
"""case add new callback""" """case add new callback"""
self.tunnel._timeouts = [(1, self.tunnel.close)] self.tunnel._timeouts = [(1, self.tunnel.close)]
...@@ -87,7 +81,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -87,7 +81,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertIn((10, callback), self.tunnel._timeouts) self.assertIn((10, callback), self.tunnel._timeouts)
def test_selectTimeout_removing(self): def test_selectTimeout_removing(self):
"""case remove a callback""" """case remove a callback"""
removed = self.tunnel.babel_dump removed = self.tunnel.babel_dump
...@@ -97,8 +90,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -97,8 +90,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(self.tunnel._timeouts, [(1, self.tunnel.close)]) self.assertEqual(self.tunnel._timeouts, [(1, self.tunnel.close)])
def test_selectTimeout_update(self): def test_selectTimeout_update(self):
"""case update a callback""" """case update a callback"""
updated = self.tunnel.babel_dump updated = self.tunnel.babel_dump
...@@ -108,7 +99,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -108,7 +99,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(self.tunnel._timeouts, [(1, self.tunnel.close), (100, updated)]) self.assertEqual(self.tunnel._timeouts, [(1, self.tunnel.close), (100, updated)])
@patch("re6st.tunnel.BaseTunnelManager.selectTimeout") @patch("re6st.tunnel.BaseTunnelManager.selectTimeout")
def test_invalidatePeers(self, selectTimeout): def test_invalidatePeers(self, selectTimeout):
"""normal case, stop_date: p2 < now < p1 < p3 """normal case, stop_date: p2 < now < p1 < p3
...@@ -129,7 +119,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -129,7 +119,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(self.tunnel._peers, [p1, p3]) self.assertEqual(self.tunnel._peers, [p1, p3])
selectTimeout.assert_called_once_with(p1.stop_date, self.tunnel.invalidatePeers) selectTimeout.assert_called_once_with(p1.stop_date, self.tunnel.invalidatePeers)
# Because _makeTunnel is defined in sub class of BaseTunnelManager, so i comment # Because _makeTunnel is defined in sub class of BaseTunnelManager, so i comment
# the follow test # the follow test
# @patch("re6st.tunnel.BaseTunnelManager._makeTunnel", create=True) # @patch("re6st.tunnel.BaseTunnelManager._makeTunnel", create=True)
...@@ -146,7 +135,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -146,7 +135,6 @@ class testBaseTunnelManager(unittest.TestCase):
# self.assertFalse(self.tunnel._connecting) # self.assertFalse(self.tunnel._connecting)
# makeTunnel.assert_called_once_with(peer, msg) # makeTunnel.assert_called_once_with(peer, msg)
def test_processPacket_address(self): def test_processPacket_address(self):
"""code is 1, for address. And peer or msg are none""" """code is 1, for address. And peer or msg are none"""
c = chr(1) c = chr(1)
...@@ -156,7 +144,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -156,7 +144,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(res, "1,1;2,2") self.assertEqual(res, "1,1;2,2")
def test_processPacket_address_with_peer(self): def test_processPacket_address_with_peer(self):
"""code is 1, peer is not none, msg is none """code is 1, peer is not none, msg is none
in my opion, this function return address in form address,port,portocl in my opion, this function return address in form address,port,portocl
...@@ -173,7 +160,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -173,7 +160,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(res, "1,1,1;0,0,0;2,2,2") self.assertEqual(res, "1,1,1;0,0,0;2,2,2")
@patch("re6st.tunnel.BaseTunnelManager.selectTimeout") @patch("re6st.tunnel.BaseTunnelManager.selectTimeout")
def test_processPacket_version(self, selectTimeout): def test_processPacket_version(self, selectTimeout):
"""code is 0, for network version, peer is none""" """code is 0, for network version, peer is none"""
...@@ -183,7 +169,6 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -183,7 +169,6 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(selectTimeout.call_args[0][1], self.tunnel.newVersion) self.assertEqual(selectTimeout.call_args[0][1], self.tunnel.newVersion)
@patch("re6st.x509.Cert.verifyVersion", Mock(return_value=True)) @patch("re6st.x509.Cert.verifyVersion", Mock(return_value=True))
@patch("re6st.tunnel.BaseTunnelManager.selectTimeout") @patch("re6st.tunnel.BaseTunnelManager.selectTimeout")
def test_processPacket_version(self, selectTimeout): def test_processPacket_version(self, selectTimeout):
...@@ -205,10 +190,5 @@ class testBaseTunnelManager(unittest.TestCase): ...@@ -205,10 +190,5 @@ class testBaseTunnelManager(unittest.TestCase):
self.assertEqual(peer.version, version2) self.assertEqual(peer.version, version2)
self.assertEqual(selectTimeout.call_args[0][1], self.tunnel.newVersion) self.assertEqual(selectTimeout.call_args[0][1], self.tunnel.newVersion)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment