Пример #1
0
    def remote_widget_render(self):
        print "\n******testing minion : %s**********"%(self.minion)
        fc = Overlord(self.minion)
        modules = fc.system.list_modules()
        display_modules={}

        print "Getting the modules that has exported arguments"
        for module in modules.itervalues():
            for mod in module:
                #if it is not empty
                exported_methods = getattr(fc,mod).get_method_args()[self.minion]
                if exported_methods:
                    print "%s will be rendered"%(mod)
                    display_modules[mod]=exported_methods

        #do the rendering work here
        for module,exp_meths in display_modules.iteritems():
            for method_name,other_options in exp_meths.iteritems():
                minion_arguments = other_options['args']
                if minion_arguments:
                    wlist_object = WidgetListFactory(minion_arguments,minion=self.minion,module=module,method=method_name)
                    wlist_object = wlist_object.get_widgetlist_object()
                    #print wlist_object
                    wf = WidgetSchemaFactory(minion_arguments)
                    schema_man=wf.get_ready_schema()
                    minion_form = RemoteFormAutomation(wlist_object,schema_man)
                    print "%s.%s.%s rendered"%(self.minion,module,method_name)
Пример #2
0
    def test_int_validator(self):
        wf = WidgetSchemaFactory(self.get_int_params())
        schema_man=wf.get_ready_schema()

        for argument_name,arg_options in self.get_int_params().iteritems():
            #print argument_name
            assert getattr(schema_man,'fields').has_key(argument_name)==True
            current_schema_object = getattr(schema_man,'fields')[argument_name]
            #print " ",argument_name," : ",getattr(schema_man,argument_name)

            #if the argument includes some range
            if arg_options.has_key('range'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(current_schema_object,'max') == arg_options['range'][1]
                assert getattr(current_schema_object,'min') == arg_options['range'][0]
            if arg_options.has_key('min'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(current_schema_object,'min') == arg_options['min']

            if arg_options.has_key('max'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(current_schema_object,'max') == arg_options['max']

            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(current_schema_object,'not_empty') == arg_options['optional']


        print "Happy test!"
Пример #3
0
    def test_string_validator(self):
        wf = WidgetSchemaFactory(self.get_string_params())
        schema_man=wf.get_ready_schema()

        conversion_schema = {
                'max_length':'max',
                'min_length':'min',
                'validator':'regex'
                }

        #do better test here
        for argument_name,arg_options in self.get_string_params().iteritems():
            #print getattr(schema_man,'fields')
            assert getattr(schema_man,'fields').has_key(argument_name) == True
            current_schema_object = getattr(schema_man,'fields')[argument_name]
            #not very efficient but it si just a test :)
            if argument_name == 'string_mix':
                continue
            if arg_options.has_key('max_length'):
                assert  getattr(current_schema_object,'max') == arg_options['max_length']
            if arg_options.has_key('min_length'):
                assert  getattr(current_schema_object,'min') == arg_options['min_length']
            if arg_options.has_key('validator'):
                assert getattr(current_schema_object,'regex')
            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(current_schema_object,'not_empty') == arg_options['optional']

        print "Happy tests !"
Пример #4
0
    def method_display(self,minion=None,module=None,method=None):
        
        global global_form
        fc = Overlord(minion)
        method_args = getattr(fc,module).get_method_args()
        
        if not method_args.values():
            print "Not registered method here"
            return dict(minion_form = None,minion=minion,module=module,method=method)

        minion_arguments = method_args[minion][method]['args']
        if minion_arguments:
            wlist_object = WidgetListFactory(minion_arguments,minion=minion,module=module,method=method)
            wlist_object = wlist_object.get_widgetlist_object()
            #create the validation parts for the remote form
            wf = WidgetSchemaFactory(minion_arguments)
            schema_man=wf.get_ready_schema()

            #create the final form
            minion_form = RemoteFormAutomation(wlist_object,schema_man)
            global_form = minion_form.for_widget
            #print global_form
            #i use that when something goes wrong to check the problem better to stay here ;)
            #self.minion_form =RemoteFormFactory(wlist_object,schema_man).get_remote_form()
            
            del wlist_object
            del minion_arguments

            return dict(minion_form =minion_form,minion=minion,module=module,method=method)
        else:
            return dict(minion_form = None,minion=minion,module=module,method=method)
Пример #5
0
    def test_list_validator(self,the_type='list'):
        if the_type == 'list':
            testing_data = self.get_list_params()
        else:
            testing_data = self.get_hash_params()

        wf = WidgetSchemaFactory(testing_data)
        schema_man=wf.get_ready_schema()

        for argument_name,arg_options in testing_data.iteritems():
            #print argument_name
            #should all the argument names really
            #print " ",argument_name," : ",getattr(schema_man,argument_name)
            assert getattr(schema_man,'fields').has_key(argument_name)==True
            current_schema_object = getattr(schema_man,'fields')[argument_name]


            if arg_options.has_key('validator'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(current_schema_object,'regex_string') == arg_options['validator']

            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(current_schema_object,'not_empty') == arg_options['optional']


        print "Happy test!"
Пример #6
0
    def test_string_validator(self):
        wf = WidgetSchemaFactory(self.get_string_params())
        schema_man=wf.get_ready_schema()
        
        conversion_schema = {
                'max_length':'max',
                'min_length':'min',
                'validator':'regex'
                }

        #do better test here
        for argument_name,arg_options in self.get_string_params().iteritems():
            #print argument_name
            assert hasattr(schema_man,argument_name)==True
            #not very efficient but it si just a test :)
            if argument_name != 'string_mix':
                for arg,value in arg_options.iteritems():
                    #print getattr(schema_man,argument_name)
                    if conversion_schema.has_key(arg):
                        if hasattr(getattr(schema_man,argument_name),conversion_schema[arg]):
                            #print arg,value
                            #couldnt find a way to test it !??
                            if arg != 'validator':
                                assert getattr(getattr(schema_man,argument_name),conversion_schema[arg])==value
                                #print getattr(getattr(schema_man,argument_name),conversion_schema[arg])
            else:
                #just print it to see what is inside because the test will be very hardcoded otherwise
                #print getattr(schema_man,argument_name)
                continue
        print "Happy tests !"
Пример #7
0
    def test_string_validator(self):
        wf = WidgetSchemaFactory(self.get_string_params())
        schema_man = wf.get_ready_schema()

        conversion_schema = {
            'max_length': 'max',
            'min_length': 'min',
            'validator': 'regex'
        }

        #do better test here
        for argument_name, arg_options in self.get_string_params().iteritems():
            #print getattr(schema_man,'fields')
            assert getattr(schema_man, 'fields').has_key(argument_name) == True
            current_schema_object = getattr(schema_man,
                                            'fields')[argument_name]
            #not very efficient but it si just a test :)
            if argument_name == 'string_mix':
                continue
            if arg_options.has_key('max_length'):
                assert getattr(current_schema_object,
                               'max') == arg_options['max_length']
            if arg_options.has_key('min_length'):
                assert getattr(current_schema_object,
                               'min') == arg_options['min_length']
            if arg_options.has_key('validator'):
                assert getattr(current_schema_object, 'regex')
            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(current_schema_object,
                                   'not_empty') == arg_options['optional']

        print "Happy tests !"
Пример #8
0
    def test_float_validator(self):
        wf = WidgetSchemaFactory(self.get_float_params())
        schema_man = wf.get_ready_schema()

        for argument_name, arg_options in self.get_float_params().iteritems():
            #print argument_name
            assert getattr(schema_man, 'fields').has_key(argument_name) == True
            current_schema_object = getattr(schema_man,
                                            'fields')[argument_name]
            #print " ",argument_name," : ",getattr(schema_man,argument_name)

            if arg_options.has_key('min'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(current_schema_object,
                               'min') == arg_options['min']

            if arg_options.has_key('max'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(current_schema_object,
                               'max') == arg_options['max']

            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(current_schema_object,
                                   'not_empty') == arg_options['optional']

        print "Happy test!"
Пример #9
0
    def test_list_validator(self, the_type='list'):
        if the_type == 'list':
            testing_data = self.get_list_params()
        else:
            testing_data = self.get_hash_params()

        wf = WidgetSchemaFactory(testing_data)
        schema_man = wf.get_ready_schema()

        for argument_name, arg_options in testing_data.iteritems():
            #print argument_name
            #should all the argument names really
            #print " ",argument_name," : ",getattr(schema_man,argument_name)
            assert getattr(schema_man, 'fields').has_key(argument_name) == True
            current_schema_object = getattr(schema_man,
                                            'fields')[argument_name]

            if arg_options.has_key('validator'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(current_schema_object,
                               'regex_string') == arg_options['validator']

            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(current_schema_object,
                                   'not_empty') == arg_options['optional']

        print "Happy test!"
Пример #10
0
    def remote_widget_render(self):
        print "\n******testing minion : %s**********" % (self.minion)
        fc = Overlord(self.minion)
        modules = fc.system.list_modules()
        display_modules = {}

        print "Getting the modules that has exported arguments"
        for module in modules.itervalues():
            for mod in module:
                #if it is not empty
                exported_methods = getattr(fc,
                                           mod).get_method_args()[self.minion]
                if exported_methods:
                    print "%s will be rendered" % (mod)
                    display_modules[mod] = exported_methods

        #do the rendering work here
        for module, exp_meths in display_modules.iteritems():
            for method_name, other_options in exp_meths.iteritems():
                minion_arguments = other_options['args']
                if minion_arguments:
                    wlist_object = WidgetListFactory(minion_arguments,
                                                     minion=self.minion,
                                                     module=module,
                                                     method=method_name)
                    wlist_object = wlist_object.get_widgetlist_object()
                    #print wlist_object
                    wf = WidgetSchemaFactory(minion_arguments)
                    schema_man = wf.get_ready_schema()
                    minion_form = RemoteFormAutomation(wlist_object,
                                                       schema_man)
                    print "%s.%s.%s rendered" % (self.minion, module,
                                                 method_name)
Пример #11
0
    def method_display(self, minion=None, module=None, method=None):
        """
        That method generates the input widget for givent method.
        """

        global global_form
        if self.func_cache["minion_name"] == minion:
            fc = self.func_cache["fc_object"]
        else:
            fc = Overlord(minion)
            self.func_cache["fc_object"] = fc
            self.func_cache["minion_name"] = minion
            # reset the children :)
            self.func_cache["module_name"] = module
            self.func_cache["modules"] = None
            self.func_cache["methods"] = None

        # get the method args
        method_args = getattr(fc, module).get_method_args()

        if not method_args.values():
            # print "Not registered method here"
            return dict(minion_form=None, minion=minion, module=module, method=method)

        minion_arguments = method_args[minion][method]["args"]
        # the description of the method we are going to display
        if method_args[minion][method].has_key("description"):
            description = method_args[minion][method]["description"]
        else:
            description = None
        if minion_arguments:
            wlist_object = WidgetListFactory(minion_arguments, minion=minion, module=module, method=method)
            wlist_object = wlist_object.get_widgetlist_object()
            # create the validation parts for the remote form
            wf = WidgetSchemaFactory(minion_arguments)
            schema_man = wf.get_ready_schema()

            # create the final form
            minion_form = RemoteFormAutomation(wlist_object, schema_man)
            global_form = minion_form.for_widget
            # print global_form
            # i use that when something goes wrong to check the problem better to stay here ;)
            # self.minion_form =RemoteFormFactory(wlist_object,schema_man).get_remote_form()

            del wlist_object
            del minion_arguments

            return dict(minion_form=minion_form, minion=minion, module=module, method=method, description=description)
        else:
            return dict(minion_form=None, minion=minion, module=module, method=method, description=description)
Пример #12
0
    def test_bool_validator(self):
        testing_data = self.get_bool_params()
        wf = WidgetSchemaFactory(testing_data)
        schema_man=wf.get_ready_schema()
        
        for argument_name,arg_options in testing_data.iteritems():  
            #print argument_name
            #should all the argument names really
            assert hasattr(schema_man,argument_name)==True
            #print " ",argument_name," : ",getattr(schema_man,argument_name)

            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(getattr(schema_man,argument_name),'not_empty') == arg_options['optional']
                
        print "Happy test!"
Пример #13
0
    def test_bool_validator(self):
        testing_data = self.get_bool_params()
        wf = WidgetSchemaFactory(testing_data)
        schema_man = wf.get_ready_schema()

        for argument_name, arg_options in testing_data.iteritems():
            #print argument_name
            #should all the argument names really
            assert getattr(schema_man, 'fields').has_key(argument_name) == True
            current_schema_object = getattr(schema_man,
                                            'fields')[argument_name]

            #print " ",argument_name," : ",getattr(schema_man,argument_name)

            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(current_schema_object,
                                   'not_empty') == arg_options['optional']

        print "Happy test!"
Пример #14
0
    def test_float_validator(self):
        wf = WidgetSchemaFactory(self.get_float_params())
        schema_man=wf.get_ready_schema()
        
        for argument_name,arg_options in self.get_float_params().iteritems():  
            #print argument_name
            assert hasattr(schema_man,argument_name)==True
            #print " ",argument_name," : ",getattr(schema_man,argument_name)
            
            if arg_options.has_key('min'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(getattr(schema_man,argument_name),'min') == arg_options['min']
                
            if arg_options.has_key('max'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert getattr(getattr(schema_man,argument_name),'max') == arg_options['max']

            if arg_options.has_key('optional'):
                #print " ",argument_name," : ",getattr(schema_man,argument_name)
                assert not getattr(getattr(schema_man,argument_name),'not_empty') == arg_options['optional']


        print "Happy test!"
Пример #15
0
    def method_display(self, minion=None, module=None, method=None):
        """
        That method generates the input widget for givent method.
        """

        global global_form
        if self.func_cache['minion_name'] == minion:
            fc = self.func_cache['fc_object']
        else:
            fc = Overlord(minion)
            self.func_cache['fc_object'] = fc
            self.func_cache['minion_name'] = minion
            #reset the children :)
            self.func_cache['module_name'] = module
            self.func_cache['modules'] = None
            self.func_cache['methods'] = None

        #get the method args
        method_args = getattr(fc, module).get_method_args()

        if not method_args.values():
            #print "Not registered method here"
            return dict(minion_form=None,
                        minion=minion,
                        module=module,
                        method=method)

        minion_arguments = method_args[minion][method]['args']
        #the description of the method we are going to display
        if method_args[minion][method].has_key('description'):
            description = method_args[minion][method]['description']
        else:
            description = None
        if minion_arguments:
            wlist_object = WidgetListFactory(minion_arguments,
                                             minion=minion,
                                             module=module,
                                             method=method)
            wlist_object = wlist_object.get_widgetlist_object()
            #create the validation parts for the remote form
            wf = WidgetSchemaFactory(minion_arguments)
            schema_man = wf.get_ready_schema()

            #create the final form
            minion_form = RemoteFormAutomation(wlist_object, schema_man)
            global_form = minion_form.for_widget
            #print global_form
            #i use that when something goes wrong to check the problem better to stay here ;)
            #self.minion_form =RemoteFormFactory(wlist_object,schema_man).get_remote_form()

            del wlist_object
            del minion_arguments

            return dict(minion_form=minion_form,
                        minion=minion,
                        module=module,
                        method=method,
                        description=description)
        else:
            return dict(minion_form=None,
                        minion=minion,
                        module=module,
                        method=method,
                        description=description)
Пример #16
0
 def test_remote_form(self):
     schema_factory = WidgetSchemaFactory(self.get_test_default_args())
     schema_validator=schema_factory.get_ready_schema()
     widget_list_object = self.widget_factory.get_widgetlist_object()
     remote_form = RemoteFormAutomation(widget_list_object,schema_validator)