Commit cb4dc998 authored by zhifan huang's avatar zhifan huang

test: fix test failed in net namespace

mock socks.sendto related function
parent 183cc381
...@@ -235,6 +235,7 @@ class TestRegistryServer(unittest.TestCase): ...@@ -235,6 +235,7 @@ class TestRegistryServer(unittest.TestCase):
# TODO test too many prefix # TODO test too many prefix
@patch("re6st.registry.RegistryServer.sendto", Mock())
@patch("re6st.registry.RegistryServer.createCertificate") @patch("re6st.registry.RegistryServer.createCertificate")
def test_requestCertificate(self, mock_func): def test_requestCertificate(self, mock_func):
token = self.server.addToken(self.email, None) token = self.server.addToken(self.email, None)
...@@ -312,6 +313,7 @@ class TestRegistryServer(unittest.TestCase): ...@@ -312,6 +313,7 @@ class TestRegistryServer(unittest.TestCase):
delete_cert(cur, prefix_new) delete_cert(cur, prefix_new)
cur.close() cur.close()
@patch("re6st.registry.RegistryServer.sendto", Mock())
@patch("re6st.registry.RegistryServer.recv") @patch("re6st.registry.RegistryServer.recv")
@patch("select.select", Mock(return_value=[1])) @patch("select.select", Mock(return_value=[1]))
def test_queryAddress(self, recv): def test_queryAddress(self, recv):
...@@ -348,6 +350,7 @@ class TestRegistryServer(unittest.TestCase): ...@@ -348,6 +350,7 @@ class TestRegistryServer(unittest.TestCase):
self.assertIsNone(self.server.sessions.get(prefix)) self.assertIsNone(self.server.sessions.get(prefix))
self.assertIsNone(get_cert(self.server.db, prefix)) self.assertIsNone(get_cert(self.server.db, prefix))
@patch("re6st.registry.RegistryServer.sendto", Mock())
def test_updateHMAC(self): def test_updateHMAC(self):
def get_hmac(): def get_hmac():
return [self.server.getConfig(registry.BABEL_HMAC[i], None) return [self.server.getConfig(registry.BABEL_HMAC[i], None)
......
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