Merge lp:~verterok/ubuntuone-client/fix-702035 into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Roman Yepishev
Approved revision: 808
Merged at revision: 812
Proposed branch: lp:~verterok/ubuntuone-client/fix-702035
Merge into: lp:ubuntuone-client
Diff against target: 117 lines (+45/-37)
2 files modified
tests/syncdaemon/test_vm.py (+43/-36)
ubuntuone/syncdaemon/volume_manager.py (+2/-1)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/fix-702035
Reviewer Review Type Date Requested Status
Roman Yepishev (community) fieldtest Approve
Natalia Bidart (community) Approve
Review via email: mp+46662@code.launchpad.net

Commit message

Shares created from a ShareVolume are always marked as accepted.

Description of the change

This branch change the way Share objects are created when the protocol object is a ShareVolume, now we always mark it as accepted as we don't have that info in the protocol and the accepted value is false, but it's implicit to the type of the object.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

+1

Can't test IRL right now, but code looks good and tests pass.

review: Approve
Revision history for this message
Roman Yepishev (rye) wrote :

Works great, the folder is created immediately after I click accept share.

review: Approve (fieldtest)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_vm.py'
2--- tests/syncdaemon/test_vm.py 2011-01-07 17:24:11 +0000
3+++ tests/syncdaemon/test_vm.py 2011-01-18 19:19:09 +0000
4@@ -1808,42 +1808,17 @@
5 self.assertTrue(self.handler.check_warning("missing volume id"))
6
7 @defer.inlineCallbacks
8- def _test_handle_SV_VOLUME_CREATED(self, auto_subscribe):
9- """Test for handle_SV_VOLUME_CREATED."""
10- user_conf = config.get_user_config()
11- user_conf.set_udf_autosubscribe(auto_subscribe)
12+ def test_handle_SV_VOLUME_CREATED_share(self):
13+ """Test for handle_SV_VOLUME_CREATED with shares."""
14 # start the test
15- udf_id = uuid.uuid4()
16- udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', None, 10, u'~/ñoño')
17 share_id = uuid.uuid4()
18- share_volume = volumes.ShareVolume(share_id, 'fake_share_uuid', None,
19- 10, 'to_me', u'ñoño',
20- 'username', u'visible_username',
21- True, 'View')
22+ share_volume = volumes.ShareVolume(
23+ share_id, 'fake_share_uuid', None, 10, 'to_me', u'ñoño',
24+ 'username', u'visible_username',
25+ False, # this is how the protocol send it
26+ 'View')
27 # initialize the the root
28 self.vm._got_root('root_uuid')
29-
30- d = defer.Deferred()
31- self._listen_for('VM_UDF_CREATED', d.callback)
32- rescan_cb = defer.Deferred()
33- self.patch(self.main.action_q, 'rescan_from_scratch', rescan_cb.callback)
34-
35- with environ('HOME', self.home_dir):
36- self.vm.handle_SV_VOLUME_CREATED(udf_volume)
37- info = yield d
38- udf = info['udf']
39- self.assertEquals(udf.volume_id, str(udf_id))
40- self.assertIn(str(udf_id), self.vm.udfs)
41- if auto_subscribe:
42- self.assertTrue(udf.subscribed)
43- self.assertTrue(os.path.exists(udf.path))
44- # check that rescan_from_scratch is called
45- vol_id = yield rescan_cb
46- self.assertEqual(vol_id, udf.volume_id)
47- else:
48- self.assertFalse(udf.subscribed)
49- self.assertFalse(os.path.exists(udf.path))
50- # subscribe a new listener
51 d = defer.Deferred()
52 self._listen_for('VM_SHARE_CREATED', d.callback)
53 rescan_cb = defer.Deferred()
54@@ -1860,13 +1835,45 @@
55 vol_id = yield rescan_cb
56 self.assertEqual(vol_id, share.volume_id)
57
58- def test_handle_SV_VOLUME_CREATED_subscribe(self):
59+ @defer.inlineCallbacks
60+ def _test_handle_SV_VOLUME_CREATED_udf(self, auto_subscribe):
61+ """Test for handle_SV_VOLUME_CREATED with udfs."""
62+ user_conf = config.get_user_config()
63+ user_conf.set_udf_autosubscribe(auto_subscribe)
64+ # start the test
65+ udf_id = uuid.uuid4()
66+ udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', None, 10, u'~/ñoño')
67+ # initialize the the root
68+ self.vm._got_root('root_uuid')
69+
70+ d = defer.Deferred()
71+ self._listen_for('VM_UDF_CREATED', d.callback)
72+ rescan_cb = defer.Deferred()
73+ self.patch(self.main.action_q, 'rescan_from_scratch', rescan_cb.callback)
74+
75+ with environ('HOME', self.home_dir):
76+ self.vm.handle_SV_VOLUME_CREATED(udf_volume)
77+ info = yield d
78+ udf = info['udf']
79+ self.assertEquals(udf.volume_id, str(udf_id))
80+ self.assertIn(str(udf_id), self.vm.udfs)
81+ if auto_subscribe:
82+ self.assertTrue(udf.subscribed)
83+ self.assertTrue(os.path.exists(udf.path))
84+ # check that rescan_from_scratch is called
85+ vol_id = yield rescan_cb
86+ self.assertEqual(vol_id, udf.volume_id)
87+ else:
88+ self.assertFalse(udf.subscribed)
89+ self.assertFalse(os.path.exists(udf.path))
90+
91+ def test_handle_SV_VOLUME_CREATED_udf_subscribe(self):
92 """Test SV_VOLUME_CREATED with udf auto_subscribe """
93- return self._test_handle_SV_VOLUME_CREATED(True)
94+ return self._test_handle_SV_VOLUME_CREATED_udf(True)
95
96- def test_handle_SV_VOLUME_CREATED_no_subscribe(self):
97+ def test_handle_SV_VOLUME_CREATED_udf_no_subscribe(self):
98 """Test SV_VOLUME_CREATED without udf auto_subscribe """
99- return self._test_handle_SV_VOLUME_CREATED(False)
100+ return self._test_handle_SV_VOLUME_CREATED_udf(False)
101
102 @defer.inlineCallbacks
103 def test_handle_SV_VOLUME_DELETED(self):
104
105=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
106--- ubuntuone/syncdaemon/volume_manager.py 2011-01-13 22:06:43 +0000
107+++ ubuntuone/syncdaemon/volume_manager.py 2011-01-18 19:19:09 +0000
108@@ -195,7 +195,8 @@
109 path=path, name=share_volume.share_name,
110 other_username=share_volume.other_username,
111 other_visible_name=share_volume.other_visible_name,
112- accepted=share_volume.accepted,
113+ # if it's form a share volume, it was accepted
114+ accepted=True,
115 access_level=share_volume.access_level,
116 generation=share_volume.generation,
117 free_bytes=share_volume.free_bytes)

Subscribers

People subscribed via source and target branches