Ejemplo n.º 1
0
    def setUp(self):

        self.dm = Mapper([{
            'id': 1,
            'active': True,
            'name': 'Steve',
            'others': {
                'age': 41,
                'childs': {
                    'year': 1991
                }
            },
        }, {
            'id': 2,
            'active': False,
            'name': 'Peter',
            'others': {
                'age': 31,
                'childs': [{
                    'year': 1999
                }, {
                    'year': 1992
                }]
            },
        }, {
            'id': 3,
            'active': True,
            'name': 'Bruce',
            'others': {
                'age': 45,
                'childs': [{
                    'year': 1987
                }, {
                    'year': 1987
                }]
            },
        }])

        self.dict_dm = Mapper({
            'id': 1,
            'name': 'Steve',
            'others': {
                'age': 41,
                'childs': {
                    'year': 1991
                }
            },
        })
Ejemplo n.º 2
0
    def setUp(self):

        self.dm = Mapper(
            {
                'first': {
                    'of': {
                        'all': 'with-string',
                        'with': ['first-item', 'middle-item', 'last-item']
                    },
                    'and': [(0, 1), (1, 2), (2, 3), (3, 4)]
                },
                'filtered': [{
                    'name': 'first',
                    'value': 'good'
                }, {
                    'name': 'second',
                    'value': 'normal'
                }, {
                    'name': 'third',
                    'value': 'bad'
                }],
                'emptylist': {
                    'item': 'itemname'
                },
                'notemptylist': [{
                    'item': 'itemname'
                }, {
                    'item': 'seconditemname'
                }],
                'strvalue':
                'many',
                'strlist': ['many', 'list', 'item'],
                'root':
                'R',
                u'útvonal': {
                    u'árvíztűrőtükörfórógép': 4
                }
            },
            routes={
                'first_of_list': 'first/of/with/0',
                'last_of_list': 'first/of/with/-1',
                'tuple_last_first': 'first/and/-1/0',
                'not_existing_route': 'first/of/here',
                'root': 'root',
                'existing_route': 'first/of/all',
                'filtered_list': 'filtered/name=second/value',
                'attributes_from_list': 'filtered/*/value',
                'whole_list_with_star': 'filtered/*',
                'whole_list_wo_star': 'filtered',
                'range_of_list': 'filtered/0:-1/value',
                'attribute_from_dict_via_expected_list': 'emptylist/~0/item',
                'attribute_from_list': 'notemptylist/~0/item',
                'string_value': 'strvalue',
                'string_to_list': 'strvalue/!/0',
                'string_to_list_check_length': 'strvalue/!/1',
                'first_attribute_from_list': 'strlist/!/0',
                'next_attribute_from_list': 'strlist/!/1',
                'accent_path': u'útvonal/árvíztűrőtükörfórógép'
            })
Ejemplo n.º 3
0
    def setUp(self):

        self.inner_test_object = TestObject(attr='anything')
        self.test_object = TestObject(
            string='item',
            list=['first-item', 'middle', 'last-item'],
            object=self.inner_test_object)
        self.dm = Mapper(self.test_object)
Ejemplo n.º 4
0
    def setUp(self):

        self.test_object = TestObject(attr='anything')
        self.dm = Mapper({
            'string': 'item',
            'list': ['first-item', 'middle', 'last-item'],
            'object': self.test_object,
            'multi-level': {
                'existing-node': True
            }
        })
Ejemplo n.º 5
0
    def getValues(self, obj, base=None):

        ret_dict = Mapper(obj, routes=self.normal_rules).getRoutes()
        ret_dict.update(Mapper(base, routes=self.base_rules).getRoutes())

        return ret_dict
Ejemplo n.º 6
0
    def setUp(self):

        self.dm = Mapper(['first-item', 'middle', 'last-item'])
Ejemplo n.º 7
0
    def setUp(self):

        self.dm = Mapper('anything')
Ejemplo n.º 8
0
    def setUp(self):

        self.dm = Mapper(None)