Ejemplo n.º 1
0
class RpcMsgMatcher(mockito.matchers.Matcher):
    def __init__(self, method, *args_dict):
        self.wanted_method = method
        self.wanted_dict = KeysEqual('version', 'method', 'args')
        self.args_dict = KeysEqual(*args_dict)

    def matches(self, arg):
        if self.wanted_method != arg['method']:
            return False
        if self.wanted_dict.match(arg) or self.args_dict.match(arg['args']):
            return False
        return True

    def __repr__(self):
        return "<Dict: %s>" % self.wanted_dict
Ejemplo n.º 2
0
class RpcMsgMatcher(mockito.matchers.Matcher):
    def __init__(self, method, *args_dict):
        self.wanted_method = method
        self.wanted_dict = KeysEqual("version", "method", "args", "namespace")
        self.args_dict = KeysEqual(*args_dict)

    def matches(self, arg):
        if self.wanted_method != arg["method"]:
            raise Exception("Method does not match: %s != %s" % (self.wanted_method, arg["method"]))
            # return False
        if self.wanted_dict.match(arg) or self.args_dict.match(arg["args"]):
            raise Exception("Args do not match: %s != %s" % (self.args_dict, arg["args"]))
            # return False
        return True

    def __repr__(self):
        return "<Dict: %s>" % self.wanted_dict
Ejemplo n.º 3
0
class RpcMsgMatcher(mockito.matchers.Matcher):
    def __init__(self, method, *args_dict):
        self.wanted_method = method
        self.wanted_dict = KeysEqual('version', 'method', 'args', 'namespace')
        self.args_dict = KeysEqual(*args_dict)

    def matches(self, arg):
        if self.wanted_method != arg['method']:
            raise Exception("Method does not match: %s != %s" %
                            (self.wanted_method, arg['method']))
            #return False
        if self.wanted_dict.match(arg) or self.args_dict.match(arg['args']):
            raise Exception("Args do not match: %s != %s" %
                            (self.args_dict, arg['args']))
            #return False
        return True

    def __repr__(self):
        return "<Dict: %s>" % self.wanted_dict
Ejemplo n.º 4
0
class RpcMsgMatcher(object):
    def __init__(self, method, *args_dict):
        self.wanted_method = method
        self.wanted_dict = KeysEqual('version', 'method', 'args', 'namespace')
        args_dict = args_dict or [{}]
        self.args_dict = KeysEqual(*args_dict)

    def __eq__(self, arg):
        if self.wanted_method != arg['method']:
            raise Exception("Method does not match: %s != %s" %
                            (self.wanted_method, arg['method']))
            #return False
        if self.wanted_dict.match(arg) or self.args_dict.match(arg['args']):
            raise Exception("Args do not match: %s != %s" %
                            (self.args_dict, arg['args']))
            #return False
        return True

    def __repr__(self):
        return "<Dict: %s>" % self.wanted_dict