def tearDown(self): call_module( "g.remove", flags="f", type_="raster", name=[self.average, self.count, self.median, self.sum_], )
def setUpClass(cls): cls.use_temp_region() call_module('g.region', n=20, s=10, e=25, w=15, res=1) cls.elevation = 'fractal_surf' cls.runModule('r.in.ascii', input='data/fractal_surf.ascii', output=cls.elevation)
def setUpClass(cls): cls.use_temp_region() call_module("g.region", n=20, s=10, e=25, w=15, res=1) cls.elevation = "fractal_surf" cls.runModule("r.in.ascii", input="data/fractal_surf.ascii", output=cls.elevation)
def tearDownClass(cls): cls.del_temp_region() call_module( 'g.remove', flags='f', type_='raster', name=[cls.t_aspect, cls.t_slope, cls.s_slope, cls.s_aspect])
def tearDownClass(self): self.del_temp_region() call_module( "g.remove", flags="f", type_="raster", name=self.sum_mapcalc, )
def tearDown(self): self.del_temp_region() call_module( "g.remove", flags="f", type_="raster", name=[self.slope, self.aspect, self.elevation], )
def tearDownClass(cls): cls.del_temp_region() call_module( "g.remove", flags="f", type_="raster", name=[cls.t_aspect, cls.t_slope, cls.s_slope, cls.s_aspect], )
def tearDown(self): self.del_temp_region() call_module( "g.remove", flags="f", type_="raster", name=[self.base, self.cover], )
def test_area_attrs_to_3d_points(self): """Check that values are uploaded to 3D points in areas (dmax=0)""" call_module('v.distance', from_=self.points_3d, to=self.areas, dmax=0, upload='to_attr', column='area_label', to_column='label') table = call_module('v.db.select', map=self.points_3d, separator='pipe', flags='c') self.assertMultiLineEqual(table, table_ref)
def test_location_exists(self): """Test that different parameter combinations work and return true""" db_path = call_module("g.gisenv", get="GISDBASE").strip() loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip() self.assertTrue(location_exists(db_path, loc_name)) self.assertTrue(location_exists(os.path.join(db_path, loc_name))) self.assertTrue(location_exists(Path(db_path), loc_name)) self.assertTrue(location_exists(Path(db_path) / loc_name))
def test_get_list_of_locations(self): """Test that different parameter combinations work and return true""" db_path = call_module("g.gisenv", get="GISDBASE").strip() current_loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip() list_of_locations = get_list_of_locations(db_path) self.assertTrue(list_of_locations, msg="No locations in the current db found") self.assertIn(current_loc_name, list_of_locations)
def test_default_mapset_with_path(self): """Check that default mapset is found for path. This requires the location (with default mapset) to exists. """ db_path = call_module("g.gisenv", get="GISDBASE").strip() loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip() mapset_path = resolve_mapset_path(path=Path(db_path) / loc_name) self.assertEqual(mapset_path.mapset, "PERMANENT")
def test_default_mapset_exists(self): """Check that default mapset is found for real path/location. The location (or mapset) may not exist, but exist in the test. """ db_path = call_module("g.gisenv", get="GISDBASE").strip() loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip() mapset_path = resolve_mapset_path(path=db_path, location=loc_name) self.assertEqual(mapset_path.mapset, "PERMANENT")
def test_area_attrs_to_2d_points(self): """Check that values are uploaded to 2D points in areas (dmax=0)""" # using call_module because PyGRASS doen't accept form_ call_module('v.distance', from_=self.points, to=self.areas, dmax=0, upload='to_attr', column='area_label', to_column='label') # using call_module because it is easier table = call_module('v.db.select', map=self.points, separator='pipe', flags='c') self.assertMultiLineEqual(table, table_ref)
def test_band_ref_assign(self): # copy raster map to the current mapset call_module('g.copy', raster='{m}@PERMANENT,{m}'.format(m=self.raster_map)) module = SimpleModule('i.band', map=self.raster_map, band=self.band_ref) self.assertModule(module) # check also using pygrass self.assertEqual(self.read_band_ref(), self.band_ref)
def test_valid_mapset(self): """Test that different parameter combinations work and return true""" db_path = call_module("g.gisenv", get="GISDBASE").strip() loc_name = call_module("g.gisenv", get="LOCATION_NAME").strip() mapset_name = call_module("g.gisenv", get="MAPSET").strip() self.assertTrue(is_mapset_valid(db_path, loc_name, mapset_name)) self.assertTrue( is_mapset_valid(os.path.join(db_path, loc_name, mapset_name))) self.assertTrue(is_mapset_valid(Path(db_path), loc_name, mapset_name)) self.assertTrue(is_mapset_valid( Path(db_path) / loc_name / mapset_name))
def test_small(self): elevation = 'small_elevation' slope = 'small_slope' aspect = 'small_aspect' self.runModule('r.in.ascii', input='-', output=elevation, stdin_=SMALL_MAP) call_module('g.region', rast=elevation) self.assertModule('r.slope.aspect', elevation=elevation, slope=slope, aspect=aspect) self.assertRasterMinMax(map=slope, refmin=0, refmax=90, msg="Slope in degrees must be between 0 and 90") self.assertRasterMinMax(map=aspect, refmin=0, refmax=360, msg="Aspect in degrees must be between 0 and 360")
def test_area_attrs_to_3d_points(self): """Check that values are uploaded to 3D points in areas (dmax=0)""" call_module( "v.distance", from_=self.points_3d, to=self.areas, dmax=0, upload="to_attr", column="area_label", to_column="label", ) table = call_module("v.db.select", map=self.points_3d, separator="pipe", flags="c") self.assertMultiLineEqual(table, table_ref)
def test_no_output(self): output = call_module('m.proj', flags='i', input='-', stdin="50.0 41.5", capture_stdout=False) self.assertIsNone(output)
def test_no_output(self): output = call_module("m.proj", flags="i", input="-", stdin="50.0 41.5", capture_stdout=False) self.assertIsNone(output)
def test_merge_stderr(self): output = call_module('m.proj', flags='i', input='-', stdin="50.0 41.5", verbose=True, merge_stderr=True) self.assertLooksLike(output, '...+proj=longlat +datum=WGS84...') self.assertLooksLike(output, '...|...\n')
def test_area_attrs_to_2d_points(self): """Check that values are uploaded to 2D points in areas (dmax=0)""" # using call_module because PyGRASS doen't accept form_ call_module( "v.distance", from_=self.points, to=self.areas, dmax=0, upload="to_attr", column="area_label", to_column="label", ) # using call_module because it is easier table = call_module("v.db.select", map=self.points, separator="pipe", flags="c") self.assertMultiLineEqual(table, table_ref)
def test_small(self): self.runModule("r.in.ascii", input="-", output=self.elevation, stdin_=SMALL_MAP) call_module("g.region", raster=self.elevation) self.assertModule( "r.slope.aspect", elevation=self.elevation, slope=self.slope, aspect=self.aspect, ) self.assertModule( "r.slope.aspect", elevation=self.elevation, slope=self.slope_threaded, aspect=self.aspect_threaded, nprocs=8, ) self.assertRasterMinMax( map=self.slope, refmin=0, refmax=90, msg="Slope in degrees must be between 0 and 90", ) self.assertRasterMinMax( map=self.slope_threaded, refmin=0, refmax=90, msg="Slope in degrees must be between 0 and 90", ) self.assertRasterMinMax( map=self.aspect, refmin=0, refmax=360, msg="Aspect in degrees must be between 0 and 360", ) self.assertRasterMinMax( map=self.aspect_threaded, refmin=0, refmax=360, msg="Aspect in degrees must be between 0 and 360", )
def test_small(self): self.runModule('r.in.ascii', input='-', output=self.elevation, stdin_=SMALL_MAP) call_module('g.region', raster=self.elevation) self.assertModule('r.slope.aspect', elevation=self.elevation, slope=self.slope, aspect=self.aspect) self.assertRasterMinMax( map=self.slope, refmin=0, refmax=90, msg="Slope in degrees must be between 0 and 90") self.assertRasterMinMax( map=self.aspect, refmin=0, refmax=360, msg="Aspect in degrees must be between 0 and 360")
def test_merge_stderr(self): output = call_module( "m.proj", flags="i", input="-", stdin="50.0 41.5", verbose=True, merge_stderr=True, ) self.assertLooksLike(output, "...+proj=longlat +datum=WGS84...") self.assertLooksLike(output, "...|...\n")
def setUpClass(cls): cls.use_temp_region() call_module('g.region', rast='elevation')
def setUp(self): self.use_temp_region() call_module("g.region", raster="elevation")
def setUpClass(cls): """Ensures expected computational region""" # to not override mapset's region (which might be used by other tests) cls.use_temp_region() call_module('r.in.ascii', input=cls.grnd_conductivity_file, output=cls.grnd_conductivity, overwrite=True) call_module('r.in.ascii', input=cls.norm_time_hs_ref_file, output=cls.norm_time_hs_ref, overwrite=True) call_module('r.in.ascii', input=cls.norm_time_lt_ref_file, output=cls.norm_time_lt_ref, overwrite=True) call_module('r.in.ascii', input=cls.gmax_ref_file, output=cls.gmax_ref, overwrite=True) call_module('r.in.ascii', input=cls.power_ref_file, output=cls.power_ref, overwrite=True) call_module('r.in.ascii', input=cls.energy_ref_file, output=cls.energy_ref, overwrite=True) call_module('g.region', raster=cls.grnd_conductivity)
def setUpClass(cls): cls.use_temp_region() call_module("g.region", raster=cls.elevation) call_module("r.mapcalc", expression=f"{cls.sum_mapcalc} = {cls.elevation} * 4")
def test_input_output(self): output = call_module('m.proj', flags='i', input='-', stdin="50.0 41.5") self.assertLooksLike(output, '...|...\n')
def test_dir_contains_location(self): """Test that different parameter combinations work and return true""" db_path = call_module("g.gisenv", get="GISDBASE").strip() self.assertTrue(dir_contains_location(db_path)) self.assertTrue(dir_contains_location(Path(db_path)))
def test_output(self): output = call_module('g.region', flags='pg') self.assertLooksLike(output, G_REGION_OUTPUT)