Merge lp://qastaging/~thisfred/desktopcouch/fix-mysterious-problem into lp://qastaging/desktopcouch

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 71
Merged at revision: not available
Proposed branch: lp://qastaging/~thisfred/desktopcouch/fix-mysterious-problem
Merge into: lp://qastaging/desktopcouch
Diff against target: 95 lines
2 files modified
desktopcouch/pair/couchdb_pairing/couchdb_io.py (+9/-5)
desktopcouch/pair/tests/test_couchdb_io.py (+9/-5)
To merge this branch: bzr merge lp://qastaging/~thisfred/desktopcouch/fix-mysterious-problem
Reviewer Review Type Date Requested Status
Vincenzo Di Somma (community) Approve
Facundo Batista (community) Approve
Review via email: mp+12352@code.qastaging.launchpad.net

Commit message

FIxes a try: except: clause that was a little too ambitious

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

There was a bug in the try except structure. Also the bad server test failed for some OpenDNS configurations. Now it passes, it just takes a few minutes...

Revision history for this message
Facundo Batista (facundo) wrote :

Looks ok

review: Approve
Revision history for this message
Vincenzo Di Somma (vds) wrote :

Good job!

Revision history for this message
Vincenzo Di Somma (vds) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktopcouch/pair/couchdb_pairing/couchdb_io.py'
2--- desktopcouch/pair/couchdb_pairing/couchdb_io.py 2009-09-18 13:18:36 +0000
3+++ desktopcouch/pair/couchdb_pairing/couchdb_io.py 2009-09-24 14:20:25 +0000
4@@ -75,7 +75,7 @@
5 push_to_server=True, server=hostname)
6
7 def get_static_paired_hosts(uri=None):
8- """Retreive a list of static hosts' information in the form of
9+ """Retreive a list of static hosts' information in the form of
10 (ID, service name, to_push, to_pull) ."""
11 db = _get_db("management", uri=uri)
12 results = db.get_records(create_view=True)
13@@ -92,7 +92,7 @@
14 logging.warn("Skipping weird record. %s", e)
15 # FIXME maybe we should log this or be more specific
16 pass
17- unique_hosts = [(v1, sn, v2, v3) for
18+ unique_hosts = [(v1, sn, v2, v3) for
19 (sn), (v1, v2, v3) in found.items()]
20 logging.debug("static pairings are %s", unique_hosts)
21 return unique_hosts
22@@ -103,7 +103,11 @@
23
24 try:
25 db = _get_db("management", uri=uri)
26- couchdb_server = db._server
27+ except socket.error, e:
28+ logging.error("Can't get 'management' database at %s", uri)
29+ return set()
30+ couchdb_server = db._server
31+ try:
32 all = set([db_name for db_name in couchdb_server])
33 except socket.error, e:
34 logging.error("Can't get list of databases from %s", couchdb_server)
35@@ -203,7 +207,7 @@
36 if target_oauth:
37 assert "consumer_secret" in target_oauth
38 target = dict(url=target, auth=dict(oauth=target_oauth))
39-
40+
41 record = dict(source=source, target=target)
42 try:
43 # regardless of source and target, we talk to our local couchdb :(
44@@ -236,7 +240,7 @@
45 if not db.view_exists("paired_servers", design_doc):
46 map_js = """function(doc) {
47 if (doc.record_type == %r && ! doc.unpaired) // unset or False
48- if (doc.application_annotations &&
49+ if (doc.application_annotations &&
50 doc.application_annotations["Ubuntu One"] &&
51 doc.application_annotations["Ubuntu One"].private_application_annotations &&
52 doc.application_annotations["Ubuntu One"].private_application_annotations.deleted) {
53
54=== modified file 'desktopcouch/pair/tests/test_couchdb_io.py'
55--- desktopcouch/pair/tests/test_couchdb_io.py 2009-09-14 15:56:42 +0000
56+++ desktopcouch/pair/tests/test_couchdb_io.py 2009-09-24 14:20:25 +0000
57@@ -20,7 +20,7 @@
58
59 import desktopcouch.tests as dctests
60
61-from desktopcouch.pair.couchdb_pairing import couchdb_io
62+from desktopcouch.pair.couchdb_pairing import couchdb_io
63 from desktopcouch.records.server import CouchDatabase
64 from desktopcouch.records.record import Record
65 import unittest
66@@ -71,7 +71,7 @@
67 "token": str("opqrst"),
68 "token_secret": str("uvwxyz"),
69 }
70-
71+
72 couchdb_io.put_dynamic_paired_host(hostname, remote_uuid, oauth_data,
73 uri=URI)
74 couchdb_io.put_dynamic_paired_host(hostname, remote_uuid, oauth_data,
75@@ -90,13 +90,17 @@
76
77 pairings = list(couchdb_io.get_pairings())
78 self.assertEqual(0, len(pairings))
79-
80+
81
82 def test_get_database_names_replicatable_bad_server(self):
83 # If this resolves, FIRE YOUR DNS PROVIDER.
84- self.assertRaises(httplib2.ServerNotFoundError,
85- couchdb_io.get_database_names_replicatable,
86+
87+ try:
88+ names = couchdb_io.get_database_names_replicatable(
89 uri='http://test.desktopcouch.example.com:9/')
90+ self.assertEqual(set(), names)
91+ except httplib2.ServerNotFoundError:
92+ pass
93
94 def test_get_database_names_replicatable(self):
95 names = couchdb_io.get_database_names_replicatable(uri=URI)

Subscribers

People subscribed via source and target branches