Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
zhifan huang
re6stnet
Commits
7c56771f
Commit
7c56771f
authored
Jun 02, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: reformat code, rmove trailing space
parent
2d99db22
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
28 deletions
+8
-28
re6st/tests/test_unit/test_tunnel/test_base_tunnel_manager.py
...t/tests/test_unit/test_tunnel/test_base_tunnel_manager.py
+8
-28
No files found.
re6st/tests/test_unit/test_tunnel/test_base_tunnel_manager.py
View file @
7c56771f
...
...
@@ -21,7 +21,6 @@ class testBaseTunnelManager(unittest.TestCase):
cls
.
cert
=
x509
.
Cert
(
"ca.cert"
,
"node.key"
,
"node.cert"
)
cls
.
control_socket
=
"babeld.sock"
def
setUp
(
self
):
patcher
=
patch
(
"re6st.cache.Cache"
)
pacher_sock
=
patch
(
"socket.socket"
)
...
...
@@ -39,7 +38,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
tunnel
.
close
()
del
self
.
tunnel
@
patch
(
"re6st.tunnel.BaseTunnelManager._babel_dump_one"
,
create
=
True
)
@
patch
(
"re6st.tunnel.BaseTunnelManager._babel_dump_two"
,
create
=
True
)
def
test_babel_dump
(
self
,
two
,
one
):
...
...
@@ -53,8 +51,6 @@ class testBaseTunnelManager(unittest.TestCase):
one
.
assert_called_once
()
two
.
assert_called_once
()
@
patch
(
"re6st.ctl.Babel.request_dump"
)
def
test_request_dump_empty
(
self
,
request_dump
):
"""case when self.__requesting_dump is None or empty"""
...
...
@@ -65,7 +61,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
self
.
tunnel
.
_BaseTunnelManager__requesting_dump
,
set
([
reason
]))
request_dump
.
assert_called_once
()
@
patch
(
"re6st.ctl.Babel.request_dump"
)
def
test___request_dump_not_empty
(
self
,
request_dump
):
"""case when self.__requesting_dump is not empty"""
...
...
@@ -77,7 +72,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
self
.
tunnel
.
_BaseTunnelManager__requesting_dump
,
set
([
reason
,
"rina"
]))
request_dump
.
assert_not_called
()
def
test_selectTimeout_add_callback
(
self
):
"""case add new callback"""
self
.
tunnel
.
_timeouts
=
[(
1
,
self
.
tunnel
.
close
)]
...
...
@@ -87,7 +81,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertIn
((
10
,
callback
),
self
.
tunnel
.
_timeouts
)
def
test_selectTimeout_removing
(
self
):
"""case remove a callback"""
removed
=
self
.
tunnel
.
babel_dump
...
...
@@ -97,8 +90,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
self
.
tunnel
.
_timeouts
,
[(
1
,
self
.
tunnel
.
close
)])
def
test_selectTimeout_update
(
self
):
"""case update a callback"""
updated
=
self
.
tunnel
.
babel_dump
...
...
@@ -108,7 +99,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
self
.
tunnel
.
_timeouts
,
[(
1
,
self
.
tunnel
.
close
),
(
100
,
updated
)])
@
patch
(
"re6st.tunnel.BaseTunnelManager.selectTimeout"
)
def
test_invalidatePeers
(
self
,
selectTimeout
):
"""normal case, stop_date: p2 < now < p1 < p3
...
...
@@ -129,7 +119,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
self
.
tunnel
.
_peers
,
[
p1
,
p3
])
selectTimeout
.
assert_called_once_with
(
p1
.
stop_date
,
self
.
tunnel
.
invalidatePeers
)
# Because _makeTunnel is defined in sub class of BaseTunnelManager, so i comment
# the follow test
# @patch("re6st.tunnel.BaseTunnelManager._makeTunnel", create=True)
...
...
@@ -146,7 +135,6 @@ class testBaseTunnelManager(unittest.TestCase):
# self.assertFalse(self.tunnel._connecting)
# makeTunnel.assert_called_once_with(peer, msg)
def
test_processPacket_address
(
self
):
"""code is 1, for address. And peer or msg are none"""
c
=
chr
(
1
)
...
...
@@ -156,7 +144,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
res
,
"1,1;2,2"
)
def
test_processPacket_address_with_peer
(
self
):
"""code is 1, peer is not none, msg is none
in my opion, this function return address in form address,port,portocl
...
...
@@ -173,7 +160,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
res
,
"1,1,1;0,0,0;2,2,2"
)
@
patch
(
"re6st.tunnel.BaseTunnelManager.selectTimeout"
)
def
test_processPacket_version
(
self
,
selectTimeout
):
"""code is 0, for network version, peer is none"""
...
...
@@ -183,7 +169,6 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
selectTimeout
.
call_args
[
0
][
1
],
self
.
tunnel
.
newVersion
)
@
patch
(
"re6st.x509.Cert.verifyVersion"
,
Mock
(
return_value
=
True
))
@
patch
(
"re6st.tunnel.BaseTunnelManager.selectTimeout"
)
def
test_processPacket_version
(
self
,
selectTimeout
):
...
...
@@ -205,10 +190,5 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
peer
.
version
,
version2
)
self
.
assertEqual
(
selectTimeout
.
call_args
[
0
][
1
],
self
.
tunnel
.
newVersion
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment