def testSerialization(self): foo_fighters = self.Foo('1', 2) json_dict = common_util.SerializeAttributesToJsonDict( {}, foo_fighters, ['foo_fighters', 'whisky_bar']) self.assertDictEqual({'foo_fighters': '1', 'whisky_bar': 2}, json_dict) # Partial update json_dict = common_util.SerializeAttributesToJsonDict( {'baz': 42}, foo_fighters, ['whisky_bar']) self.assertDictEqual({'baz': 42, 'whisky_bar': 2}, json_dict) # Non-existing attribute. with self.assertRaises(AttributeError): json_dict = common_util.SerializeAttributesToJsonDict( {}, foo_fighters, ['foo_fighters', 'whisky_bar', 'baz'])
def ToJsonDict(self): return common_util.SerializeAttributesToJsonDict( super(_IndexedNode, self).ToJsonDict(), self, ['index'])
def ToJsonDict(self): """Returns a dict representing this instance.""" result = {'graph': self.graph.ToJsonDict()} return common_util.SerializeAttributesToJsonDict( result, self, ['postload_msec'])
def ToJsonDict(self): result = super(RequestNode, self).ToJsonDict() return common_util.SerializeAttributesToJsonDict( result, self, self._ATTRS)
def ToJsonDict(self): return common_util.SerializeAttributesToJsonDict({}, self, self._ATTRS)
def ToJsonDict(self): return common_util.SerializeAttributesToJsonDict( {}, self, ['from_node', 'to_node', 'cost'])
def ToJsonDict(self): return common_util.SerializeAttributesToJsonDict({}, self, ['cost'])
def ToJsonDict(self): result = {} return common_util.SerializeAttributesToJsonDict( result, self, ['reason', 'cost', 'is_timing'])