def test_formfields2taskargs_wrongshape(self):
        task = PyKML()
        color = {'id': 3,
                 'slowest': '#FFFF50',
                 'slow': '#FDD017',
                 'fast': '#C68E17',
                 'fastest': '#733C00'
                 }
        formfields = {'start': '2013-05-14T10:11:12Z',
                      'end': '2013-05-15T08:33:34Z',
                      'trackers': [{'id': 1234, 'color': color}],
                      # wrong shape
                      'shape': 'square',
                      'size': 'medium',
                      'colorby': 'ispeed',
                      'speedthreshold1': 5,
                      'speedthreshold2': 10,
                      'speedthreshold3': 20,
                      'transparency': 100,
                      'altitudemode': 'absolute',
                      }
        db_url = 'postgresql://localhost/eecology'
        with self.assertRaises(Invalid) as e:
            task.formfields2taskargs(formfields, db_url)

        expected = {'shape': u'"square" is not one of circle, iarrow, tarrow'
                    }
        self.assertEqual(e.exception.asdict(), expected)
    def test_formfields2taskargs_noerrors(self, gpscount):
        gpscount.return_value = 400
        task = PyKML()
        color = {'id': 3,
                 'slowest': '#FFFF50',
                 'slow': '#FDD017',
                 'fast': '#C68E17',
                 'fastest': '#733C00'
                 }
        formfields = {'start': '2013-05-14T10:11:12Z',
                      'end': '2013-05-15T08:33:34Z',
                      'trackers': [{'id': 1234, 'color': color}],
                      'shape': 'circle',
                      'size': 'medium',
                      'colorby': 'ispeed',
                      'speedthreshold1': 5,
                      'speedthreshold2': 10,
                      'speedthreshold3': 20,
                      'transparency': 0,
                      'altitudemode': 'absolute',
                      }
        db_url = 'postgresql://localhost/eecology'
        taskargs = task.formfields2taskargs(formfields, db_url)

        ecolor = {'slowest': '#FFFF50',
                  'slow': '#FDD017',
                  'fast': '#C68E17',
                  'fastest': '#733C00'
                  }
        etaskargs = {'db_url': 'postgresql://localhost/eecology',
                     'start': '2013-05-14T10:11:12Z',
                     'end': '2013-05-15T08:33:34Z',
                     'trackers': [{'id': 1234, 'color': ecolor}],
                     'shape': 'circle',
                     'size': 'medium',
                     'sizebyalt': False,
                     'colorby': 'ispeed',
                     'speedthreshold1': 5,
                     'speedthreshold2': 10,
                     'speedthreshold3': 20,
                     'alpha': 100,
                     'altitudemode': 'absolute',
                     }
        self.assertDictEqual(taskargs, etaskargs)