added test for utils.make_tuple_fromstr and fixed send_objects to ignore checking nodes for all configs, since that is not always the case
This commit is contained in:
parent
0c840f553d
commit
991abb1895
3 changed files with 27 additions and 5 deletions
|
@ -1697,16 +1697,16 @@ class CoreHandler(SocketServer.BaseRequestHandler):
|
|||
|
||||
# send mobility model info
|
||||
for node_id in self.session.mobility.nodes():
|
||||
node = self.session.get_object(node_id)
|
||||
for model_class, config in self.session.mobility.get_models(node):
|
||||
for model_name, config in self.session.mobility.get_all_configs(node_id).iteritems():
|
||||
model_class = self.session.mobility.models[model_name]
|
||||
logger.debug("mobility config: node(%s) class(%s) values(%s)", node_id, model_class, config)
|
||||
config_data = ConfigShim.config_data(0, node_id, ConfigFlags.UPDATE.value, model_class, config)
|
||||
self.session.broadcast_config(config_data)
|
||||
|
||||
# send emane model info
|
||||
for node_id in self.session.emane.nodes():
|
||||
node = self.session.get_object(node_id)
|
||||
for model_class, config in self.session.emane.get_models(node):
|
||||
for model_name, config in self.session.emane.get_all_configs(node_id).iteritems():
|
||||
model_class = self.session.emane.models[model_name]
|
||||
logger.debug("emane config: node(%s) class(%s) values(%s)", node_id, model_class, config)
|
||||
config_data = ConfigShim.config_data(0, node_id, ConfigFlags.UPDATE.value, model_class, config)
|
||||
self.session.broadcast_config(config_data)
|
||||
|
|
|
@ -126,7 +126,7 @@ def make_tuple_fromstr(s, value_type):
|
|||
"""
|
||||
Create a tuple from a string.
|
||||
|
||||
:param str s: string to convert to a tuple
|
||||
:param str|unicode s: string to convert to a tuple
|
||||
:param value_type: type of values to be contained within tuple
|
||||
:return: tuple from string
|
||||
:rtype: tuple
|
||||
|
|
22
daemon/tests/test_utils.py
Normal file
22
daemon/tests/test_utils.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from core.misc import utils
|
||||
|
||||
|
||||
class TestUtils:
|
||||
def test_make_tuple_fromstr(self):
|
||||
# given
|
||||
no_args = "()"
|
||||
one_arg = "('one',)"
|
||||
two_args = "('one', 'two')"
|
||||
unicode_args = u"('one', 'two', 'three')"
|
||||
|
||||
# when
|
||||
no_args = utils.make_tuple_fromstr(no_args, str)
|
||||
one_arg = utils.make_tuple_fromstr(one_arg, str)
|
||||
two_args = utils.make_tuple_fromstr(two_args, str)
|
||||
unicode_args = utils.make_tuple_fromstr(unicode_args, str)
|
||||
|
||||
# then
|
||||
assert no_args == ()
|
||||
assert len(one_arg) == 1
|
||||
assert len(two_args) == 2
|
||||
assert len(unicode_args) == 3
|
Loading…
Reference in a new issue