From 2ad8ea537a33b1d49478000f6f6824abeeea95be Mon Sep 17 00:00:00 2001
From: Anne Philipp <anne.philipp@univie.ac.at>
Date: Fri, 31 Aug 2018 16:32:09 +0200
Subject: [PATCH] added a test for function get_cmdline_arguments

---
 python/pythontest/TestTools.py | 44 ++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/python/pythontest/TestTools.py b/python/pythontest/TestTools.py
index f611a52..6780a55 100644
--- a/python/pythontest/TestTools.py
+++ b/python/pythontest/TestTools.py
@@ -8,7 +8,8 @@ import pytest
 
 sys.path.append('../')
 import _config
-from tools import init128, to_param_id, my_error, read_ecenv
+from tools import (init128, to_param_id, my_error, read_ecenv,
+                   get_cmdline_arguments)
 
 
 class TestTools():
@@ -19,7 +20,44 @@ class TestTools():
         pass
 
     def test_get_cmdline_arguments(self):
-        assert True
+        '''
+        '''
+        cmd_dict_control = {'start_date':'20180101',
+                            'end_date':'20180101',
+                            'date_chunk':'3',
+                            'basetime':'12',
+                            'step':'1',
+                            'levelist':'1/to/10',
+                            'area':'50/10/60/20',
+                            'inputdir':'../work',
+                            'outputdir':'../work',
+                            'flexpart_root_scripts':'../',
+                            'ppid':'1234',
+                            'job_template':'job.sh',
+                            'queue':'ecgate',
+                            'controlfile':'CONTROL.WORK',
+                            'debug':'1'}
+
+        sys.argv = ['dummy.py',
+                    '--start_date=20180101',
+                    '--end_date=20180101',
+                    '--date_chunk=3',
+                    '--basetime=12',
+                    '--step=1',
+                    '--levelist=1/to/10',
+                    '--area=50/10/60/20',
+                    '--inputdir=../work',
+                    '--outputdir=../work',
+                    '--flexpart_root_scripts=../',
+                    '--ppid=1234',
+                    '--job_template=job.sh',
+                    '--queue=ecgate',
+                    '--controlfile=CONTROL.WORK',
+                    '--debug=1']
+
+        results = get_cmdline_arguments()
+
+        assert cmd_dict_control == vars(results)
 
     def test_init128(self):
         '''
@@ -30,7 +68,6 @@ class TestTools():
         result = all((k in table128 and table128[k]==v) for k,v in expected.iteritems())
         assert result == True
 
-
     def test_to_param_id(self):
         '''
         '''
@@ -59,7 +96,6 @@ class TestTools():
 
         assert envs_ref == envs
 
-
     def test_clean_up(self):
         assert True
 
-- 
GitLab