コード例 #1
0
 def assertBackAndForth(self, obj):
   """
   Checks that conversion to json and back is idempotent.
   """
   jsonable = thrift2json(obj)
   back = jsonable2thrift(jsonable, type(obj))
   self.assertEquals(obj, back)
コード例 #2
0
ファイル: thrift_util_test.py プロジェクト: maduhu/HDP-hue
 def assertBackAndForth(self, obj):
     """
 Checks that conversion to json and back is idempotent.
 """
     jsonable = thrift2json(obj)
     back = jsonable2thrift(jsonable, type(obj))
     self.assertEquals(obj, back)
コード例 #3
0
    def to_python(self, value):
        if value is None or value == "":
            return self.thrift_class()

        if not isinstance(value, basestring):
            return value

        jsonable = json.loads(value)
        tft = thrift_util.jsonable2thrift(jsonable, self.thrift_class)
        return tft
コード例 #4
0
ファイル: djangothrift.py プロジェクト: cloudera/hue
  def to_python(self, value):
    if value is None or value == "": 
      return self.thrift_class()

    if not isinstance(value, basestring): 
      return value

    jsonable = json.loads(value)
    tft = thrift_util.jsonable2thrift(jsonable, self.thrift_class)
    return tft
コード例 #5
0
 def test_default(self):
   x = jsonable2thrift(dict(), TestManyTypes)
   self.assertEquals(TestManyTypes(a_string_with_default="the_default"), x)
コード例 #6
0
ファイル: thrift_util_test.py プロジェクト: maduhu/HDP-hue
 def test_default(self):
     x = jsonable2thrift(dict(), TestManyTypes)
     self.assertEquals(TestManyTypes(a_string_with_default="the_default"),
                       x)