def test_from_dict(self): m = Method.from_dict(self.serialized.copy()) self.assertEqual(m.takes.to_dict(), self.takes.to_dict()) self.assertEqual(m.defaults, self.serialized["defaults"]) self.assertEqual(m.tags, []) self.assertEqual(m.writeable, True) self.assertEqual(m.label, "") self.assertEqual(m.returns.to_dict(), MapMeta().to_dict())
def test_from_dict(self): m = Method.from_dict(self.serialized.copy()) self.assertEqual(m.takes.to_dict(), self.takes.to_dict()) self.assertEqual(m.defaults, self.serialized["defaults"]) self.assertEqual(m.tags, []) self.assertEqual(m.writeable, True) self.assertEqual(m.label, "") self.assertEqual(m.returns.to_dict(), MapMeta().to_dict())
def wrap_method(self, method_name, method_map): """Take the serialized method map and create a Method from it Args: method_map (dict): Serialized Method """ method = Method.from_dict(method_name, method_map) method.set_function( functools.partial(self.call_server_method, method_name)) self.log_debug("Wrapping method %s", method_name) return method
def wrap_method(self, method_name, method_map): """Take the serialized method map and create a Method from it Args: method_map (dict): Serialized Method """ method = Method.from_dict(method_name, method_map) method.set_function( functools.partial(self.call_server_method, method_name)) self.log_debug("Wrapping method %s", method_name) return method
def test_from_dict_deserialize(self, mock_mapmeta): name = "foo" description = "dummy description" takes = dict(a=object(), b=object()) returns = dict(c=object()) defaults = dict(a=43) d = dict(description=description, takes=takes, returns=returns, defaults=defaults) m = Method.from_dict(name, d) self.assertEqual(mock_mapmeta.from_dict.call_args_list, [ call("takes", takes), call("returns", returns)]) self.assertEqual(m.name, name) self.assertEqual(m.takes, mock_mapmeta.from_dict.return_value) self.assertEqual(m.returns, mock_mapmeta.from_dict.return_value) self.assertEqual(m.defaults, defaults)
def test_from_dict_deserialize(self, mock_mapmeta): name = "foo" description = "dummy description" takes = dict(a=object(), b=object()) returns = dict(c=object()) defaults = dict(a=43) d = dict(description=description, takes=takes, returns=returns, defaults=defaults) m = Method.from_dict(name, d) self.assertEqual(mock_mapmeta.from_dict.call_args_list, [call("takes", takes), call("returns", returns)]) self.assertEqual(m.name, name) self.assertEqual(m.takes, mock_mapmeta.from_dict.return_value) self.assertEqual(m.returns, mock_mapmeta.from_dict.return_value) self.assertEqual(m.defaults, defaults)