[Telepathy-commits] [telepathy-salut/master] quote/unquote filename

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Nov 28 04:35:38 PST 2008


---
 tests/twisted/avahi/test-ichat-receive-file.py |    5 +++--
 tests/twisted/avahi/test-ichat-send-file.py    |    5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/twisted/avahi/test-ichat-receive-file.py b/tests/twisted/avahi/test-ichat-receive-file.py
index e5cee7f..6c1ed06 100644
--- a/tests/twisted/avahi/test-ichat-receive-file.py
+++ b/tests/twisted/avahi/test-ichat-receive-file.py
@@ -5,6 +5,7 @@ import socket
 import md5
 import avahi
 import BaseHTTPServer
+import urllib
 
 from saluttest import exec_test
 from avahitest import AvahiAnnouncer, AvahiListener
@@ -113,7 +114,7 @@ def test(q, bus, conn):
     iq['type'] = 'set'
     iq['id'] = 'iChat_A1FB5D95'
     query = iq.addElement(('jabber:iq:oob', 'query'))
-    url = 'http://127.0.0.1:%u/gibber-file-transfer-0/%s' % (httpd.server_port, FILE_NAME)
+    url = 'http://127.0.0.1:%u/gibber-file-transfer-0/%s' % (httpd.server_port, urllib.quote(FILE_NAME))
     url_node = query.addElement('url', content=url)
     url_node['type'] = 'file'
     url_node['size'] = str(FILE_SIZE)
@@ -211,7 +212,7 @@ class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
     def do_GET(self):
         # is that the right file ?
         filename = self.path.rsplit('/', 2)[-1]
-        assert filename == FILE_NAME
+        assert filename == urllib.quote(FILE_NAME)
 
         self.send_response(200)
         self.send_header('Content-type', FILE_CONTENT_TYPE)
diff --git a/tests/twisted/avahi/test-ichat-send-file.py b/tests/twisted/avahi/test-ichat-send-file.py
index 9d54c7e..29057da 100644
--- a/tests/twisted/avahi/test-ichat-send-file.py
+++ b/tests/twisted/avahi/test-ichat-send-file.py
@@ -4,6 +4,7 @@ import dbus
 import socket
 import md5
 import struct
+import urllib
 
 from saluttest import exec_test
 from avahitest import AvahiAnnouncer
@@ -160,7 +161,8 @@ def test(q, bus, conn):
     assert url_node['size'] == str(FILE_SIZE)
     assert url_node['mimeType'] == FILE_CONTENT_TYPE
     url = url_node.children[0]
-    assert url.endswith(FILE_NAME)
+    _, host, file, _, _, _ = urlparse.urlparse(url)
+    urllib.unquote(file) == FILE_NAME
     desc_node = xpath.queryForNodes("/iq/query/desc",  iq)[0]
     desc = desc_node.children[0]
     assert desc == FILE_DESCRIPTION
@@ -172,7 +174,6 @@ def test(q, bus, conn):
     assert state == FT_STATE_PENDING
 
     # Connect HTTP client to the CM and request the file
-    _, host, file, _, _, _ = urlparse.urlparse(url)
     http = httplib.HTTPConnection(host)
     headers = {'Accept-Encoding': 'AppleSingle'}
     http.request('GET', file, headers=headers)
-- 
1.5.6.5




More information about the Telepathy-commits mailing list