def test_not_implemented(self): # Arrange p = hm.Projection() coords = 0 # Act / Assert with self.assertRaisesRegex(NotImplementedError, ""): p.project(coords) with self.assertRaisesRegex(NotImplementedError, ""): p.inverse_project(coords)
def test_units(self): '''Test projection units.''' p = hm.Projection() p.pixels_per_degree = 2 self.assertAlmostEqual(p.pixels_per_degree, 2.0) self.assertAlmostEqual(p.meters_per_pixel, 55659.7453966) p.meters_per_pixel = 500 self.assertAlmostEqual(p.pixels_per_degree, 222.63898158654) self.assertAlmostEqual(p.meters_per_pixel, 500)
def test_no_pixels_per_degree(self): # Arrange p = hm.Projection() # Act scaled = p.is_scaled() # Assert self.assertFalse(scaled) with self.assertRaisesRegex(AttributeError, "projection scale was never set"): p.get_pixels_per_degree()
def test_has_pixels_per_degree(self): # Arrange p = hm.Projection() p.pixels_per_degree = 2 # Act scaled = p.is_scaled() ppd = p.get_pixels_per_degree() # Assert self.assertTrue(scaled) self.assertEqual(ppd, 2)