def full_point_test(self): """Check if a point with all constructor options is correctly created""" point = Point(1.0, 2.0, elevation=100.5, name="foo name", summary="bar summary", message="baz message") self.assertEqual(point.lat, 1.0) self.assertEqual(point.lon, 2.0) self.assertEqual(point.elevation, 100.5) # test name, etc. self.assertEqual(point.name, "foo name") self.assertEqual(point.summary, "bar summary") self.assertEqual(point.description, "baz message") # test the tuple getters/setters self.assertEqual(point.getLL(), (1.0, 2.0)) point.setLL(3.0, 4.0) self.assertEqual(point.getLL(), (3.0, 4.0)) self.assertEqual(point.getLLE(), (3.0, 4.0, 100.5)) point.setLLE(5.0, 6.0, 200.5) self.assertEqual(point.getLLE(), (5.0, 6.0, 200.5)) self.assertEqual(point.getLLEM(), (5.0, 6.0, 200.5, "baz message"))
def set_message_point_test(self): """Test replacing message points already added to a Way.""" way = Way() # add some message points point1 = Point(lat=50.0, lon=50.0, elevation=300.0, message="foo") point2 = Point(lat=75.0, lon=75.0, elevation=600.0, message="bar") point3 = Point(lat=100.0, lon=100.0, elevation=1200.0, message="baz") way.add_message_points([point1, point2, point3]) self.assertEqual(way.get_message_point_by_index(0), point1) self.assertEqual(way.get_message_point_by_index(2), point3) # replace some of the points point11 = Point(lat=51.0, lon=51.0, elevation=301.0, message="foo1") point31 = Point(lat=101.0, lon=101.0, elevation=1201.0, message="baz1") way.set_message_point_by_index(0, point11) way.set_message_point_by_index(2, point31) # check the points have been replaced self.assertEqual(way.get_message_point_by_index(0), point11) self.assertEqual(way.get_message_point_by_index(2), point31) # some sanity checks self.assertEqual(way.message_point_count, 3) self.assertListEqual(way.message_points, [point11, point2, point31]) self.assertListEqual( way.message_points_lle, [point11.getLLE(), point2.getLLE(), point31.getLLE()]) lol_point = Point(lat=50.0, lon=50.0, elevation=300, message="lol") with self.assertRaises(IndexError): way.set_message_point_by_index(3, lol_point) with self.assertRaises(IndexError): way.set_message_point_by_index(-100, lol_point) with self.assertRaises(IndexError): way.set_message_point_by_index(100, lol_point)