diff mbox

[Branch,~linaro-validation/lava-tool/trunk] Rev 191: Fixed rpc_endnpoint parameter usage.

Message ID 20130807094724.16646.48295.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Milo Casagrande Aug. 7, 2013, 9:47 a.m. UTC
Merge authors:
  Milo Casagrande (milo)
Related merge proposals:
  https://code.launchpad.net/~milo/lava-tool/server-rpc-endpoint-fix/+merge/177658
  proposed by: Milo Casagrande (milo)
  review: Approve - Antonio Terceiro (terceiro)
------------------------------------------------------------
revno: 191 [merge]
committer: Milo Casagrande <milo@ubuntu.com>
branch nick: trunk
timestamp: Wed 2013-08-07 11:42:35 +0200
message:
  Fixed rpc_endnpoint parameter usage.
modified:
  lava/helper/command.py
  lava_tool/tests/test_utils.py
  lava_tool/utils.py


--
lp:lava-tool
https://code.launchpad.net/~linaro-validation/lava-tool/trunk

You are subscribed to branch lp:lava-tool.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-tool/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava/helper/command.py'
--- lava/helper/command.py	2013-07-31 10:24:23 +0000
+++ lava/helper/command.py	2013-08-07 09:42:35 +0000
@@ -91,10 +91,10 @@ 
         rpc_endpoint_parameter = Parameter("rpc_endpoint",
                                            depends=server_name_parameter)
 
-        server_url = self.config.get(server_name_parameter)
+        self.config.get(server_name_parameter)
         endpoint = self.config.get(rpc_endpoint_parameter)
 
-        rpc_url = verify_and_create_url(server_url, endpoint)
+        rpc_url = verify_and_create_url(endpoint)
         server = AuthenticatingServerProxy(rpc_url,
                                            auth_backend=KeyringAuthBackend())
         return server

=== modified file 'lava_tool/tests/test_utils.py'
--- lava_tool/tests/test_utils.py	2013-07-26 09:30:11 +0000
+++ lava_tool/tests/test_utils.py	2013-07-30 17:39:27 +0000
@@ -243,7 +243,7 @@ 
 
     def test_verify_and_create_url_0(self):
         expected = "https://www.example.org/"
-        obtained = verify_and_create_url("www.example.org", "")
+        obtained = verify_and_create_url("www.example.org")
         self.assertEquals(expected, obtained)
 
     def test_verify_and_create_url_1(self):
@@ -253,12 +253,12 @@ 
 
     def test_verify_and_create_url_2(self):
         expected = "http://www.example.org/RPC/"
-        obtained = verify_and_create_url("http://www.example.org", "RPC")
+        obtained = verify_and_create_url("http://www.example.org/RPC")
         self.assertEquals(expected, obtained)
 
     def test_verify_and_create_url_3(self):
         expected = "https://www.example.org/RPC/"
-        obtained = verify_and_create_url("www.example.org/", "/RPC/")
+        obtained = verify_and_create_url("www.example.org/RPC")
         self.assertEquals(expected, obtained)
 
     def test_create_dir_0(self):

=== modified file 'lava_tool/utils.py'
--- lava_tool/utils.py	2013-07-26 14:12:33 +0000
+++ lava_tool/utils.py	2013-07-30 17:39:27 +0000
@@ -281,7 +281,7 @@ 
                                                            editor))
 
 
-def verify_and_create_url(server, endpoint=""):
+def verify_and_create_url(endpoint):
     """Checks that the provided values make a correct URL.
 
     If the server address does not contain a scheme, by default it will use
@@ -291,25 +291,22 @@ 
     :param server: A server URL to verify.
     :return A URL.
     """
-    scheme, netloc, path, params, query, fragment = \
-        urlparse.urlparse(server)
-    if not scheme:
-        scheme = "https"
-    if not netloc:
-        netloc, path = path, ""
-
-    if not netloc[-1:] == "/":
-        netloc += "/"
-
+    url = ""
     if endpoint:
-        if endpoint[0] == "/":
-            endpoint = endpoint[1:]
-        if not endpoint[-1:] == "/":
-            endpoint += "/"
-        netloc += endpoint
-
-    return urlparse.urlunparse(
-        (scheme, netloc, path, params, query, fragment))
+        scheme, netloc, path, params, query, fragment = \
+            urlparse.urlparse(endpoint)
+        if not scheme:
+            scheme = "https"
+        if not netloc:
+            netloc, path = path, ""
+
+        url = urlparse.urlunparse(
+            (scheme, netloc, path, params, query, fragment))
+
+        if url[-1:] != "/":
+            url += "/"
+
+    return url
 
 
 def create_dir(path, dir_name=None):