def test_defaults(self): func = Mock(return_value={"first_out": "test"}) m = Method("test_description", writeable=True) m.set_parent(Mock(), "test_method") s = StringMeta(description='desc') args_meta = MapMeta() args_meta.elements = {"first": s, "second": s} m.set_takes(args_meta) m.set_defaults({"second": "default"}) m.set_function(func) self.assertEquals({"first_out": "test"}, m.call_function(dict(first="test"))) call_arg = func.call_args[0][0] self.assertEqual("test", call_arg.first) self.assertEqual("default", call_arg.second) self.assertEqual(args_meta, call_arg.meta)
def test_to_dict(self): m = Method("test_description") m.set_takes(self.takes) m.set_defaults(self.serialized["defaults"]) self.assertEqual(m.to_dict(), self.serialized)