def testComma(self): sel = SimpleModule('v.db.select', flags='c', map=self.invect, where="{col}='{val}'".format(col=self.col, val=self.val), separator=',') sel.run() self.assertLooksLike(reference=out_sep, actual=sel.outputs.stdout)
def testWhere(self): """Testing v.db.select with where option""" sel = SimpleModule('v.db.select', flags='c', map=self.invect, where="{col}='{val}'".format(col=self.col, val=self.val)) sel.run() self.assertLooksLike(reference=out_where, actual=sel.outputs.stdout)
def testComma(self): sel = SimpleModule( "v.db.select", flags="c", map=self.invect, where="{col}='{val}'".format(col=self.col, val=self.val), separator=",", ) sel.run() self.assertLooksLike(reference=out_sep, actual=sel.outputs.stdout)
def testWhere(self): """Testing v.db.select with where option""" sel = SimpleModule( "v.db.select", flags="c", map=self.invect, where="{col}='{val}'".format(col=self.col, val=self.val), ) sel.run() self.assertLooksLike(reference=out_where, actual=sel.outputs.stdout)
def test_raster_what_points_flag_r(self): """Testing r.what runs successfully with flag r""" module = SimpleModule('r.what', map=self.map1, points=self.points, flags='r') module.run() self.assertLooksLike( actual=str(module.outputs.stdout), reference=self.refrence_flag_r, msg="test_raster_what_cats did't run successfully")
def test_raster_what_cats(self): """Testing r.what runs successfully with input coordinates given as a vector points map with cats and flag v""" module = SimpleModule('r.what', map=self.map1, points=self.points, flags='v') module.run() self.assertLooksLike( actual=str(module.outputs.stdout), reference=self.refrence_cats, msg="test_raster_what_cats did't run successfully")
def test_raster_what_coordinates(self): """Testing r.what runs successfully with input coordinates given as an option and with multiple maps""" module = SimpleModule("r.what", map=self.map2, coordinates=self.coordinates) module.run() self.assertLooksLike( actual=str(module.outputs.stdout), reference=self.refrence_coordinates, msg="test_raster_what_coordinates did't run successfully", )
def testBuffering(self): """Test against errors in buffering implementation""" vpro = SimpleModule( "v.profile", input=self.points, separator="comma", dp=3, buffer=500, profile_map=self.in_map, profile_where="cat=193", ) vpro.run()
def test_raster_what_cache(self): """Testing r.what runs successfully with cache""" module = SimpleModule("r.what", map=self.map1, points=self.points, flags="c", cache=500) module.run() self.assertLooksLike( actual=str(module.outputs.stdout), reference=self.refrence_cache, msg="test_raster_what_cats did't run successfully", )
def test_flagw(self): """Testing flag w with map lakes""" output_str = """number of features with non NULL attribute: 15279 number of missing attributes: 0 number of NULL attributes: 0 minimum: 2 maximum: 15280 range: 15278 sum: 5.76349e+11 mean: 6190.76 mean of absolute values: 6190.76""" v_univar = SimpleModule('v.univar', map='lakes', column='FULL_HYDRO', flags='w') v_univar.run() self.assertLooksLike(actual=v_univar.outputs.stdout.encode('utf8'), reference=output_str)
def testJSON(self): import json sel = SimpleModule('v.db.select', flags='j', map=self.invect, where="cat<={cat}".format(cat=self.cat)) sel.run() try: json.loads(sel.outputs.stdout) except ValueError: self.fail(msg="No JSON object could be decoded:\n" + sel.outputs.stdout) self.assertLooksLike(reference=out_json, actual=sel.outputs.stdout)
def is_null_file_compressed(raster): """ Check is NULL file of a raster map is compressed """ module = SimpleModule('r.compress', flags='g' , map=raster) module.run() status = module.outputs.stdout.split('|')[-1] # # Verbosity ------------------------------------------------- # message = "NULL file compression for <{tm}>: ".format(tm=raster) # message += status # print message # # Verbosity ------------------------------------------------- return status
def testRun(self): """Module runs with minimal parameters and give output.""" sel = SimpleModulesel = SimpleModule("g.copy", vector=(self.invect, self.outvect)) sel.run() sel = SimpleModule("v.greedycolors", map=self.outvect) sel.run() sel = SimpleModule( "db.select", sql= "select greedyclr,count(greedyclr) from my_boundary_county group by greedyclr", ) sel.run() self.assertLooksLike(reference=out_greedyclrs, actual=sel.outputs.stdout)
def testJSON(self): """Test that JSON can be decoded and formatted exactly as expected""" import json sel = SimpleModule( "v.db.select", format="json", map=self.invect, where="cat<={cat}".format(cat=self.cat), ) sel.run() try: json.loads(sel.outputs.stdout) except ValueError: self.fail(msg="No JSON object could be decoded:\n" + sel.outputs.stdout) self.assertLooksLike(reference=out_json, actual=sel.outputs.stdout)
def test_flagd(self): """Testing flag d with map hospitals""" univar_string = """number of primitives: 160 number of non zero distances: 12561 number of zero distances: 0 minimum: 9.16773 maximum: 760776 range: 760767 sum: 2.69047e+09 mean: 214193 mean of absolute values: 214193 population standard deviation: 128505 population variance: 1.65136e+10 population coefficient of variation: 0.599953 sample standard deviation: 128511 sample variance: 1.6515e+10 kurtosis: 0.277564 skewness: 0.801646""" v_univar = SimpleModule('v.univar', map='hospitals', column='CITY', flags='d') v_univar.run() self.assertLooksLike(actual=v_univar.outputs.stdout.encode('utf8'), reference=univar_string)
def test_flagg(self): """Testing flag g with map lakes""" output_str = """n=15279 nmissing=0 nnull=0 min=1 max=15279 range=15278 sum=1.16732e+08 mean=7640 mean_abs=7640 population_stddev=4410.67 population_variance=1.9454e+07 population_coeff_variation=0.577312 sample_stddev=4410.81 sample_variance=1.94553e+07 kurtosis=-1.20024 skewness=-2.41826e-14""" v_univar = SimpleModule("v.univar", flags="g", map='lakes', column='cat') v_univar.run() self.assertLooksLike(actual=v_univar.outputs.stdout.encode('utf8'), reference=output_str)
def testOutput(self): """Test correctness of output""" # Normal output vpro = SimpleModule( "v.profile", input=self.in_points, profile_map=self.in_map, buffer=200, profile_where=self.where, ) vpro.run() self.assertLooksLike(reference=output_full, actual=vpro.outputs.stdout) # Without column names vpro = SimpleModule( "v.profile", input=self.in_points, profile_map=self.in_map, buffer=200, profile_where=self.where, c=True, ) vpro.run() self.assertLooksLike(reference=output_nocols, actual=vpro.outputs.stdout) # Filtering input points vpro = SimpleModule( "v.profile", input=self.in_points, profile_map=self.in_map, buffer=200, where="class='Dam'", profile_where=self.where, ) vpro.run() self.assertLooksLike(reference=output_filtered, actual=vpro.outputs.stdout) # Providing profiling line from coordinates vpro = SimpleModule("v.profile", input=self.in_points, coordinates=self.prof_ponts, buffer=200) vpro.run() self.assertLooksLike(reference=output_coords, actual=vpro.outputs.stdout)
def testGroup(self): """Testing v.db.select with group option""" sel = SimpleModule('v.db.select', flags='c', map=self.invect, columns=self.col, group=self.col) sel.run() self.assertLooksLike(reference=out_group, actual=sel.outputs.stdout)