コード例 #1
0
 def testRdfFormatterHandlesKeyValuePair(self):
     """rdfvalue.KeyValue items need special handling to expand k and v."""
     key = rdf_protodict.DataBlob().SetValue("skynet")
     value = rdf_protodict.DataBlob().SetValue([1997])
     rdf = rdf_protodict.KeyValue(k=key, v=value)
     template = "{k}: {v}"
     hinter = hints.Hinter(template=template)
     expected = "skynet: 1997"
     result = hinter.Render(rdf)
     self.assertEqual(expected, result)
コード例 #2
0
  def testLegacyRDFBoolCanBeDeserialized(self):
    kv = rdf_protodict.KeyValue()
    kv.k.data = b"t"
    kv.v.rdf_value.name = b"RDFBool"
    kv.v.rdf_value.data = b"1"

    sample = rdf_protodict.Dict()
    sample._values[b"t"] = kv

    sample = rdf_protodict.Dict.FromSerializedBytes(sample.SerializeToBytes())
    self.assertIs(sample[b"t"], True)