예제 #1
0
 def test_recursive_to_str(self):
     now = datetime.now()
     objid = ObjectId()
     number = 10
     self.check_value_type(es.to_str(self.record))
     self.check_value_type(es.to_str(self.values))
     self.check_value_type(es.to_str(now))
     self.check_value_type(es.to_str(objid))
     self.check_value_type(es.to_str(number))
예제 #2
0
 def test_recursive_to_str(self):
     now = datetime.now()
     objid = ObjectId()
     number = 10
     self.check_value_type(es.to_str(self.record))
     self.check_value_type(es.to_str(self.values))
     self.check_value_type(es.to_str(now))
     self.check_value_type(es.to_str(objid))
     self.check_value_type(es.to_str(number))
예제 #3
0
    def to_str(cls, values, callback=None):
        """Convert many records's values to str
        """
        if callback and callable(callback):
            if isinstance(values, dict):
                return callback(_es.to_str(values))

            return [callback(_es.to_str(i)) for i in values]
        return _es.to_str(values)
예제 #4
0
    def to_str(cls, values, callback=None):
        """Convert many records's values to str
        """
        if callback and callable(callback):
            if isinstance(values, dict):
                return callback(_es.to_str(values))

            return [callback(_es.to_str(i)) for i in values]
        return _es.to_str(values)
예제 #5
0
    def to_str(cls, values, callback=None):
        """string化的多个record组成的list对象
        """
        if callback and callable(callback):
            if isinstance(values, dict):
                return callback(_es.to_str(values))

            return [callback(_es.to_str(i)) for i in values]
            
        return _es.to_str(values)
예제 #6
0
 def test_to_str(self):
     data = {
         'v1': 10,
         'v2': datetime.datetime.now(),
         'v3': ObjectId(),
         'v4': 'value',
     }
     
     self.assertTrue(isinstance(json.dumps(escape.to_str([deepcopy(data) for i in range(10)])), basestring))
     self.assertTrue(isinstance(json.dumps(escape.to_str(deepcopy(data))), basestring))
예제 #7
0
파일: model.py 프로젝트: spawn3/app-turbo
    def to_str(cls, values, callback=None):
        """string化的多个record组成的list对象
        """
        if callback and callable(callback):
            if isinstance(values, dict):
                return callback(_es.to_str(values))

            return [callback(_es.to_str(i)) for i in values]
            
        return _es.to_str(values)
예제 #8
0
    def test_json_decode(self):
        self.assertTrue(type(es.json_decode(
            es.json_encode(es.to_str(self.values), indent=4)
        )).__name__ == 'list'
        )

        # error test
        self.assertTrue(type(es.json_decode(
            es.json_encode(es.to_str(self.values), invlaid=4)
        )).__name__ == 'NoneType'
        )
예제 #9
0
    def test_to_str(self):
        data = {
            'v1': 10,
            'v2': datetime.datetime.now(),
            'v3': ObjectId(),
            'v4': 'value',
        }

        self.assertTrue(isinstance(json.dumps(escape.to_str(
            [deepcopy(data) for i in range(10)])), basestring))
        self.assertTrue(isinstance(json.dumps(
            escape.to_str(deepcopy(data))), basestring))
예제 #10
0
    def test_json_decode(self):
        self.assertTrue(
            type(
                es.json_decode(es.json_encode(es.to_str(self.values),
                                              indent=4))).__name__ == 'list')

        # error test
        self.assertTrue(
            type(
                es.json_decode(
                    es.json_encode(es.to_str(self.values),
                                   invlaid=4))).__name__ == 'NoneType')
예제 #11
0
    def test_to_str_encode(self):
        data = {
            'v1': 10,
            'v2': datetime.datetime.now(),
            'v3': ObjectId(),
            'v4': 'value',
        }

        v = escape.to_str(data)

        self.assertTrue(isinstance(v['v1'], int))
        self.assertTrue(isinstance(v['v2'], float))
        self.assertTrue(isinstance(v['v3'], basestring_type))
        self.assertTrue(isinstance(v['v4'], basestring_type))

        def encode(v):
            return str(v)

        v = escape.to_str(data, encode)
        self.assertTrue(isinstance(v['v1'], basestring_type))
        self.assertTrue(isinstance(v['v2'], basestring_type))
        self.assertTrue(isinstance(v['v3'], basestring_type))
        self.assertTrue(isinstance(v['v4'], basestring_type))
예제 #12
0
    def test_to_str_encode(self):
        data = {
            'v1': 10,
            'v2': datetime.datetime.now(),
            'v3': ObjectId(),
            'v4': 'value',
        }

        v = escape.to_str(data)

        self.assertTrue(isinstance(v['v1'], int))
        self.assertTrue(isinstance(v['v2'], float))
        self.assertTrue(isinstance(v['v3'], basestring_type))
        self.assertTrue(isinstance(v['v4'], basestring_type))

        def encode(v):
            return str(v)

        v = escape.to_str(data, encode)
        self.assertTrue(isinstance(v['v1'], basestring_type))
        self.assertTrue(isinstance(v['v2'], basestring_type))
        self.assertTrue(isinstance(v['v3'], basestring_type))
        self.assertTrue(isinstance(v['v4'], basestring_type))
예제 #13
0
 def to_str(v):
     return _es.to_str(v)
예제 #14
0
 def to_str(v):
     """Convert value into string
     """
     return _es.to_str(v)
예제 #15
0
파일: app.py 프로젝트: intfrr/app-turbo
 def to_str(v):
     return _es.to_str(v)
예제 #16
0
 def test_json_encode(self):
     self.assertTrue(
         es.json_encode(es.to_str(self.values), indent=4) is not None)
예제 #17
0
파일: app.py 프로젝트: ESSL-CQQ/app-turbo
 def to_str(v):
     """Convert value into string
     """
     return _es.to_str(v)
예제 #18
0
 def test_json_encode(self):
     self.assertTrue(es.json_encode(
         es.to_str(self.values), indent=4) is not None)