Merge lp://qastaging/~thisfred/desktopcouch/fix-missing-import into lp://qastaging/desktopcouch

Proposed by Eric Casteleijn
Status: Merged
Approved by: Stuart Langridge
Approved revision: 80
Merged at revision: not available
Proposed branch: lp://qastaging/~thisfred/desktopcouch/fix-missing-import
Merge into: lp://qastaging/desktopcouch
Diff against target: 54 lines
2 files modified
desktopcouch/pair/couchdb_pairing/couchdb_io.py (+8/-5)
desktopcouch/pair/tests/test_couchdb_io.py (+7/-0)
To merge this branch: bzr merge lp://qastaging/~thisfred/desktopcouch/fix-missing-import
Reviewer Review Type Date Requested Status
Stuart Langridge (community) Approve
Mark G. Saye (community) Approve
Review via email: mp+12953@code.qastaging.launchpad.net

Commit message

Fixed broken mk_uri function and added a test for it.

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

This fixes two pretty bad errors: mk_uri uses urllib which was not imported, and had a parenthesis in the wrong place. Test added.

80. By Eric Casteleijn

test with path

Revision history for this message
Mark G. Saye (markgsaye) wrote :

Code looks good, new tests that test untested code are always good, especially when they pass!

review: Approve
Revision history for this message
Stuart Langridge (sil) wrote :

> This fixes two pretty bad errors: mk_uri uses urllib which was not imported,
> and had a parenthesis in the wrong place. Test added.

Good catch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'desktopcouch/pair/couchdb_pairing/couchdb_io.py'
--- desktopcouch/pair/couchdb_pairing/couchdb_io.py 2009-09-30 15:52:57 +0000
+++ desktopcouch/pair/couchdb_pairing/couchdb_io.py 2009-10-07 13:29:11 +0000
@@ -18,6 +18,7 @@
18"""Communicate with CouchDB."""18"""Communicate with CouchDB."""
1919
20import logging20import logging
21import urllib
2122
22from desktopcouch import find_port as desktopcouch_find_port23from desktopcouch import find_port as desktopcouch_find_port
23from desktopcouch.records import server24from desktopcouch.records import server
@@ -33,10 +34,12 @@
33def mkuri(hostname, port, has_ssl=False, path="", auth_pair=None):34def mkuri(hostname, port, has_ssl=False, path="", auth_pair=None):
34 """Create a URI from parts."""35 """Create a URI from parts."""
35 protocol = "https" if has_ssl else "http"36 protocol = "https" if has_ssl else "http"
36 auth = (":".join(map(urllib.quote, auth_pair) + "@")) if auth_pair else ""37 if auth_pair:
37 port = int(port)38 auth = (":".join(map(urllib.quote, auth_pair)) + "@")
38 uri = "%(protocol)s://%(auth)s%(hostname)s:%(port)d/%(path)s" % locals()39 else:
39 return uri40 auth = ""
41 port = str(port)
42 return "%s://%s%s:%s/%s" % (protocol, auth, hostname, port, path)
4043
41def _get_db(name, create=True, uri=None):44def _get_db(name, create=True, uri=None):
42 """Get (and create?) a database."""45 """Get (and create?) a database."""
@@ -224,7 +227,7 @@
224 target_ssl, target_oauth)227 target_ssl, target_oauth)
225 logging.debug("db exists, and we're ready to replicate")228 logging.debug("db exists, and we're ready to replicate")
226 except:229 except:
227 logging.exception("can't create/verify %r %s:%d oauth=%s", 230 logging.exception("can't create/verify %r %s:%d oauth=%s",
228 target_database, target_host, target_port, target_oauth)231 target_database, target_host, target_port, target_oauth)
229232
230 try:233 try:
231234
=== modified file 'desktopcouch/pair/tests/test_couchdb_io.py'
--- desktopcouch/pair/tests/test_couchdb_io.py 2009-09-24 13:46:17 +0000
+++ desktopcouch/pair/tests/test_couchdb_io.py 2009-10-07 13:29:11 +0000
@@ -113,6 +113,13 @@
113 self.assertEquals(len(got), 1)113 self.assertEquals(len(got), 1)
114 self.assertEquals(got, again)114 self.assertEquals(got, again)
115115
116 def test_mkuri(self):
117 uri = couchdb_io.mkuri(
118 'fnord.org', 55241, has_ssl=True, path='a/b/c',
119 auth_pair=('f o o', 'b=a=r'))
120 self.assertEquals(
121 'https://f%20o%20o:b%3Da%3Dr@fnord.org:55241/a/b/c', uri)
122
116 def Xtest_replication_good(self):123 def Xtest_replication_good(self):
117 pass124 pass
118125

Subscribers

People subscribed via source and target branches