kopia lustrzana https://github.com/OpenDroneMap/WebODM
Fixed tests
rodzic
d6f0f47a0a
commit
f3b761e46d
|
@ -73,6 +73,10 @@ class GrassContext:
|
|||
|
||||
script = os.path.abspath(script)
|
||||
|
||||
# Make sure working directory exists
|
||||
if not os.path.exists(self.get_cwd()):
|
||||
os.mkdir(self.get_cwd())
|
||||
|
||||
# Create param list
|
||||
params = ["{}={}".format(opt,value) for opt,value in self.script_opts.items()]
|
||||
|
||||
|
@ -99,9 +103,8 @@ class GrassContext:
|
|||
}
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
# if os.path.exists(self.get_cwd()):
|
||||
# shutil.rmtree(self.get_cwd())
|
||||
if os.path.exists(self.get_cwd()):
|
||||
shutil.rmtree(self.get_cwd())
|
||||
|
||||
def __del__(self):
|
||||
if self.auto_cleanup:
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# test: Geospatial test file
|
||||
# ------
|
||||
# output: greets the user and prints the information of a spatial file
|
||||
|
||||
v.in.ogr input=${test} layer=test output=test --overwrite
|
||||
v.info map=test
|
|
@ -0,0 +1,25 @@
|
|||
#%module
|
||||
#% description: greets the user and prints the information of a spatial file
|
||||
#%end
|
||||
#%option
|
||||
#% key: test
|
||||
#% type: string
|
||||
#% required: yes
|
||||
#% multiple: no
|
||||
#% description: Geospatial test file
|
||||
#%end
|
||||
|
||||
import sys
|
||||
from grass.pygrass.modules import Module
|
||||
import grass.script as grass
|
||||
|
||||
def main():
|
||||
# Import raster and vector
|
||||
Module("v.in.ogr", input=opts['test'], layer="test", output="test", overwrite=True)
|
||||
info = grass.vector_info("test")
|
||||
print("Number of points: %s" % info['points'])
|
||||
|
||||
if __name__ == "__main__":
|
||||
opts, _ = grass.parser()
|
||||
sys.exit(main())
|
||||
|
|
@ -149,10 +149,11 @@ class TestPlugins(BootTestCase):
|
|||
ctx.set_location("EPSG:4326")
|
||||
|
||||
result = execute_grass_script.delay(
|
||||
os.path.join(grass_scripts_dir, "simple_test.grass"),
|
||||
os.path.join(grass_scripts_dir, "simple_test.py"),
|
||||
ctx.serialize()
|
||||
).get()
|
||||
self.assertTrue("Number of points: 1" in result.get('output'))
|
||||
|
||||
self.assertEqual("Number of points: 1", result.get('output'))
|
||||
|
||||
self.assertTrue(result.get('context') == ctx.serialize())
|
||||
|
||||
|
@ -160,24 +161,24 @@ class TestPlugins(BootTestCase):
|
|||
self.assertFalse(os.path.exists(ctx.get_cwd()))
|
||||
|
||||
error = execute_grass_script.delay(
|
||||
os.path.join(grass_scripts_dir, "nonexistant_script.grass"),
|
||||
os.path.join(grass_scripts_dir, "nonexistant_script.py"),
|
||||
ctx.serialize()
|
||||
).get()
|
||||
self.assertIsInstance(error, dict)
|
||||
self.assertIsInstance(error['error'], str)
|
||||
|
||||
with self.assertRaises(GrassEngineException):
|
||||
ctx.execute(os.path.join(grass_scripts_dir, "nonexistant_script.grass"))
|
||||
ctx.execute(os.path.join(grass_scripts_dir, "nonexistant_script.py"))
|
||||
|
||||
ctx = grass.create_context({"auto_cleanup": False})
|
||||
ctx.add_file('test.geojson', points)
|
||||
ctx.set_location("EPSG:4326")
|
||||
|
||||
result = execute_grass_script.delay(
|
||||
os.path.join(grass_scripts_dir, "simple_test.grass"),
|
||||
os.path.join(grass_scripts_dir, "simple_test.py"),
|
||||
ctx.serialize()
|
||||
).get()
|
||||
self.assertTrue("Number of points: 1" in result.get('output'))
|
||||
self.assertEqual("Number of points: 1", result.get('output'))
|
||||
|
||||
# Path still there
|
||||
self.assertTrue(os.path.exists(ctx.get_cwd()))
|
||||
|
|
Ładowanie…
Reference in New Issue