def test_formfields2taskargs(self, gps_count):
        gps_count.return_value = 1000
        task = GpsVisDB()

        trackers = [{'id': 1, 'color': 'DADADA',
                     'size': 'small', 'speed': 1}]
        formquery = {'trackers': trackers,
                     'start': '2013-01-01T00:00:00',
                     'end': '2013-10-10T00:00:00',
                     'alt': 'clampToGround',
                     }

        taskargs = task.formfields2taskargs(formquery,
                                            'postgresql://localhost')

        etrackers = [{'id': 1, 'color': 12,
                      'size': 'small', 'speed': 1}]
        etaskargs = {'db_url': 'postgresql://localhost',
                     'start': '2013-01-01T00:00:00',
                     'end': '2013-10-10T00:00:00',
                     'alt': 'clampToGround',
                     'trackers': etrackers,
                     }

        self.assertEqual(taskargs, etaskargs)
    def test_convert_colors_valids(self):
        task = GpsVisDB()

        colors = {'FFFF50': 1,
                  'F7E8AA': 2,
                  'FFA550': 3,
                  '5A5AFF': 4,
                  'BEFFFF': 5,
                  '8CFF8C': 6,
                  'FF8CFF': 7,
                  'AADD96': 8,
                  'FFD3AA': 9,
                  'C6C699': 10,
                  'E5BFC6': 11,
                  'DADADA': 12,
                  'C6B5C4': 13,
                  'C1D1BF': 14,
                  '000000': 15
                  }
        for (code, index) in colors.iteritems():
            result = task.convert_colors({'id': 1, 'color': code,
                                          'size': 'small', 'speed': 1})
            self.assertEquals(result, index)
    def test_convert_colors_notfound(self):
        task = GpsVisDB()

        with self.assertRaises(ValueError):
            task.convert_colors({'id': 1, 'color': 'blue',
                                 'size': 'small', 'speed': 1})