def test_flatten_int(self):

        dict = {'int': 1}

        d = SyndicationModularInput.flatten(dict)

        self.assertEquals(len(d), 1)
        self.assertEquals(d['int'], 1)
    def test_flatten_none(self):

        dict = {'none': None}

        d = SyndicationModularInput.flatten(dict)

        self.assertEquals(len(d), 1)
        self.assertEquals(d['none'], None)
    def test_flatten_dict(self):

        dict = {'list': {'one': 'uno', 'two': 'dos'}}

        d = SyndicationModularInput.flatten(dict)

        self.assertEquals(len(d), 2)
        self.assertEquals(d['list.one'], 'uno')
    def test_flatten_time(self):

        t = time.strptime("9 Feb 15", "%d %b %y")

        dict = {'time': t}

        d = SyndicationModularInput.flatten(dict)

        self.assertEquals(d['time'], '2015-02-09T00:00:00Z')
    def test_flatten_boolean(self):

        dict = {'TrueDat': True, 'FalseDat': False}

        d = SyndicationModularInput.flatten(dict)

        self.assertEquals(len(d), 2)
        self.assertEquals(d['TrueDat'], True)
        self.assertEquals(d['FalseDat'], False)
    def test_flatten_list(self):

        dict = {'list': ['first', 'second']}

        d = SyndicationModularInput.flatten(dict)

        self.assertEquals(len(d), 2)
        self.assertEquals(d['list.0'], 'first')
        self.assertEquals(d['list.1'], 'second')
Ejemplo n.º 7
0
    def test_flatten_dict_sort(self):
        # https://lukemurphey.net/issues/2039
        d = {
                'list': {
                         '3' : 'tres',
                         '1' : 'uno',
                         '2' : 'dos',
                         '5' : 'cinco',
                         '4' : 'cuatro',
                         '6' : 'seis'
                         }
                }
        
        d = SyndicationModularInput.flatten(d, sort=True)
        
        self.assertEquals(len(d), 6)

        keys = list(d.keys())
        self.assertEquals(keys[0], 'list.1')
        self.assertEquals(keys[1], 'list.2')
        self.assertEquals(keys[2], 'list.3')
        self.assertEquals(keys[3], 'list.4')
        self.assertEquals(keys[4], 'list.5')
        self.assertEquals(keys[5], 'list.6')