Example #1
0
    def test_ssh_transports(self):
        testcases = (
            ("scgi+ssh://localhost/tmp/foo",),
            ("scgi+ssh://localhost:5000/~/foo",),
        )
        for url, in testcases:
            # Just make sure they get parsed with no errors
            xmlrpc2scgi.transport_from_url(url)

        # Port handling
        self.failIf("-p" in xmlrpc2scgi.transport_from_url("scgi+ssh://localhost/foo").cmd)
        self.failUnless("-p" in xmlrpc2scgi.transport_from_url("scgi+ssh://localhost:5000/foo").cmd)

        # Errors
        self.failUnlessRaises(URLError, xmlrpc2scgi.transport_from_url, "scgi+ssh://localhost:5000")
Example #2
0
    def test_ssh_transports(self):
        testcases = (
            ("scgi+ssh://localhost/tmp/foo", ),
            ("scgi+ssh://localhost:5000/~/foo", ),
        )
        for url, in testcases:
            # JUst make sure they get parsed with no errors
            xmlrpc2scgi.transport_from_url(url)

        # Port handling
        self.failIf("-p" in xmlrpc2scgi.transport_from_url(
            "scgi+ssh://localhost/foo").cmd)
        self.failUnless("-p" in xmlrpc2scgi.transport_from_url(
            "scgi+ssh://localhost:5000/foo").cmd)

        # Errors
        self.failUnlessRaises(urllib2.URLError, xmlrpc2scgi.transport_from_url,
                              "scgi+ssh://localhost:5000")
Example #3
0
 def test_local_transports(self):
     testcases = (
         ("scgi://localhost:5000/", socket.AF_INET),
         ("localhost:5000", socket.AF_INET),
         ("example.com:5000", socket.AF_INET),
         ("~/tmp/socket", socket.AF_UNIX),
         ("/tmp/socket", socket.AF_UNIX),
         ("scgi:///tmp/socket", socket.AF_UNIX),
         ("scgi:/tmp/socket", socket.AF_UNIX),
     )
     for url, family in testcases:
         result = xmlrpc2scgi.transport_from_url(url)
         self.failUnlessEqual(result.sock_args[0], family)
         if family == socket.AF_UNIX:
             self.failUnless(result.sock_addr.endswith("/tmp/socket"))
Example #4
0
 def test_local_transports(self):
     testcases = (
         ("scgi://localhost:5000/", socket.AF_INET),
         ("localhost:5000", socket.AF_INET),
         ("example.com:5000", socket.AF_INET),
         ("~/tmp/socket", socket.AF_UNIX),
         ("/tmp/socket", socket.AF_UNIX),
         ("scgi:///tmp/socket", socket.AF_UNIX),
         ("scgi:/tmp/socket", socket.AF_UNIX),
     )
     for url, family in testcases:
         result = xmlrpc2scgi.transport_from_url(url) 
         self.failUnlessEqual(result.sock_args[0], family)
         if family == socket.AF_UNIX:
             self.failUnless(result.sock_addr.endswith("/tmp/socket"))
Example #5
0
    def __init__(self, url, mapping=None):
        self.LOG = pymagic.get_class_logger(self)
        self._url = url
        self._transport = xmlrpc2scgi.transport_from_url(url)
        self._versions = ("", "")
        self._version_info = ()
        self._use_deprecated = True
        self._mapping = mapping or config.xmlrpc
        self._fix_mappings()

        # Statistics (traffic w/o HTTP overhead)
        self._requests = 0
        self._outbound = 0L
        self._outbound_max = 0L
        self._inbound = 0L
        self._inbound_max = 0L
        self._latency = 0.0
        self._net_latency = 0.0
Example #6
0
    def __init__(self, url, mapping=None):
        self.LOG = pymagic.get_class_logger(self)
        self._url = os.path.expandvars(url)
        try:
            self._transport = xmlrpc2scgi.transport_from_url(self._url)
        except socket.gaierror as exc:
            raise XmlRpcError("Bad XMLRPC URL {0}: {1}", self._url, exc)
        self._versions = ("", "")
        self._version_info = ()
        self._use_deprecated = True
        self._mapping = mapping or config.xmlrpc
        self._fix_mappings()

        # Statistics (traffic w/o HTTP overhead)
        self._requests = 0
        self._outbound = 0
        self._outbound_max = 0
        self._inbound = 0
        self._inbound_max = 0
        self._latency = 0.0
        self._net_latency = 0.0
Example #7
0
def test_ssh_url_error():
    with pytest.raises(URLError):
        xmlrpc2scgi.transport_from_url("scgi+ssh://localhost:5000")
Example #8
0
def test_ssh_url_with_port():
    # Port handling
    assert "-p" not in xmlrpc2scgi.transport_from_url("scgi+ssh://localhost/foo").cmd
    assert "-p" in xmlrpc2scgi.transport_from_url("scgi+ssh://localhost:5000/foo").cmd
Example #9
0
def test_ssh_transports(url):
    # Just make sure they get parsed with no errors
    xmlrpc2scgi.transport_from_url(url)
Example #10
0
def test_local_transports(url, family):
    result = xmlrpc2scgi.transport_from_url(url)
    assert "%s[%d]" % (url, result.sock_args[0]) == "%s[%d]" % (url, family)
    if family == socket.AF_UNIX:
        assert result.sock_addr.endswith("/tmp/socket")
Example #11
0
def test_bad_url():
    with pytest.raises(URLError):
        xmlrpc2scgi.transport_from_url("xxxx:///")