1
=== modified file 'desktopcouch/pair/couchdb_pairing/couchdb_io.py'
2
--- desktopcouch/pair/couchdb_pairing/couchdb_io.py 2010-04-12 19:24:14 +0000
3
+++ desktopcouch/pair/couchdb_pairing/couchdb_io.py 2010-04-15 14:56:36 +0000
5
if key in record.value: # EAFP, rather than LBYL? Nones default?
6
value = record.value[key]
9
+ if "_order" in value: # MergableList, so decode.
10
+ values.append(value[k] for k in value["_order"])
12
+ values.append(value)
14
logging.debug("skipping record empty %s", key)
17
=== modified file 'desktopcouch/pair/tests/test_couchdb_io.py'
18
--- desktopcouch/pair/tests/test_couchdb_io.py 2009-11-12 22:05:09 +0000
19
+++ desktopcouch/pair/tests/test_couchdb_io.py 2010-04-15 14:56:36 +0000
21
from desktopcouch.pair.couchdb_pairing import couchdb_io
22
from desktopcouch.records.server import CouchDatabase
23
from desktopcouch.records.record import Record
24
+from desktopcouch.replication_services import ubuntuone
25
from twisted.trial import unittest
29
self.foo_database = CouchDatabase('foo', create=True, uri=URI,
30
ctx=test_environment.test_context)
31
#create some records to pull out and test
32
+ self.foo_database = CouchDatabase('bar', create=True, uri=URI,
33
+ ctx=test_environment.test_context)
34
+ #create some records to pull out and test
35
self.foo_database.put_record(Record({
36
"key1_1": "val1_1", "key1_2": "val1_2", "key1_3": "val1_3",
37
"record_type": "test.com"}))
39
"key13_1": "va31_1", "key3_2": "val3_2", "key3_3": "val3_3",
40
"record_type": "test.com"}))
42
+ couchdb_io.put_static_paired_service({
43
+ "consumer_key": str("abcdef"),
44
+ "consumer_secret": str("ghighjklm"),
45
+ "token": str("opqrst"),
46
+ "token_secret": str("uvwxyz")}, "ubuntuone", uri=URI,
47
+ ctx=test_environment.test_context)
48
+ excl = ubuntuone.ReplicationExclusion(ctx=test_environment.test_context)
52
"""tear down each test"""
53
del self.mgt_database._server['management']
55
uri=URI, ctx=test_environment.test_context)
57
pairings = list(couchdb_io.get_pairings(ctx=test_environment.test_context))
58
- self.assertEqual(3, len(pairings))
59
+ self.assertEqual(4, len(pairings)) # 3, plus 1 from setUp()
60
self.assertEqual(pairings[0].value["oauth"], oauth_data)
61
self.assertEqual(pairings[0].value["server"], hostname)
62
self.assertEqual(pairings[0].value["pairing_identifier"], remote_uuid)
64
names = couchdb_io.get_database_names_replicatable(uri=URI, ctx=test_environment.test_context)
65
self.assertFalse('management' in names)
66
self.assertTrue('foo' in names)
67
+ self.assertFalse('bar' in names, names) # is excluded
69
def test_get_my_host_unique_id(self):
70
got = couchdb_io.get_my_host_unique_id(uri=URI, ctx=test_environment.test_context)