cls.runModule("g.remove", flags="f", type="raster", name=cls.elevation) if cls.to_remove: cls.runModule("g.remove", flags="f", type="raster", name=",".join(cls.to_remove)) def test_viewshed(self): ref_viewshed = "reference_viewshed" viewshed = "actual_viewshed" obs_elev = "1.72" self.runModule("r.in.ascii", input="data/lake_viewshed.ascii", output=ref_viewshed) self.to_remove.append(ref_viewshed) self.assertModule( "r.viewshed", input=self.elevation, coordinates=(634720, 216180), output=viewshed, observer_elevation=obs_elev, ) self.to_remove.append(viewshed) # check we have expected values self.assertRasterMinMax(map=viewshed, refmin=0, refmax=180, msg="Viewshed in degrees must be between 0 and 180") # check against reference data self.assertRastersNoDifference(actual=viewshed, reference=ref_viewshed, precision=self.precision) # TODO: add self.assertRasterFitsUnivar() if __name__ == "__main__": test()
text_from_file = open("map_names_file.txt", "r").read() self.assertLooksLike(map_list, text_from_file) class TestGdalImportFails(TestCase): def test_error_handling_1(self): # Wrong number of digits self.assertModuleFail( "r.in.gdal", input="data/elevation.nc", num_digits="-1", output="test_gdal_import_map", ) def test_error_handling_2(self): # No location specified self.assertModuleFail( "r.in.gdal", input="data/elevation.nc", flags="c", output="test_gdal_import_map", ) if __name__ == "__main__": from grass.gunittest.main import test test()