コード例 #1
0
    def test_params(self):
        try:
            from component_params import input_files, input_params, output_files, return_value
        except:
            self.assertEqual(True, False, 'Please complete the params file')
        try:
            import component_ui
        except:
            #cannot run this test if running in unittest mode as ui isn't available
            self.assertEqual(True, True, '')
            return

        arg_act = defaultdict(tuple)
        for val in component_ui.parser._actions[1:]:
            arg_act[val.dest] = (val.required, val.default)
            if val.required == None:
                self.assertEqual(
                    val.default, None, 'The optional argument: ' + val.dest +
                    ' has no default value')

        #merge all the dictionaries together
        params_dict = dict(input_files.items() + input_params.items() +
                           output_files.items())

        for dest, (req, default) in arg_act.iteritems():
            if req == True:
                self.assertEqual(params_dict[dest], '__REQUIRED__',
                                 'params and ui dont match')
            else:
                if not params_dict[dest] in [default, '__OPTIONAL__']:
                    self.assertEqual(True, False, 'Please ensure that either default or ' +\
                                     '__OPTIONAL__ flag is provided for: '+params_dict[dest])
コード例 #2
0
 def test_params(self):
     try:
         from component_params import input_files,input_params,output_files,return_value
     except:
         self.assertEqual(True,False,'Please complete the params file')
     try:
         import component_ui   
     except:
         #cannot run this test if running in unittest mode as ui isn't available
         self.assertEqual(True, True, '') 
         return
         
     arg_act = defaultdict(tuple)
     for val in component_ui.parser._actions[1:]:
         arg_act[val.dest] = (val.required,val.default)
         if val.required == None:
             self.assertEqual(val.default, None, 'The optional argument: '+ val.dest+' has no default value')
     
     #merge all the dictionaries together
     params_dict = dict(input_files.items() + input_params.items() + output_files.items())
     
     for dest,(req,default) in arg_act.iteritems():
         if req == True:
             self.assertEqual(params_dict[dest], '__REQUIRED__', 'params and ui dont match')
         else:
             if not params_dict[dest] in [default,'__OPTIONAL__', '__FLAG__']:
                 self.assertEqual(True, False, 'Please ensure that either default or ' +\
                                  '__OPTIONAL__ flag is provided for: '+dest)