def test_get_product_parameters(self): """Tests parameter checks for the get_product method.""" cat = catalog.Catalog() with self.assertRaises(ValueError): cat.get_products(None) with self.assertRaises(ValueError): cat.get_products('PROBAV_L3_S10_TOC_333M', fileformat=None)
def test_get_products_error(self, mock_get): """Unit test to test error handling behaviour for retrieval of products.""" with self.assertRaises(HTTPError): cat = catalog.Catalog() cat.get_products('PROBAV_L3_S10_TOC_333M', fileformat='GEOTIFF', startdate=datetime.date(2016, 1, 1), enddate=datetime.date(2016, 1, 2))
def test_get_products_by_daterange(self, mock_get): """Unit test for retrieval of products by date range.""" cat = catalog.Catalog() products = cat.get_products('PROBAV_L3_S10_TOC_333M', fileformat='GEOTIFF', startdate=datetime.date(2016, 1, 1), enddate=datetime.date(2016, 1, 2)) self.assertEquals(len(products), 2) self.assertEquals(products[0].geometry.geom_type, 'Polygon') self.assertEquals(products[0].geometry.exterior.coords[0], (0.0, 65.0)) self.assertEquals(products[0].geometry.exterior.coords[1], (0.0, 55.0)) self.assertEquals(products[0].geometry.exterior.coords[2], (10.0, 55.0)) self.assertEquals(products[0].geometry.exterior.coords[3], (10.0, 65.0)) self.assertEquals(products[0].geometry.exterior.coords[4], (0.0, 65.0)) self.assertIsNone(products[1].geometry)
def test_init_catalog_2(self): """Tests catalog constructor with custom catalog base URL.""" cat = catalog.Catalog('dummy.be') self.assertEqual(cat.baseurl, 'dummy.be')
def test_init_catalog(self): """Tests catalog constructor with default catalog base URL.""" cat = catalog.Catalog() self.assertEqual(cat.baseurl, catalog.CATALOG_BASE_URL)
def test_get_times_error(self, mock_get): """Unit test to test error handling behaviour for retrieval of times.""" with self.assertRaises(HTTPError): cat = catalog.Catalog() cat.get_times('PROBAV_L3_S10_TOC_333M')
def test_get_producttypes_error(self, mock_get): """Unit test to test error handling behaviour for retrieval of producttypes.""" with self.assertRaises(HTTPError): cat = catalog.Catalog() cat.get_producttypes()
def test_get_times(self, mock_get): """Unit test for retrieval of times for a producttype.""" cat = catalog.Catalog() times = cat.get_times('PROBAV_L3_S10_TOC_333M') self.assertEquals(len(times), 116)
def test_get_producttypes(self, mock_get): """Unit test for retrieval of producttypes.""" cat = catalog.Catalog() producttypes = cat.get_producttypes() self.assertEquals(len(producttypes), 49)