Commit bc632478 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added tests for command line argparser.


Former-commit-id: 2dda12ab
parent f347434a
......@@ -3,6 +3,7 @@ __author__ = 'Daniel Scheffler'
import argparse
import warnings
import os
import matplotlib
......@@ -33,7 +34,12 @@ def run_from_jobid(args):
PC = process_controller(args.jobid, **get_config_kwargs_from_cli_args(args))
# run the job
PC.run_all_processors()
if 'GMS_IS_TEST' in os.environ and os.environ['GMS_IS_TEST'] == 'True':
# in case of software test, it is enough to get an instance of process controller because all inputs are
# validated within options.config.Job_Config (indirectly called by ProcessController.__init__() )
pass
else:
PC.run_all_processors()
def run_from_sceneids(args):
......@@ -97,7 +103,12 @@ def _run_job(dbJob, **config_kwargs):
PC = process_controller(dbJob.id, **config_kwargs)
# run the job
PC.run_all_processors()
if 'GMS_IS_TEST' in os.environ and os.environ['GMS_IS_TEST'] == 'True':
# in case of software test, it is enough to get an instance of process controller because all inputs are
# validated within options.config.Job_Config (indirectly called by ProcessController.__init__() )
pass
else:
PC.run_all_processors()
def get_gms_argparser():
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_cli
--------
Tests for gms_preprocessing.bin.run_gms
"""
import unittest
import os
from gms_preprocessing.misc.helper_functions import subcall_with_output
from gms_preprocessing import __path__
path_run_gms = os.path.abspath(os.path.join(__path__[0], '..', 'bin', 'run_gms.py'))
def exec_call(cmd):
out, exitcode, err = subcall_with_output(' '.join(cmd) if cmd is list else cmd)
if exitcode:
raise Exception(err.decode('latin-1'))
else:
if out:
return out.decode('UTF-8')
class Test_run_jobid(unittest.TestCase):
def setUp(self):
self.base_cmd = 'python %s jobid %d' % (path_run_gms, 26186261) # Landsat8_CollectionData
os.environ['GMS_IS_TEST'] = 'True'
def tearDown(self):
del os.environ['GMS_IS_TEST']
def test_no_kwargs(self):
exec_call(self.base_cmd)
class Test_run_sceneids(unittest.TestCase):
def setUp(self):
self.base_cmd = 'python %s sceneids %d' % (path_run_gms, 32259730) # LC81930292017233LGN00
os.environ['GMS_IS_TEST'] = 'True'
def tearDown(self):
del os.environ['GMS_IS_TEST']
def test_no_kwargs(self):
exec_call(self.base_cmd)
class Test_run_entityids(unittest.TestCase):
def setUp(self):
self.base_cmd = 'python %s entityids %s' % (path_run_gms, 'LC81930292017233LGN00')
os.environ['GMS_IS_TEST'] = 'True'
def tearDown(self):
del os.environ['GMS_IS_TEST']
def test_no_kwargs(self):
exec_call(self.base_cmd)
class Test_run_filenames(unittest.TestCase):
def setUp(self):
self.base_cmd = 'python %s filenames %s' % (path_run_gms, 'LC08_L1TP_193029_20170821_20170911_01_T1.tar.gz')
os.environ['GMS_IS_TEST'] = 'True'
def tearDown(self):
del os.environ['GMS_IS_TEST']
def test_no_kwargs(self):
exec_call(self.base_cmd)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment