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_trackrows2kml_absoluteClampBelowGround(self): self.maxDiff = None kml = simplekml.Kml() task = PyKML() rows = [[355, datetime(2013, 5, 15, 8, 33, 34, tzinfo=UTC), 4.485608, 52.412252, 84, 8.90, 8.91, 14.1, 14.2, 50, ], [355, datetime(2013, 5, 15, 8, 34, 34, tzinfo=UTC), 4.485608, 52.415252, 34, 8.90, 9.91, 14.1, 14.2, 50, ], ] style = {'shape': 'circle', 'size': 'medium', 'sizebyalt': False, 'colorby': 'ispeed', 'speedthresholds': [5, 10, 20], 'alpha': 100, 'altitudemode': 'absoluteClampBelowGround', } tracker = {'id': 355, 'color': {'slowest': '#FFFF50', 'slow': '#FDD017', 'fast': '#C68E17', 'fastest': '#733C00' } } task.trackrows2kml(kml, rows, tracker, style) self.assertKml('absoluteclampbelowground', kml)
def test_trackrows2kml_idirectionnoneispeednone(self): self.maxDiff = None kml = simplekml.Kml() task = PyKML() rows = [[355, datetime(2013, 5, 15, 8, 33, 34, tzinfo=UTC), 4.485608, 52.412252, 84, None, 9.91, None, 14.2, 4.0, ], ] style = {'shape': 'iarrow', 'size': 'medium', 'sizebyalt': False, 'colorby': 'ispeed', 'speedthresholds': [5, 10, 20], 'alpha': 100, 'altitudemode': 'absolute', } tracker = {'id': 355, 'color': {'slowest': '#FFFF50', 'slow': '#FDD017', 'fast': '#C68E17', 'fastest': '#733C00' } } task.trackrows2kml(kml, rows, tracker, style) self.assertKml('directionnone', kml)
def test_trackrows2kml_sizebyaltonsmallsize_iconsizebig(self): kml = simplekml.Kml() task = PyKML() rows = [[355, datetime(2013, 5, 15, 8, 33, 34, tzinfo=UTC), 4.485608, 52.412252, 84, 8.90, 9.91, 14.1, 14.2, 4.0, ], ] style = {'shape': 'circle', 'size': 'small', 'sizebyalt': True, 'colorby': 'ispeed', 'speedthresholds': [5, 10, 20], 'alpha': 100, 'altitudemode': 'absolute', } tracker = {'id': 355, 'color': {'slowest': '#FFFF50', 'slow': '#FDD017', 'fast': '#C68E17', 'fastest': '#733C00' } } task.trackrows2kml(kml, rows, tracker, style) self.assertKml('sizebyaltonsmallsize', kml)
def test_addIcons2kml_circlepngarrowpngadded(self): kml = simplekml.Kml() task = PyKML() path = task.addIcons2kml(kml) self.assertIn('files/arrow.png', path) self.assertIn('files/circle.png', path)
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)