Exemplo n.º 1
0
    def __init__(self, suite_name, assertions=None, browser_debugging=None, method_proxy=None):
        """Assign all available attributes to instance so they are easily introspected"""
        
        if method_proxy is None:
            method_proxy = tools.make_jsonrpc_client()
        
        self._method_proxy = method_proxy
        
        if assertions is not None:
            self.assertions = assertions
        if browser_debugging is not None:
            self.browser_debugging = browser_debugging
            
        if functest.registry.get('browser_debugging', False):
            self.browser_debugging = True
            self.assertions = False
            
        class ExecWrapper(object):
            """In line callable wrapper class for execute/load methods"""
            def __init__(self, exec_method, action_name):
                self.action_name = action_name
                self.exec_method = exec_method
            def __call__(self, **kwargs):
                return self.exec_method(self.action_name, **kwargs)
                
        class NSWrapper(object):
            """Namespace wrapper"""
            def __init__(self, name):
                self.name = name

        for action in self._method_proxy.execute_command(
                                   {'method':'commands.getControllerMethods','params':{}})['result']['result']:
            parent = self
            if action.find('.') is not -1:
                for name in [a for a in action.split('.') if not action.endswith(a) ]:
                    if not hasattr(parent, name): 
                        setattr(parent, name, NSWrapper(name))
                    parent = getattr(parent, name) 
            
            #Bind every available test and action to self, flatten them as well
            if action.find('command') is not -1:
                setattr(parent, 
                        action.split('.')[-1], 
                        ExecWrapper(self._exec_command, action)
                        )
            else:
                setattr(parent, 
                        action.split('.')[-1], 
                        ExecWrapper(self._exec_test, action)
                        )
        # We'll need to start the suite for the name passed to the initializer
        self._method_proxy.start_suite(suite_name)
Exemplo n.º 2
0
#   See the License for the specific language governing permissions and
#   limitations under the License.

import windmill
from windmill.dep import uuid
import sys, os, logging, re
from time import sleep
from windmill.authoring import frame
from threading import Thread
from windmill.dep import functest

logger = logging.getLogger(__name__)

from windmill import tools, browser, server

jsonrpc_client = tools.make_jsonrpc_client()
xmlrpc_client = tools.make_xmlrpc_client()

from StringIO import StringIO
test_stream_object = StringIO()

def clear_queue():
    """Clear the Service's current queue of tests/actions."""
    try:
        xmlrpc_client.clear_queue()
    except Exception, e:
        logger.debug(type(e).__name__+':'+e.message)
        
windmill.settings['controllers'] = []
        
def start_firefox():