Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
e1cf7412
Commit
e1cf7412
authored
Dec 29, 2011
by
Michal 'vorner' Vaner
Browse files
[1454] Check we check for new commands
parent
ba9038e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/ddns/ddns.py.in
View file @
e1cf7412
...
...
@@ -146,7 +146,7 @@ class DDNSServer:
select.select([cc_fileno, listen_fileno], [], [])
for fileno in reads:
if fileno == cc_fileno:
self._cc.check_command(
Fals
e)
self._cc.check_command(
Tru
e)
elif fileno == listen_fileno:
self.accept()
else:
...
...
src/bin/ddns/tests/ddns_test.py
View file @
e1cf7412
...
...
@@ -79,6 +79,7 @@ class TestDDNSServer(unittest.TestCase):
cc_session
=
MyCCSession
()
self
.
assertFalse
(
cc_session
.
_started
)
self
.
ddns_server
=
ddns
.
DDNSServer
(
cc_session
)
self
.
cc_session
=
cc_session
self
.
assertTrue
(
cc_session
.
_started
)
self
.
__select_expected
=
None
self
.
__select_answer
=
None
...
...
@@ -124,12 +125,12 @@ class TestDDNSServer(unittest.TestCase):
self
.
ddns_server
.
_shutdown
=
True
return
answer
def
__hook
(
self
):
def
__hook
(
self
,
param
=
None
):
"""
A hook that can be installed to any unary function and see
if it was
really called.
A hook that can be installed to any
nullary or
unary function and see
if it was
really called.
"""
self
.
__hook_called
=
True
self
.
__hook_called
=
param
def
test_accept_called
(
self
):
"""
...
...
@@ -140,10 +141,31 @@ class TestDDNSServer(unittest.TestCase):
self
.
ddns_server
.
accept
=
self
.
__hook
self
.
__select_expected
=
([
1
,
2
],
[],
[],
None
)
self
.
__select_answer
=
([
2
],
[],
[])
self
.
__hook_called
=
"Not called"
self
.
ddns_server
.
run
()
self
.
assertTrue
(
self
.
ddns_server
.
_shutdown
)
# The answer got used
self
.
assertIsNone
(
self
.
__select_answer
)
# Reset, when called without parameter
self
.
assertIsNone
(
self
.
__hook_called
)
ddns
.
select
.
select
=
select
.
select
def
test_check_command_called
(
self
):
"""
Test the check_command is called when there's something on the
socket.
"""
self
.
ddns_server
.
_listen_socket
=
FakeSocket
(
2
)
ddns
.
select
.
select
=
self
.
__select
self
.
cc_session
.
check_command
=
self
.
__hook
self
.
__select_expected
=
([
1
,
2
],
[],
[],
None
)
self
.
__select_answer
=
([
1
],
[],
[])
self
.
ddns_server
.
run
()
self
.
assertTrue
(
self
.
ddns_server
.
_shutdown
)
# The answer got used
self
.
assertIsNone
(
self
.
__select_answer
)
# And the check_command was called with true parameter (eg.
# non-blocking)
self
.
assertTrue
(
self
.
__hook_called
)
ddns
.
select
.
select
=
select
.
select
...
...
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