Merge lp:~nataliabidart/ubuntuone-client/yield-around into lp:ubuntuone-client
- yield-around
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||||||
Approved revision: | 838 | ||||||||
Merged at revision: | 836 | ||||||||
Proposed branch: | lp:~nataliabidart/ubuntuone-client/yield-around | ||||||||
Merge into: | lp:ubuntuone-client | ||||||||
Diff against target: |
2089 lines (+383/-282) 10 files modified
tests/eventlog/test_zg_listener.py (+9/-7) tests/platform/linux/test_dbus.py (+150/-106) tests/platform/linux/test_filesystem_notifications.py (+14/-7) tests/platform/linux/test_tools.py (+4/-3) tests/syncdaemon/test_eq_inotify.py (+10/-7) tests/syncdaemon/test_fsm.py (+113/-84) tests/syncdaemon/test_localrescan.py (+61/-44) tests/syncdaemon/test_status_listener.py (+5/-5) tests/syncdaemon/test_sync.py (+8/-9) tests/syncdaemon/test_u1sdtool.py (+9/-10) |
||||||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-client/yield-around | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Roberto Alsina (community) | Approve | ||
Eric Casteleijn (community) | Approve | ||
Review via email: mp+48504@code.launchpad.net |
Description of the change
To post a comment you must log in.
- 837. By Natalia Bidart
-
Merged trunk in.
- 838. By Natalia Bidart
-
ZG tests should also yield on vm.add_share.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'tests/eventlog/test_zg_listener.py' | |||
2 | --- tests/eventlog/test_zg_listener.py 2011-01-28 15:23:20 +0000 | |||
3 | +++ tests/eventlog/test_zg_listener.py 2011-02-03 17:29:42 +0000 | |||
4 | @@ -213,7 +213,7 @@ | |||
5 | 213 | self.main.fs.set_node_id(path, sample_node_id) | 213 | self.main.fs.set_node_id(path, sample_node_id) |
6 | 214 | share = Shared(path=path, volume_id=sample_share_id, | 214 | share = Shared(path=path, volume_id=sample_share_id, |
7 | 215 | node_id=sample_node_id, other_username=fake_username) | 215 | node_id=sample_node_id, other_username=fake_username) |
9 | 216 | self.vm.add_shared(share) | 216 | yield self.vm.add_shared(share) |
10 | 217 | 217 | ||
11 | 218 | def fake_delete_share(share_id): | 218 | def fake_delete_share(share_id): |
12 | 219 | """Fake delete_share.""" | 219 | """Fake delete_share.""" |
13 | @@ -250,6 +250,7 @@ | |||
14 | 250 | self.assertEqual(other_user.manifestation, | 250 | self.assertEqual(other_user.manifestation, |
15 | 251 | MANIFESTATION_U1_CONTACT_DATA_OBJECT) | 251 | MANIFESTATION_U1_CONTACT_DATA_OBJECT) |
16 | 252 | 252 | ||
17 | 253 | @defer.inlineCallbacks | ||
18 | 253 | def test_share_accepted_is_logged(self): | 254 | def test_share_accepted_is_logged(self): |
19 | 254 | """Test that an accepted share event is logged.""" | 255 | """Test that an accepted share event is logged.""" |
20 | 255 | # initialize the the root | 256 | # initialize the the root |
21 | @@ -260,7 +261,7 @@ | |||
22 | 260 | share_path = os.path.join(self.shares_dir, 'fake_share') | 261 | share_path = os.path.join(self.shares_dir, 'fake_share') |
23 | 261 | share = Share(path=share_path, volume_id='volume_id', node_id="node_id", | 262 | share = Share(path=share_path, volume_id='volume_id', node_id="node_id", |
24 | 262 | other_username=fake_username) | 263 | other_username=fake_username) |
26 | 263 | self.vm.add_share(share) | 264 | yield self.vm.add_share(share) |
27 | 264 | 265 | ||
28 | 265 | self.assertEqual(len(self.listener.zg.events), 1) | 266 | self.assertEqual(len(self.listener.zg.events), 1) |
29 | 266 | event = self.listener.zg.events[0] | 267 | event = self.listener.zg.events[0] |
30 | @@ -300,7 +301,8 @@ | |||
31 | 300 | fake_username, | 301 | fake_username, |
32 | 301 | u'visible_name', 'Read') | 302 | u'visible_name', 'Read') |
33 | 302 | 303 | ||
35 | 303 | self.main.vm.add_share(Share.from_notify_holder(holder, share_path)) | 304 | share = Share.from_notify_holder(holder, share_path) |
36 | 305 | yield self.main.vm.add_share(share) | ||
37 | 304 | self._listen_for('VM_VOLUME_DELETED', d.callback, 1, collect=True) | 306 | self._listen_for('VM_VOLUME_DELETED', d.callback, 1, collect=True) |
38 | 305 | self.main.event_q.push('SV_SHARE_DELETED', share_id=holder.share_id) | 307 | self.main.event_q.push('SV_SHARE_DELETED', share_id=holder.share_id) |
39 | 306 | yield d | 308 | yield d |
40 | @@ -1092,8 +1094,8 @@ | |||
41 | 1092 | public_url = 'http://example.com/foo.mp3' | 1094 | public_url = 'http://example.com/foo.mp3' |
42 | 1093 | 1095 | ||
43 | 1094 | share_path = os.path.join(self.shares_dir, 'share') | 1096 | share_path = os.path.join(self.shares_dir, 'share') |
46 | 1095 | self.main.vm.add_share(Share(path=share_path, volume_id='share', | 1097 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share', |
47 | 1096 | other_username='other username')) | 1098 | other_username='other username')) |
48 | 1097 | path = os.path.join(share_path, "foo.mp3") | 1099 | path = os.path.join(share_path, "foo.mp3") |
49 | 1098 | self.main.fs.create(path, str(share_id)) | 1100 | self.main.fs.create(path, str(share_id)) |
50 | 1099 | self.main.fs.set_node_id(path, str(node_id)) | 1101 | self.main.fs.set_node_id(path, str(node_id)) |
51 | @@ -1132,8 +1134,8 @@ | |||
52 | 1132 | public_url = 'http://example.com/foo.mp3' | 1134 | public_url = 'http://example.com/foo.mp3' |
53 | 1133 | 1135 | ||
54 | 1134 | share_path = os.path.join(self.shares_dir, 'share') | 1136 | share_path = os.path.join(self.shares_dir, 'share') |
57 | 1135 | self.main.vm.add_share(Share(path=share_path, volume_id='share', | 1137 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share', |
58 | 1136 | other_username='other username')) | 1138 | other_username='other username')) |
59 | 1137 | path = os.path.join(share_path, "foo.mp3") | 1139 | path = os.path.join(share_path, "foo.mp3") |
60 | 1138 | self.main.fs.create(path, str(share_id)) | 1140 | self.main.fs.create(path, str(share_id)) |
61 | 1139 | self.main.fs.set_node_id(path, str(node_id)) | 1141 | self.main.fs.set_node_id(path, str(node_id)) |
62 | 1140 | 1142 | ||
63 | === modified file 'tests/platform/linux/test_dbus.py' | |||
64 | --- tests/platform/linux/test_dbus.py 2011-02-02 13:10:59 +0000 | |||
65 | +++ tests/platform/linux/test_dbus.py 2011-02-03 17:29:42 +0000 | |||
66 | @@ -424,10 +424,11 @@ | |||
67 | 424 | 424 | ||
68 | 425 | return d | 425 | return d |
69 | 426 | 426 | ||
70 | 427 | @defer.inlineCallbacks | ||
71 | 427 | def test_get_metadata_path(self): | 428 | def test_get_metadata_path(self): |
72 | 428 | """Test the FileSystem Object, getting MD by path.""" | 429 | """Test the FileSystem Object, getting MD by path.""" |
73 | 429 | share_path = os.path.join(self.shares_dir, 'share') | 430 | share_path = os.path.join(self.shares_dir, 'share') |
75 | 430 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 431 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
76 | 431 | path = os.path.join(share_path, "foo") | 432 | path = os.path.join(share_path, "foo") |
77 | 432 | self.fs_manager.create(path, "share") | 433 | self.fs_manager.create(path, "share") |
78 | 433 | self.fs_manager.set_node_id(path, "node_id") | 434 | self.fs_manager.set_node_id(path, "node_id") |
79 | @@ -446,12 +447,13 @@ | |||
80 | 446 | client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME) | 447 | client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME) |
81 | 447 | client.call_method('get_metadata', path, reply_handler=handler, | 448 | client.call_method('get_metadata', path, reply_handler=handler, |
82 | 448 | error_handler=self.error_handler) | 449 | error_handler=self.error_handler) |
84 | 449 | return d | 450 | yield d |
85 | 450 | 451 | ||
86 | 452 | @defer.inlineCallbacks | ||
87 | 451 | def test_get_metadata_path_symlink(self): | 453 | def test_get_metadata_path_symlink(self): |
88 | 452 | """Test the FileSystem Object, getting MD by path in a symlink.""" | 454 | """Test the FileSystem Object, getting MD by path in a symlink.""" |
89 | 453 | share_path = os.path.join(self.shares_dir, 'share') | 455 | share_path = os.path.join(self.shares_dir, 'share') |
91 | 454 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 456 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
92 | 455 | path = os.path.join(share_path, "foo") | 457 | path = os.path.join(share_path, "foo") |
93 | 456 | symlink_path = os.path.join(self.shares_dir, "share_symlink") | 458 | symlink_path = os.path.join(self.shares_dir, "share_symlink") |
94 | 457 | share_context = self.main.fs._enable_share_write('share', | 459 | share_context = self.main.fs._enable_share_write('share', |
95 | @@ -468,7 +470,8 @@ | |||
96 | 468 | 470 | ||
97 | 469 | def callback(result): | 471 | def callback(result): |
98 | 470 | """Callback to check the result.""" | 472 | """Callback to check the result.""" |
100 | 471 | self.assertEquals(os.path.join(symlink_path, 'foo'), str(result['path'])) | 473 | self.assertEquals(os.path.join(symlink_path, 'foo'), |
101 | 474 | str(result['path'])) | ||
102 | 472 | self.assertEquals('share', result['share_id']) | 475 | self.assertEquals('share', result['share_id']) |
103 | 473 | self.assertEquals('node_id', result['node_id']) | 476 | self.assertEquals('node_id', result['node_id']) |
104 | 474 | 477 | ||
105 | @@ -477,12 +480,13 @@ | |||
106 | 477 | client.call_method('get_metadata', os.path.join(symlink_path, 'foo'), | 480 | client.call_method('get_metadata', os.path.join(symlink_path, 'foo'), |
107 | 478 | reply_handler=handler, | 481 | reply_handler=handler, |
108 | 479 | error_handler=self.error_handler) | 482 | error_handler=self.error_handler) |
110 | 480 | return d | 483 | yield d |
111 | 481 | 484 | ||
112 | 485 | @defer.inlineCallbacks | ||
113 | 482 | def test_get_metadata_share_node(self): | 486 | def test_get_metadata_share_node(self): |
114 | 483 | """Test the FileSystem Object, getting MD by share and node.""" | 487 | """Test the FileSystem Object, getting MD by share and node.""" |
115 | 484 | share_path = os.path.join(self.shares_dir, 'share') | 488 | share_path = os.path.join(self.shares_dir, 'share') |
117 | 485 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 489 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
118 | 486 | path = os.path.join(share_path, "foo") | 490 | path = os.path.join(share_path, "foo") |
119 | 487 | self.fs_manager.create(path, "share") | 491 | self.fs_manager.create(path, "share") |
120 | 488 | self.fs_manager.set_node_id(path, "node_id") | 492 | self.fs_manager.set_node_id(path, "node_id") |
121 | @@ -502,7 +506,7 @@ | |||
122 | 502 | client.call_method('get_metadata_by_node', 'share', 'node_id', | 506 | client.call_method('get_metadata_by_node', 'share', 'node_id', |
123 | 503 | reply_handler=handler, | 507 | reply_handler=handler, |
124 | 504 | error_handler=self.error_handler) | 508 | error_handler=self.error_handler) |
126 | 505 | return d | 509 | yield d |
127 | 506 | 510 | ||
128 | 507 | def test_push_event(self): | 511 | def test_push_event(self): |
129 | 508 | """Test the exposed method: push_event.""" | 512 | """Test the exposed method: push_event.""" |
130 | @@ -540,6 +544,7 @@ | |||
131 | 540 | self.event_q.add_empty_event_queue_callback(empty_queue_cb) | 544 | self.event_q.add_empty_event_queue_callback(empty_queue_cb) |
132 | 541 | return push_deferred | 545 | return push_deferred |
133 | 542 | 546 | ||
134 | 547 | @defer.inlineCallbacks | ||
135 | 543 | def test_waiting_content(self): | 548 | def test_waiting_content(self): |
136 | 544 | """Test Status.waiting_content. | 549 | """Test Status.waiting_content. |
137 | 545 | 550 | ||
138 | @@ -552,7 +557,8 @@ | |||
139 | 552 | 557 | ||
140 | 553 | # prepare the VM so it lies for us | 558 | # prepare the VM so it lies for us |
141 | 554 | share_path = os.path.join(self.shares_dir, 'share') | 559 | share_path = os.path.join(self.shares_dir, 'share') |
143 | 555 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 560 | share = Share(path=share_path, volume_id='share_id') |
144 | 561 | yield self.main.vm.add_share(share) | ||
145 | 556 | b_path = os.path.join(share_path, "path_b") | 562 | b_path = os.path.join(share_path, "path_b") |
146 | 557 | c_path = os.path.join(share_path, "path_c") | 563 | c_path = os.path.join(share_path, "path_c") |
147 | 558 | self.fs_manager.create(b_path, "share_id") | 564 | self.fs_manager.create(b_path, "share_id") |
148 | @@ -582,13 +588,15 @@ | |||
149 | 582 | client.call_method('waiting_content', | 588 | client.call_method('waiting_content', |
150 | 583 | reply_handler=waiting_handler, | 589 | reply_handler=waiting_handler, |
151 | 584 | error_handler=self.error_handler) | 590 | error_handler=self.error_handler) |
153 | 585 | return d | 591 | yield d |
154 | 586 | 592 | ||
155 | 593 | @defer.inlineCallbacks | ||
156 | 587 | def test_waiting_metadata(self): | 594 | def test_waiting_metadata(self): |
157 | 588 | """Test Status.waiting_metadata with fake data in the AQ.""" | 595 | """Test Status.waiting_metadata with fake data in the AQ.""" |
158 | 589 | # prepare the VM so it lies for us | 596 | # prepare the VM so it lies for us |
159 | 590 | share_path = os.path.join(self.shares_dir, 'share') | 597 | share_path = os.path.join(self.shares_dir, 'share') |
161 | 591 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 598 | share = Share(path=share_path, volume_id='share_id') |
162 | 599 | yield self.main.vm.add_share(share) | ||
163 | 592 | b_path = os.path.join(share_path, "path_b") | 600 | b_path = os.path.join(share_path, "path_b") |
164 | 593 | c_path = os.path.join(share_path, "path_c") | 601 | c_path = os.path.join(share_path, "path_c") |
165 | 594 | d_path = os.path.join(share_path, "path_d") | 602 | d_path = os.path.join(share_path, "path_d") |
166 | @@ -635,15 +643,17 @@ | |||
167 | 635 | client.call_method('waiting_metadata', | 643 | client.call_method('waiting_metadata', |
168 | 636 | reply_handler=waiting_handler, | 644 | reply_handler=waiting_handler, |
169 | 637 | error_handler=self.error_handler) | 645 | error_handler=self.error_handler) |
171 | 638 | return d | 646 | yield d |
172 | 639 | 647 | ||
173 | 648 | @defer.inlineCallbacks | ||
174 | 640 | def test_get_metadata_and_quick_tree_not_synced(self): | 649 | def test_get_metadata_and_quick_tree_not_synced(self): |
175 | 641 | """Test Status.get_metadata_and_quick_tree_status. | 650 | """Test Status.get_metadata_and_quick_tree_status. |
176 | 642 | 651 | ||
177 | 643 | Fake data in the AQ is used. | 652 | Fake data in the AQ is used. |
178 | 644 | """ | 653 | """ |
179 | 645 | share_path = os.path.join(self.shares_dir, 'share') | 654 | share_path = os.path.join(self.shares_dir, 'share') |
181 | 646 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 655 | share = Share(path=share_path, volume_id='share') |
182 | 656 | yield self.main.vm.add_share(share) | ||
183 | 647 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) | 657 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) |
184 | 648 | self.fs_manager.create(path, "share") | 658 | self.fs_manager.create(path, "share") |
185 | 649 | self.fs_manager.set_node_id(path, "node_id") | 659 | self.fs_manager.set_node_id(path, "node_id") |
186 | @@ -669,15 +679,16 @@ | |||
187 | 669 | client.call_method('get_metadata_and_quick_tree_synced', | 679 | client.call_method('get_metadata_and_quick_tree_synced', |
188 | 670 | path, reply_handler=handler, | 680 | path, reply_handler=handler, |
189 | 671 | error_handler=self.error_handler) | 681 | error_handler=self.error_handler) |
191 | 672 | return d | 682 | yield d |
192 | 673 | 683 | ||
193 | 684 | @defer.inlineCallbacks | ||
194 | 674 | def test_get_metadata_and_quick_tree_no_blow_up_kthxbye(self): | 685 | def test_get_metadata_and_quick_tree_no_blow_up_kthxbye(self): |
195 | 675 | """Test Status.get_metadata_and_quick_tree_status. | 686 | """Test Status.get_metadata_and_quick_tree_status. |
196 | 676 | 687 | ||
197 | 677 | Fake data in the AQ is used. | 688 | Fake data in the AQ is used. |
198 | 678 | """ | 689 | """ |
199 | 679 | share_path = os.path.join(self.shares_dir, 'share') | 690 | share_path = os.path.join(self.shares_dir, 'share') |
201 | 680 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 691 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
202 | 681 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) | 692 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) |
203 | 682 | self.fs_manager.create(path, "share") | 693 | self.fs_manager.create(path, "share") |
204 | 683 | self.fs_manager.set_node_id(path, "node_id") | 694 | self.fs_manager.set_node_id(path, "node_id") |
205 | @@ -704,15 +715,16 @@ | |||
206 | 704 | client.call_method('get_metadata_and_quick_tree_synced', | 715 | client.call_method('get_metadata_and_quick_tree_synced', |
207 | 705 | path, reply_handler=handler, | 716 | path, reply_handler=handler, |
208 | 706 | error_handler=self.error_handler) | 717 | error_handler=self.error_handler) |
210 | 707 | return d | 718 | yield d |
211 | 708 | 719 | ||
212 | 720 | @defer.inlineCallbacks | ||
213 | 709 | def test_get_metadata_and_quick_tree_not_synced_2(self): | 721 | def test_get_metadata_and_quick_tree_not_synced_2(self): |
214 | 710 | """Test Status.get_metadata_and_quick_tree_status. | 722 | """Test Status.get_metadata_and_quick_tree_status. |
215 | 711 | 723 | ||
216 | 712 | Fake data in the AQ is used. | 724 | Fake data in the AQ is used. |
217 | 713 | """ | 725 | """ |
218 | 714 | share_path = os.path.join(self.shares_dir, 'share') | 726 | share_path = os.path.join(self.shares_dir, 'share') |
220 | 715 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 727 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
221 | 716 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) | 728 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) |
222 | 717 | self.fs_manager.create(path, "share") | 729 | self.fs_manager.create(path, "share") |
223 | 718 | self.fs_manager.set_node_id(path, "node_id") | 730 | self.fs_manager.set_node_id(path, "node_id") |
224 | @@ -738,13 +750,14 @@ | |||
225 | 738 | client.call_method('get_metadata_and_quick_tree_synced', | 750 | client.call_method('get_metadata_and_quick_tree_synced', |
226 | 739 | path, reply_handler=handler, | 751 | path, reply_handler=handler, |
227 | 740 | error_handler=self.error_handler) | 752 | error_handler=self.error_handler) |
229 | 741 | return d | 753 | yield d |
230 | 742 | 754 | ||
231 | 755 | @defer.inlineCallbacks | ||
232 | 743 | def test_get_metadata_and_quick_tree_synced(self): | 756 | def test_get_metadata_and_quick_tree_synced(self): |
233 | 744 | """Test Status.get_metadata_and_quick_tree_status | 757 | """Test Status.get_metadata_and_quick_tree_status |
234 | 745 | without fake data in the AQ.""" | 758 | without fake data in the AQ.""" |
235 | 746 | share_path = os.path.join(self.shares_dir, 'share') | 759 | share_path = os.path.join(self.shares_dir, 'share') |
237 | 747 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 760 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
238 | 748 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) | 761 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) |
239 | 749 | self.fs_manager.create(path, "share") | 762 | self.fs_manager.create(path, "share") |
240 | 750 | self.fs_manager.set_node_id(path, "node_id") | 763 | self.fs_manager.set_node_id(path, "node_id") |
241 | @@ -766,13 +779,14 @@ | |||
242 | 766 | client.call_method('get_metadata_and_quick_tree_synced', | 779 | client.call_method('get_metadata_and_quick_tree_synced', |
243 | 767 | path, reply_handler=handler, | 780 | path, reply_handler=handler, |
244 | 768 | error_handler=self.error_handler) | 781 | error_handler=self.error_handler) |
246 | 769 | return d | 782 | yield d |
247 | 770 | 783 | ||
248 | 784 | @defer.inlineCallbacks | ||
249 | 771 | def test_get_metadata_and_quick_tree_synced_symlink(self): | 785 | def test_get_metadata_and_quick_tree_synced_symlink(self): |
250 | 772 | """Test Status.get_metadata_and_quick_tree_status | 786 | """Test Status.get_metadata_and_quick_tree_status |
251 | 773 | without fake data in the AQ.""" | 787 | without fake data in the AQ.""" |
252 | 774 | share_path = os.path.join(self.shares_dir, 'share') | 788 | share_path = os.path.join(self.shares_dir, 'share') |
254 | 775 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 789 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
255 | 776 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) | 790 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) |
256 | 777 | self.fs_manager.create(path, "share") | 791 | self.fs_manager.create(path, "share") |
257 | 778 | self.fs_manager.set_node_id(path, "node_id") | 792 | self.fs_manager.set_node_id(path, "node_id") |
258 | @@ -801,7 +815,7 @@ | |||
259 | 801 | client.call_method('get_metadata_and_quick_tree_synced', | 815 | client.call_method('get_metadata_and_quick_tree_synced', |
260 | 802 | expected_path, reply_handler=handler, | 816 | expected_path, reply_handler=handler, |
261 | 803 | error_handler=self.error_handler) | 817 | error_handler=self.error_handler) |
263 | 804 | return d | 818 | yield d |
264 | 805 | 819 | ||
265 | 806 | def test_content_queue_added(self): | 820 | def test_content_queue_added(self): |
266 | 807 | """Test the signal because a command was added to the queue.""" | 821 | """Test the signal because a command was added to the queue.""" |
267 | @@ -831,10 +845,12 @@ | |||
268 | 831 | self.main.event_q.push('SYS_QUEUE_REMOVED', FakeCommand()) | 845 | self.main.event_q.push('SYS_QUEUE_REMOVED', FakeCommand()) |
269 | 832 | return d | 846 | return d |
270 | 833 | 847 | ||
271 | 848 | @defer.inlineCallbacks | ||
272 | 834 | def test_current_downloads(self): | 849 | def test_current_downloads(self): |
273 | 835 | """Test Status.current_downloads with fake data in the AQ.""" | 850 | """Test Status.current_downloads with fake data in the AQ.""" |
274 | 836 | share_path = os.path.join(self.shares_dir, 'share') | 851 | share_path = os.path.join(self.shares_dir, 'share') |
276 | 837 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 852 | share = Share(path=share_path, volume_id='share_id') |
277 | 853 | yield self.main.vm.add_share(share) | ||
278 | 838 | down_path = os.path.join(share_path, "down_path") | 854 | down_path = os.path.join(share_path, "down_path") |
279 | 839 | self.fs_manager.create(down_path, "share_id") | 855 | self.fs_manager.create(down_path, "share_id") |
280 | 840 | self.fs_manager.set_node_id(down_path, "node_id") | 856 | self.fs_manager.set_node_id(down_path, "node_id") |
281 | @@ -853,12 +869,14 @@ | |||
282 | 853 | client.call_method('current_downloads', | 869 | client.call_method('current_downloads', |
283 | 854 | reply_handler=downloads_handler, | 870 | reply_handler=downloads_handler, |
284 | 855 | error_handler=self.error_handler) | 871 | error_handler=self.error_handler) |
286 | 856 | return d | 872 | yield d |
287 | 857 | 873 | ||
288 | 874 | @defer.inlineCallbacks | ||
289 | 858 | def test_current_uploads(self): | 875 | def test_current_uploads(self): |
290 | 859 | """Test Status.current_uploads with fake data in the AQ.""" | 876 | """Test Status.current_uploads with fake data in the AQ.""" |
291 | 860 | share_path = os.path.join(self.shares_dir, 'share') | 877 | share_path = os.path.join(self.shares_dir, 'share') |
293 | 861 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 878 | share = Share(path=share_path, volume_id='share_id') |
294 | 879 | yield self.main.vm.add_share(share) | ||
295 | 862 | up_path = os.path.join(share_path, "up_path") | 880 | up_path = os.path.join(share_path, "up_path") |
296 | 863 | self.fs_manager.create(up_path, "share_id") | 881 | self.fs_manager.create(up_path, "share_id") |
297 | 864 | self.fs_manager.set_node_id(up_path, "node_id") | 882 | self.fs_manager.set_node_id(up_path, "node_id") |
298 | @@ -877,7 +895,7 @@ | |||
299 | 877 | 895 | ||
300 | 878 | client.call_method('current_uploads', reply_handler=uploads_handler, | 896 | client.call_method('current_uploads', reply_handler=uploads_handler, |
301 | 879 | error_handler=self.error_handler) | 897 | error_handler=self.error_handler) |
303 | 880 | return d | 898 | yield d |
304 | 881 | 899 | ||
305 | 882 | def test_current_uploads_with_marker(self): | 900 | def test_current_uploads_with_marker(self): |
306 | 883 | """Test Status.current_uploads with fake data in the AQ.""" | 901 | """Test Status.current_uploads with fake data in the AQ.""" |
307 | @@ -895,17 +913,20 @@ | |||
308 | 895 | error_handler=self.error_handler) | 913 | error_handler=self.error_handler) |
309 | 896 | return d | 914 | return d |
310 | 897 | 915 | ||
311 | 916 | @defer.inlineCallbacks | ||
312 | 898 | def test_two_current_downloads(self): | 917 | def test_two_current_downloads(self): |
313 | 899 | """Test Status.current_downloads with fake data in the AQ.""" | 918 | """Test Status.current_downloads with fake data in the AQ.""" |
314 | 900 | share_path = os.path.join(self.shares_dir, 'share') | 919 | share_path = os.path.join(self.shares_dir, 'share') |
316 | 901 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 920 | share = Share(path=share_path, volume_id='share_id') |
317 | 921 | yield self.main.vm.add_share(share) | ||
318 | 902 | down_path = os.path.join(share_path, "down_path") | 922 | down_path = os.path.join(share_path, "down_path") |
319 | 903 | self.fs_manager.create(down_path, "share_id") | 923 | self.fs_manager.create(down_path, "share_id") |
320 | 904 | self.fs_manager.set_node_id(down_path, "node_id") | 924 | self.fs_manager.set_node_id(down_path, "node_id") |
321 | 905 | self.action_q.downloading[('share_id', 'node_id')] = dict( | 925 | self.action_q.downloading[('share_id', 'node_id')] = dict( |
322 | 906 | deflated_size=10, size=100, n_bytes_read=8) | 926 | deflated_size=10, size=100, n_bytes_read=8) |
323 | 907 | share1_path = os.path.join(self.shares_dir, 'share1') | 927 | share1_path = os.path.join(self.shares_dir, 'share1') |
325 | 908 | self.main.vm.add_share(Share(path=share1_path, volume_id='share_id_1')) | 928 | share1 = Share(path=share1_path, volume_id='share_id_1') |
326 | 929 | yield self.main.vm.add_share(share1) | ||
327 | 909 | down_path_1 = os.path.join(share1_path, "down_path_1") | 930 | down_path_1 = os.path.join(share1_path, "down_path_1") |
328 | 910 | self.fs_manager.create(down_path_1, "share_id_1") | 931 | self.fs_manager.create(down_path_1, "share_id_1") |
329 | 911 | self.fs_manager.set_node_id(down_path_1, "node_id_1") | 932 | self.fs_manager.set_node_id(down_path_1, "node_id_1") |
330 | @@ -927,19 +948,22 @@ | |||
331 | 927 | client.call_method('current_downloads', | 948 | client.call_method('current_downloads', |
332 | 928 | reply_handler=downloads_handler, | 949 | reply_handler=downloads_handler, |
333 | 929 | error_handler=self.error_handler) | 950 | error_handler=self.error_handler) |
335 | 930 | return d | 951 | yield d |
336 | 931 | 952 | ||
337 | 953 | @defer.inlineCallbacks | ||
338 | 932 | def test_two_current_uploads(self): | 954 | def test_two_current_uploads(self): |
339 | 933 | """Test Status.current_uploads with fake data in the AQ.""" | 955 | """Test Status.current_uploads with fake data in the AQ.""" |
340 | 934 | share_path = os.path.join(self.shares_dir, 'share') | 956 | share_path = os.path.join(self.shares_dir, 'share') |
342 | 935 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 957 | share = Share(path=share_path, volume_id='share_id') |
343 | 958 | yield self.main.vm.add_share(share) | ||
344 | 936 | up_path = os.path.join(share_path, "up_path") | 959 | up_path = os.path.join(share_path, "up_path") |
345 | 937 | self.fs_manager.create(up_path, "share_id") | 960 | self.fs_manager.create(up_path, "share_id") |
346 | 938 | self.fs_manager.set_node_id(up_path, "node_id") | 961 | self.fs_manager.set_node_id(up_path, "node_id") |
347 | 939 | self.action_q.uploading[('share_id', 'node_id')] = dict( | 962 | self.action_q.uploading[('share_id', 'node_id')] = dict( |
348 | 940 | deflated_size=100, n_bytes_written=10) | 963 | deflated_size=100, n_bytes_written=10) |
349 | 941 | share1_path = os.path.join(self.shares_dir, 'share1') | 964 | share1_path = os.path.join(self.shares_dir, 'share1') |
351 | 942 | self.main.vm.add_share(Share(path=share1_path, volume_id='share_id_1')) | 965 | share1 = Share(path=share1_path, volume_id='share_id_1') |
352 | 966 | yield self.main.vm.add_share(share1) | ||
353 | 943 | up_path_1 = os.path.join(share1_path, "up_path_1") | 967 | up_path_1 = os.path.join(share1_path, "up_path_1") |
354 | 944 | self.fs_manager.create(up_path_1, "share_id_1") | 968 | self.fs_manager.create(up_path_1, "share_id_1") |
355 | 945 | self.fs_manager.set_node_id(up_path_1, "node_id_1") | 969 | self.fs_manager.set_node_id(up_path_1, "node_id_1") |
356 | @@ -961,12 +985,14 @@ | |||
357 | 961 | 985 | ||
358 | 962 | client.call_method('current_uploads', reply_handler=uploads_handler, | 986 | client.call_method('current_uploads', reply_handler=uploads_handler, |
359 | 963 | error_handler=self.error_handler) | 987 | error_handler=self.error_handler) |
361 | 964 | return d | 988 | yield d |
362 | 965 | 989 | ||
363 | 990 | @defer.inlineCallbacks | ||
364 | 966 | def test_current_downloads_deflated_size_NA(self): | 991 | def test_current_downloads_deflated_size_NA(self): |
365 | 967 | """Test Status.current_downloads with fake data in the AQ.""" | 992 | """Test Status.current_downloads with fake data in the AQ.""" |
366 | 968 | share_path = os.path.join(self.shares_dir, 'share') | 993 | share_path = os.path.join(self.shares_dir, 'share') |
368 | 969 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 994 | share = Share(path=share_path, volume_id='share_id') |
369 | 995 | yield self.main.vm.add_share(share) | ||
370 | 970 | down_path = os.path.join(share_path, "down_path") | 996 | down_path = os.path.join(share_path, "down_path") |
371 | 971 | self.fs_manager.create(down_path, "share_id") | 997 | self.fs_manager.create(down_path, "share_id") |
372 | 972 | self.fs_manager.set_node_id(down_path, "node_id") | 998 | self.fs_manager.set_node_id(down_path, "node_id") |
373 | @@ -984,12 +1010,14 @@ | |||
374 | 984 | client.call_method('current_downloads', | 1010 | client.call_method('current_downloads', |
375 | 985 | reply_handler=downloads_handler, | 1011 | reply_handler=downloads_handler, |
376 | 986 | error_handler=self.error_handler) | 1012 | error_handler=self.error_handler) |
378 | 987 | return d | 1013 | yield d |
379 | 988 | 1014 | ||
380 | 1015 | @defer.inlineCallbacks | ||
381 | 989 | def test_current_uploads_deflated_size_NA(self): | 1016 | def test_current_uploads_deflated_size_NA(self): |
382 | 990 | """Test Status.current_uploads with fake data in the AQ.""" | 1017 | """Test Status.current_uploads with fake data in the AQ.""" |
383 | 991 | share_path = os.path.join(self.shares_dir, 'share') | 1018 | share_path = os.path.join(self.shares_dir, 'share') |
385 | 992 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 1019 | share = Share(path=share_path, volume_id='share_id') |
386 | 1020 | yield self.main.vm.add_share(share) | ||
387 | 993 | up_path = os.path.join(share_path, "up_path") | 1021 | up_path = os.path.join(share_path, "up_path") |
388 | 994 | self.fs_manager.create(up_path, "share_id") | 1022 | self.fs_manager.create(up_path, "share_id") |
389 | 995 | self.fs_manager.set_node_id(up_path, "node_id") | 1023 | self.fs_manager.set_node_id(up_path, "node_id") |
390 | @@ -1007,7 +1035,7 @@ | |||
391 | 1007 | 1035 | ||
392 | 1008 | client.call_method('current_uploads', reply_handler=uploads_handler, | 1036 | client.call_method('current_uploads', reply_handler=uploads_handler, |
393 | 1009 | error_handler=self.error_handler) | 1037 | error_handler=self.error_handler) |
395 | 1010 | return d | 1038 | yield d |
396 | 1011 | 1039 | ||
397 | 1012 | def test_nm_signals(self): | 1040 | def test_nm_signals(self): |
398 | 1013 | """Test that NM signals are received and handled properly.""" | 1041 | """Test that NM signals are received and handled properly.""" |
399 | @@ -1036,11 +1064,13 @@ | |||
400 | 1036 | self.event_q.add_empty_event_queue_callback(empty_queue_cb) | 1064 | self.event_q.add_empty_event_queue_callback(empty_queue_cb) |
401 | 1037 | return d | 1065 | return d |
402 | 1038 | 1066 | ||
403 | 1067 | @defer.inlineCallbacks | ||
404 | 1039 | def test_get_shares(self): | 1068 | def test_get_shares(self): |
405 | 1040 | """Test Shares.get_shares method.""" | 1069 | """Test Shares.get_shares method.""" |
406 | 1041 | share_path = os.path.join(self.main.shares_dir, 'share') | 1070 | share_path = os.path.join(self.main.shares_dir, 'share') |
409 | 1042 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id', | 1071 | share = Share(path=share_path, volume_id='share_id', |
410 | 1043 | access_level='Read', accepted=False)) | 1072 | access_level='Read', accepted=False) |
411 | 1073 | yield self.main.vm.add_share(share) | ||
412 | 1044 | client = DBusClient(self.bus, '/shares', DBUS_IFACE_SHARES_NAME) | 1074 | client = DBusClient(self.bus, '/shares', DBUS_IFACE_SHARES_NAME) |
413 | 1045 | d = defer.Deferred() | 1075 | d = defer.Deferred() |
414 | 1046 | def check(shares): | 1076 | def check(shares): |
415 | @@ -1056,19 +1086,21 @@ | |||
416 | 1056 | self.assertEquals('share_id', str(share['volume_id'])) | 1086 | self.assertEquals('share_id', str(share['volume_id'])) |
417 | 1057 | self.assertEquals(share_path, str(share['path'])) | 1087 | self.assertEquals(share_path, str(share['path'])) |
418 | 1058 | self.assertEquals('Read', str(share['access_level'])) | 1088 | self.assertEquals('Read', str(share['access_level'])) |
420 | 1059 | self.assertEquals('False', str(share['accepted'])) | 1089 | self.assertEquals('', str(share['accepted'])) |
421 | 1060 | 1090 | ||
422 | 1061 | def shares_handler(shares): | 1091 | def shares_handler(shares): |
423 | 1062 | d.callback(shares) | 1092 | d.callback(shares) |
424 | 1063 | 1093 | ||
425 | 1064 | client.call_method('get_shares', reply_handler=shares_handler, | 1094 | client.call_method('get_shares', reply_handler=shares_handler, |
426 | 1065 | error_handler=self.error_handler) | 1095 | error_handler=self.error_handler) |
428 | 1066 | return d | 1096 | d.addCallback(check) |
429 | 1097 | yield d | ||
430 | 1067 | 1098 | ||
431 | 1099 | @defer.inlineCallbacks | ||
432 | 1068 | def test_accept_share(self): | 1100 | def test_accept_share(self): |
433 | 1069 | """Test the accept_share method in dbus_interface.Share.""" | 1101 | """Test the accept_share method in dbus_interface.Share.""" |
434 | 1070 | share_path = os.path.join(self.main.shares_dir, 'share') | 1102 | share_path = os.path.join(self.main.shares_dir, 'share') |
436 | 1071 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id', | 1103 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share_id', |
437 | 1072 | access_level='Read', accepted=False, | 1104 | access_level='Read', accepted=False, |
438 | 1073 | node_id="node_id")) | 1105 | node_id="node_id")) |
439 | 1074 | self.assertEquals(False, self.main.vm.shares['share_id'].accepted) | 1106 | self.assertEquals(False, self.main.vm.shares['share_id'].accepted) |
440 | @@ -1088,12 +1120,13 @@ | |||
441 | 1088 | self.assertEquals(True, self.main.vm.shares['share_id'].accepted) | 1120 | self.assertEquals(True, self.main.vm.shares['share_id'].accepted) |
442 | 1089 | 1121 | ||
443 | 1090 | d.addCallback(check) | 1122 | d.addCallback(check) |
445 | 1091 | return d | 1123 | yield d |
446 | 1092 | 1124 | ||
447 | 1125 | @defer.inlineCallbacks | ||
448 | 1093 | def test_reject_share(self): | 1126 | def test_reject_share(self): |
449 | 1094 | """Test the reject_share method in dbus_interface.Share.""" | 1127 | """Test the reject_share method in dbus_interface.Share.""" |
450 | 1095 | share_path = os.path.join(self.main.shares_dir, 'share') | 1128 | share_path = os.path.join(self.main.shares_dir, 'share') |
452 | 1096 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id', | 1129 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share_id', |
453 | 1097 | access_level='Read', accepted=False)) | 1130 | access_level='Read', accepted=False)) |
454 | 1098 | self.assertEquals(False, self.main.vm.shares['share_id'].accepted) | 1131 | self.assertEquals(False, self.main.vm.shares['share_id'].accepted) |
455 | 1099 | client = DBusClient(self.bus, '/shares', DBUS_IFACE_SHARES_NAME) | 1132 | client = DBusClient(self.bus, '/shares', DBUS_IFACE_SHARES_NAME) |
456 | @@ -1112,7 +1145,7 @@ | |||
457 | 1112 | self.assertEquals(False, self.main.vm.shares['share_id'].accepted) | 1145 | self.assertEquals(False, self.main.vm.shares['share_id'].accepted) |
458 | 1113 | 1146 | ||
459 | 1114 | d.addCallback(check) | 1147 | d.addCallback(check) |
461 | 1115 | return d | 1148 | yield d |
462 | 1116 | 1149 | ||
463 | 1117 | def test_get_root(self): | 1150 | def test_get_root(self): |
464 | 1118 | """Check SycnDaemon.get_root exposed method.""" | 1151 | """Check SycnDaemon.get_root exposed method.""" |
465 | @@ -1349,18 +1382,20 @@ | |||
466 | 1349 | share = Share(path=share_path, volume_id=str(uuid.uuid4()), | 1382 | share = Share(path=share_path, volume_id=str(uuid.uuid4()), |
467 | 1350 | access_level='Modify', accepted=True, | 1383 | access_level='Modify', accepted=True, |
468 | 1351 | node_id=str(uuid.uuid4())) | 1384 | node_id=str(uuid.uuid4())) |
470 | 1352 | self.main.vm.add_share(share) | 1385 | yield self.main.vm.add_share(share) |
471 | 1353 | client = DBusClient(self.bus, '/', DBUS_IFACE_SYNC_NAME) | 1386 | client = DBusClient(self.bus, '/', DBUS_IFACE_SYNC_NAME) |
472 | 1387 | |||
473 | 1388 | rescan_d = defer.Deferred() | ||
474 | 1389 | self.main.action_q.rescan_from_scratch = rescan_d.callback | ||
475 | 1390 | |||
476 | 1354 | d = defer.Deferred() | 1391 | d = defer.Deferred() |
477 | 1355 | def fake_rescan_from_scratch(volume_id): | ||
478 | 1356 | """Stub method.""" | ||
479 | 1357 | d.callback(volume_id) | ||
480 | 1358 | self.main.action_q.rescan_from_scratch = fake_rescan_from_scratch | ||
481 | 1359 | d.addCallback(self.assertTrue) | ||
482 | 1360 | client.call_method('rescan_from_scratch', share.volume_id, | 1392 | client.call_method('rescan_from_scratch', share.volume_id, |
484 | 1361 | reply_handler=lambda _: None, | 1393 | reply_handler=d.callback, |
485 | 1362 | error_handler=d.errback) | 1394 | error_handler=d.errback) |
487 | 1363 | vol_id = yield d | 1395 | |
488 | 1396 | yield d | ||
489 | 1397 | |||
490 | 1398 | vol_id = yield rescan_d | ||
491 | 1364 | self.assertEqual(vol_id, share.volume_id) | 1399 | self.assertEqual(vol_id, share.volume_id) |
492 | 1365 | 1400 | ||
493 | 1366 | @defer.inlineCallbacks | 1401 | @defer.inlineCallbacks |
494 | @@ -1422,13 +1457,14 @@ | |||
495 | 1422 | class DBusInterfaceUnicodeTests(DBusTwistedTestCase): | 1457 | class DBusInterfaceUnicodeTests(DBusTwistedTestCase): |
496 | 1423 | """Unicode variant of basic tests to the objects exposed with D-Bus.""" | 1458 | """Unicode variant of basic tests to the objects exposed with D-Bus.""" |
497 | 1424 | 1459 | ||
498 | 1460 | @defer.inlineCallbacks | ||
499 | 1425 | def test_filesystem_unicode(self): | 1461 | def test_filesystem_unicode(self): |
500 | 1426 | """Test the FileSystem Object, registering it to the session bus. | 1462 | """Test the FileSystem Object, registering it to the session bus. |
501 | 1427 | 1463 | ||
502 | 1428 | Excercise the API. | 1464 | Excercise the API. |
503 | 1429 | """ | 1465 | """ |
504 | 1430 | share_path = os.path.join(self.shares_dir, 'share') | 1466 | share_path = os.path.join(self.shares_dir, 'share') |
506 | 1431 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 1467 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
507 | 1432 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) | 1468 | path = os.path.join(share_path, u'ñoño'.encode('utf-8')) |
508 | 1433 | self.fs_manager.create(path, "share") | 1469 | self.fs_manager.create(path, "share") |
509 | 1434 | self.fs_manager.set_node_id(path, "node_id") | 1470 | self.fs_manager.set_node_id(path, "node_id") |
510 | @@ -1447,7 +1483,7 @@ | |||
511 | 1447 | client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME) | 1483 | client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME) |
512 | 1448 | client.call_method('get_metadata', path, reply_handler=handler, | 1484 | client.call_method('get_metadata', path, reply_handler=handler, |
513 | 1449 | error_handler=self.error_handler) | 1485 | error_handler=self.error_handler) |
515 | 1450 | return d | 1486 | yield d |
516 | 1451 | 1487 | ||
517 | 1452 | def test_create_share_unicode(self): | 1488 | def test_create_share_unicode(self): |
518 | 1453 | """Test share offering.""" | 1489 | """Test share offering.""" |
519 | @@ -1480,6 +1516,7 @@ | |||
520 | 1480 | error_handler=self.error_handler) | 1516 | error_handler=self.error_handler) |
521 | 1481 | return d | 1517 | return d |
522 | 1482 | 1518 | ||
523 | 1519 | @defer.inlineCallbacks | ||
524 | 1483 | def test_get_shared_unicode(self): | 1520 | def test_get_shared_unicode(self): |
525 | 1484 | """Test that list_shared method behaves with unicode data.""" | 1521 | """Test that list_shared method behaves with unicode data.""" |
526 | 1485 | a_dir = os.path.join(self.root_dir, u'ñoño'.encode('utf-8')) | 1522 | a_dir = os.path.join(self.root_dir, u'ñoño'.encode('utf-8')) |
527 | @@ -1488,7 +1525,7 @@ | |||
528 | 1488 | share = Shared(path=a_dir, volume_id='shared_id', name=u'ñoño_shared', | 1525 | share = Shared(path=a_dir, volume_id='shared_id', name=u'ñoño_shared', |
529 | 1489 | access_level='View', other_username=u'test_username', | 1526 | access_level='View', other_username=u'test_username', |
530 | 1490 | node_id='node_id') | 1527 | node_id='node_id') |
532 | 1491 | self.main.vm.add_shared(share) | 1528 | yield self.main.vm.add_shared(share) |
533 | 1492 | client = DBusClient(self.bus, '/shares', DBUS_IFACE_SHARES_NAME) | 1529 | client = DBusClient(self.bus, '/shares', DBUS_IFACE_SHARES_NAME) |
534 | 1493 | d = defer.Deferred() | 1530 | d = defer.Deferred() |
535 | 1494 | 1531 | ||
536 | @@ -1504,7 +1541,7 @@ | |||
537 | 1504 | d.addCallback(check) | 1541 | d.addCallback(check) |
538 | 1505 | client.call_method('get_shared', | 1542 | client.call_method('get_shared', |
539 | 1506 | reply_handler=d.callback, error_handler=d.errback) | 1543 | reply_handler=d.callback, error_handler=d.errback) |
541 | 1507 | return d | 1544 | yield d |
542 | 1508 | 1545 | ||
543 | 1509 | 1546 | ||
544 | 1510 | class DBusSignalTest(DBusTwistedTestCase): | 1547 | class DBusSignalTest(DBusTwistedTestCase): |
545 | @@ -1823,6 +1860,7 @@ | |||
546 | 1823 | node_id='node', path=None, mdid=None) | 1860 | node_id='node', path=None, mdid=None) |
547 | 1824 | return d | 1861 | return d |
548 | 1825 | 1862 | ||
549 | 1863 | @defer.inlineCallbacks | ||
550 | 1826 | def test_share_changed(self): | 1864 | def test_share_changed(self): |
551 | 1827 | """Test the ShareChanged signal.""" | 1865 | """Test the ShareChanged signal.""" |
552 | 1828 | share_path = os.path.join(self.main.shares_dir, 'share') | 1866 | share_path = os.path.join(self.main.shares_dir, 'share') |
553 | @@ -1831,7 +1869,7 @@ | |||
554 | 1831 | u'test_username', | 1869 | u'test_username', |
555 | 1832 | u'visible_name', 'Write') | 1870 | u'visible_name', 'Write') |
556 | 1833 | 1871 | ||
558 | 1834 | self.main.vm.add_share(Share(path=share_path, | 1872 | yield self.main.vm.add_share(Share(path=share_path, |
559 | 1835 | volume_id=str(share_holder.share_id), | 1873 | volume_id=str(share_holder.share_id), |
560 | 1836 | node_id=str(share_holder.subtree), | 1874 | node_id=str(share_holder.subtree), |
561 | 1837 | access_level='Read', accepted=False)) | 1875 | access_level='Read', accepted=False)) |
562 | @@ -1850,8 +1888,9 @@ | |||
563 | 1850 | signal_name='ShareChanged') | 1888 | signal_name='ShareChanged') |
564 | 1851 | self.signal_receivers.add(match) | 1889 | self.signal_receivers.add(match) |
565 | 1852 | self.main.event_q.push('SV_SHARE_CHANGED', info=share_holder) | 1890 | self.main.event_q.push('SV_SHARE_CHANGED', info=share_holder) |
567 | 1853 | return d | 1891 | yield d |
568 | 1854 | 1892 | ||
569 | 1893 | @defer.inlineCallbacks | ||
570 | 1855 | def test_share_deleted(self): | 1894 | def test_share_deleted(self): |
571 | 1856 | """Test the ShareDeleted signal.""" | 1895 | """Test the ShareDeleted signal.""" |
572 | 1857 | share_path = os.path.join(self.main.shares_dir, 'share') | 1896 | share_path = os.path.join(self.main.shares_dir, 'share') |
573 | @@ -1859,15 +1898,11 @@ | |||
574 | 1859 | u'fake_share', | 1898 | u'fake_share', |
575 | 1860 | u'test_username', | 1899 | u'test_username', |
576 | 1861 | u'visible_name', 'Read') | 1900 | u'visible_name', 'Read') |
579 | 1862 | 1901 | share = Share.from_notify_holder(share_holder, share_path) | |
580 | 1863 | self.main.vm.add_share(Share.from_notify_holder(share_holder, share_path)) | 1902 | yield self.main.vm.add_share(share) |
581 | 1864 | d = defer.Deferred() | 1903 | d = defer.Deferred() |
588 | 1865 | def share_handler(share_dict): | 1904 | match = self.bus.add_signal_receiver(d.callback, |
589 | 1866 | """Handler for ShareDeletedsignal.""" | 1905 | signal_name='ShareDeleted') |
584 | 1867 | d.callback(share_dict) | ||
585 | 1868 | |||
586 | 1869 | match = self.bus.add_signal_receiver(share_handler, | ||
587 | 1870 | signal_name='ShareDeleted') | ||
590 | 1871 | self.signal_receivers.add(match) | 1906 | self.signal_receivers.add(match) |
591 | 1872 | 1907 | ||
592 | 1873 | def check(share_dict): | 1908 | def check(share_dict): |
593 | @@ -1888,13 +1923,9 @@ | |||
594 | 1888 | self.assertEquals(expected_dict[str(k)], str(v)) | 1923 | self.assertEquals(expected_dict[str(k)], str(v)) |
595 | 1889 | d.addCallback(check) | 1924 | d.addCallback(check) |
596 | 1890 | 1925 | ||
597 | 1891 | match = self.bus.add_signal_receiver(share_handler, | ||
598 | 1892 | signal_name='ShareDeleted') | ||
599 | 1893 | self.signal_receivers.add(match) | ||
600 | 1894 | |||
601 | 1895 | self.main.event_q.push('SV_SHARE_DELETED', | 1926 | self.main.event_q.push('SV_SHARE_DELETED', |
602 | 1896 | share_id=share_holder.share_id) | 1927 | share_id=share_holder.share_id) |
604 | 1897 | return d | 1928 | yield d |
605 | 1898 | 1929 | ||
606 | 1899 | def test_share_created(self): | 1930 | def test_share_created(self): |
607 | 1900 | """Test the ShareCreated signal.""" | 1931 | """Test the ShareCreated signal.""" |
608 | @@ -1960,6 +1991,7 @@ | |||
609 | 1960 | new_generation='new_generation') | 1991 | new_generation='new_generation') |
610 | 1961 | return d | 1992 | return d |
611 | 1962 | 1993 | ||
612 | 1994 | @defer.inlineCallbacks | ||
613 | 1963 | def test_new_share(self): | 1995 | def test_new_share(self): |
614 | 1964 | """Test the NewShare signal.""" | 1996 | """Test the NewShare signal.""" |
615 | 1965 | share_path = os.path.join(self.main.shares_dir, 'share') | 1997 | share_path = os.path.join(self.main.shares_dir, 'share') |
616 | @@ -1996,9 +2028,10 @@ | |||
617 | 1996 | for k, v in share_dict.items(): | 2028 | for k, v in share_dict.items(): |
618 | 1997 | self.assertEquals(expected_dict[str(k)], str(v)) | 2029 | self.assertEquals(expected_dict[str(k)], str(v)) |
619 | 1998 | d.addCallback(check) | 2030 | d.addCallback(check) |
622 | 1999 | self.main.vm.add_share(share) | 2031 | yield self.main.vm.add_share(share) |
623 | 2000 | return d | 2032 | yield d |
624 | 2001 | 2033 | ||
625 | 2034 | @defer.inlineCallbacks | ||
626 | 2002 | def test_public_access_changed(self): | 2035 | def test_public_access_changed(self): |
627 | 2003 | """Test the PublicAccessChanged signal.""" | 2036 | """Test the PublicAccessChanged signal.""" |
628 | 2004 | d = defer.Deferred() | 2037 | d = defer.Deferred() |
629 | @@ -2016,7 +2049,7 @@ | |||
630 | 2016 | public_url = 'http://example.com' | 2049 | public_url = 'http://example.com' |
631 | 2017 | 2050 | ||
632 | 2018 | share_path = os.path.join(self.shares_dir, 'share') | 2051 | share_path = os.path.join(self.shares_dir, 'share') |
634 | 2019 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 2052 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
635 | 2020 | path = os.path.join(share_path, "foo") | 2053 | path = os.path.join(share_path, "foo") |
636 | 2021 | self.fs_manager.create(path, str(share_id)) | 2054 | self.fs_manager.create(path, str(share_id)) |
637 | 2022 | self.fs_manager.set_node_id(path, str(node_id)) | 2055 | self.fs_manager.set_node_id(path, str(node_id)) |
638 | @@ -2033,8 +2066,9 @@ | |||
639 | 2033 | self.event_q.push('AQ_CHANGE_PUBLIC_ACCESS_OK', | 2066 | self.event_q.push('AQ_CHANGE_PUBLIC_ACCESS_OK', |
640 | 2034 | share_id=share_id, node_id=node_id, | 2067 | share_id=share_id, node_id=node_id, |
641 | 2035 | is_public=is_public, public_url=public_url) | 2068 | is_public=is_public, public_url=public_url) |
643 | 2036 | return d | 2069 | yield d |
644 | 2037 | 2070 | ||
645 | 2071 | @defer.inlineCallbacks | ||
646 | 2038 | def test_public_access_change_error(self): | 2072 | def test_public_access_change_error(self): |
647 | 2039 | """Test the PublicAccessChangeError signal.""" | 2073 | """Test the PublicAccessChangeError signal.""" |
648 | 2040 | d = defer.Deferred() | 2074 | d = defer.Deferred() |
649 | @@ -2051,7 +2085,7 @@ | |||
650 | 2051 | expected_error = 'error message' | 2085 | expected_error = 'error message' |
651 | 2052 | 2086 | ||
652 | 2053 | share_path = os.path.join(self.shares_dir, 'share') | 2087 | share_path = os.path.join(self.shares_dir, 'share') |
654 | 2054 | self.main.vm.add_share(Share(path=share_path, volume_id='share')) | 2088 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share')) |
655 | 2055 | path = os.path.join(share_path, "foo") | 2089 | path = os.path.join(share_path, "foo") |
656 | 2056 | self.fs_manager.create(path, str(share_id)) | 2090 | self.fs_manager.create(path, str(share_id)) |
657 | 2057 | self.fs_manager.set_node_id(path, str(node_id)) | 2091 | self.fs_manager.set_node_id(path, str(node_id)) |
658 | @@ -2067,7 +2101,7 @@ | |||
659 | 2067 | self.event_q.push('AQ_CHANGE_PUBLIC_ACCESS_ERROR', | 2101 | self.event_q.push('AQ_CHANGE_PUBLIC_ACCESS_ERROR', |
660 | 2068 | share_id=share_id, node_id=node_id, | 2102 | share_id=share_id, node_id=node_id, |
661 | 2069 | error=expected_error) | 2103 | error=expected_error) |
663 | 2070 | return d | 2104 | yield d |
664 | 2071 | 2105 | ||
665 | 2072 | def test_root_mismatch(self): | 2106 | def test_root_mismatch(self): |
666 | 2073 | """Test RootMismatch signal.""" | 2107 | """Test RootMismatch signal.""" |
667 | @@ -2089,6 +2123,7 @@ | |||
668 | 2089 | self.main.vm._got_root('another_root_id') | 2123 | self.main.vm._got_root('another_root_id') |
669 | 2090 | return d | 2124 | return d |
670 | 2091 | 2125 | ||
671 | 2126 | @defer.inlineCallbacks | ||
672 | 2092 | def test_public_files_list(self): | 2127 | def test_public_files_list(self): |
673 | 2093 | """Test the PublicAccessChanged signal.""" | 2128 | """Test the PublicAccessChanged signal.""" |
674 | 2094 | d = defer.Deferred() | 2129 | d = defer.Deferred() |
675 | @@ -2105,7 +2140,8 @@ | |||
676 | 2105 | public_url = 'http://example.com' | 2140 | public_url = 'http://example.com' |
677 | 2106 | 2141 | ||
678 | 2107 | share_path = os.path.join(self.shares_dir, 'share') | 2142 | share_path = os.path.join(self.shares_dir, 'share') |
680 | 2108 | self.main.vm.add_share(Share(path=share_path, volume_id=volume_id)) | 2143 | share = Share(path=share_path, volume_id=volume_id) |
681 | 2144 | yield self.main.vm.add_share(share) | ||
682 | 2109 | path = os.path.join(share_path, "foo") | 2145 | path = os.path.join(share_path, "foo") |
683 | 2110 | self.fs_manager.create(path, str(volume_id)) | 2146 | self.fs_manager.create(path, str(volume_id)) |
684 | 2111 | self.fs_manager.set_node_id(path, str(node_id)) | 2147 | self.fs_manager.set_node_id(path, str(node_id)) |
685 | @@ -2120,7 +2156,7 @@ | |||
686 | 2120 | d.addCallback(check) | 2156 | d.addCallback(check) |
687 | 2121 | pf = dict(volume_id=volume_id, node_id=node_id, public_url=public_url) | 2157 | pf = dict(volume_id=volume_id, node_id=node_id, public_url=public_url) |
688 | 2122 | self.event_q.push('AQ_PUBLIC_FILES_LIST_OK', public_files=[pf]) | 2158 | self.event_q.push('AQ_PUBLIC_FILES_LIST_OK', public_files=[pf]) |
690 | 2123 | return d | 2159 | yield d |
691 | 2124 | 2160 | ||
692 | 2125 | def test_public_files_list_error(self): | 2161 | def test_public_files_list_error(self): |
693 | 2126 | """Test the PublicFilesListError signal.""" | 2162 | """Test the PublicFilesListError signal.""" |
694 | @@ -2164,16 +2200,17 @@ | |||
695 | 2164 | volume_id=volume_id, free_bytes=123) | 2200 | volume_id=volume_id, free_bytes=123) |
696 | 2165 | return d | 2201 | return d |
697 | 2166 | 2202 | ||
698 | 2203 | @defer.inlineCallbacks | ||
699 | 2167 | def test_quota_exceeded_for_share(self): | 2204 | def test_quota_exceeded_for_share(self): |
700 | 2168 | """Test QuotaExceeded signal for share.""" | 2205 | """Test QuotaExceeded signal for share.""" |
701 | 2169 | volume_id = 'test this please' | 2206 | volume_id = 'test this please' |
702 | 2170 | path = 'test/path/bla' | 2207 | path = 'test/path/bla' |
703 | 2171 | name = 'Beatiful Stranger' | 2208 | name = 'Beatiful Stranger' |
709 | 2172 | a_share = Share(volume_id=volume_id, node_id=None, path=path, name=name, | 2209 | share = Share(volume_id=volume_id, node_id=None, path=path, name=name, |
710 | 2173 | other_username=None, other_visible_name=None, | 2210 | other_username=None, other_visible_name=None, |
711 | 2174 | accepted=False, access_level='View', free_bytes=None) | 2211 | accepted=False, access_level='View', free_bytes=None) |
712 | 2175 | self.main.vm.add_share(a_share) | 2212 | yield self.main.vm.add_share(share) |
713 | 2176 | return self.assert_quota_exceeded(volume_id, _get_share_dict(a_share)) | 2213 | yield self.assert_quota_exceeded(volume_id, _get_share_dict(share)) |
714 | 2177 | 2214 | ||
715 | 2178 | def test_quota_exceeded_for_udf(self): | 2215 | def test_quota_exceeded_for_udf(self): |
716 | 2179 | """Test QuotaExceeded signal for UDF.""" | 2216 | """Test QuotaExceeded signal for UDF.""" |
717 | @@ -2972,11 +3009,12 @@ | |||
718 | 2972 | 'VM_UDF_CREATE_ERROR', path=path, error="I'm broken") | 3009 | 'VM_UDF_CREATE_ERROR', path=path, error="I'm broken") |
719 | 2973 | return d | 3010 | return d |
720 | 2974 | 3011 | ||
721 | 3012 | @defer.inlineCallbacks | ||
722 | 2975 | def test_delete(self): | 3013 | def test_delete(self): |
723 | 2976 | """Test for Folders.delete.""" | 3014 | """Test for Folders.delete.""" |
724 | 2977 | suggested_path = u'~/ñoño' | 3015 | suggested_path = u'~/ñoño' |
725 | 2978 | udf = self._create_udf(uuid.uuid4(), 'node_id', suggested_path) | 3016 | udf = self._create_udf(uuid.uuid4(), 'node_id', suggested_path) |
727 | 2979 | self.main.vm.add_udf(udf) | 3017 | yield self.main.vm.add_udf(udf) |
728 | 2980 | d = defer.Deferred() | 3018 | d = defer.Deferred() |
729 | 2981 | def delete_volume(volume_id, path): | 3019 | def delete_volume(volume_id, path): |
730 | 2982 | """Fake delete_volume.""" | 3020 | """Fake delete_volume.""" |
731 | @@ -3001,13 +3039,14 @@ | |||
732 | 3001 | self.folders_client.call_method('delete', udf.volume_id, | 3039 | self.folders_client.call_method('delete', udf.volume_id, |
733 | 3002 | reply_handler=check_deleted, | 3040 | reply_handler=check_deleted, |
734 | 3003 | error_handler=self.error_handler) | 3041 | error_handler=self.error_handler) |
736 | 3004 | return d | 3042 | yield d |
737 | 3005 | 3043 | ||
738 | 3044 | @defer.inlineCallbacks | ||
739 | 3006 | def test_delete_error_signal(self): | 3045 | def test_delete_error_signal(self): |
740 | 3007 | """Test for FolderDeleteError.""" | 3046 | """Test for FolderDeleteError.""" |
741 | 3008 | suggested_path = u'~/ñoño' | 3047 | suggested_path = u'~/ñoño' |
742 | 3009 | udf = self._create_udf(uuid.uuid4(), 'node_id', suggested_path) | 3048 | udf = self._create_udf(uuid.uuid4(), 'node_id', suggested_path) |
744 | 3010 | self.main.vm.add_udf(udf) | 3049 | yield self.main.vm.add_udf(udf) |
745 | 3011 | d = defer.Deferred() | 3050 | d = defer.Deferred() |
746 | 3012 | # patch delete_volume to fail | 3051 | # patch delete_volume to fail |
747 | 3013 | def delete_volume(volume_id, path): | 3052 | def delete_volume(volume_id, path): |
748 | @@ -3026,8 +3065,8 @@ | |||
749 | 3026 | self.folders_client.call_method('delete', udf.volume_id, | 3065 | self.folders_client.call_method('delete', udf.volume_id, |
750 | 3027 | reply_handler=lambda *args: None, | 3066 | reply_handler=lambda *args: None, |
751 | 3028 | error_handler=self.error_handler) | 3067 | error_handler=self.error_handler) |
754 | 3029 | d.addCallback(lambda _: self.main.vm.udf_deleted(udf.volume_id)) | 3068 | yield d |
755 | 3030 | return d | 3069 | self.main.vm.udf_deleted(udf.volume_id) |
756 | 3031 | 3070 | ||
757 | 3032 | @defer.inlineCallbacks | 3071 | @defer.inlineCallbacks |
758 | 3033 | def test_delete_error_signal_folder_id(self): | 3072 | def test_delete_error_signal_folder_id(self): |
759 | @@ -3120,36 +3159,38 @@ | |||
760 | 3120 | d.addCallback(lambda _: self.main.vm.udf_deleted(udf.volume_id)) | 3159 | d.addCallback(lambda _: self.main.vm.udf_deleted(udf.volume_id)) |
761 | 3121 | yield d | 3160 | yield d |
762 | 3122 | 3161 | ||
763 | 3162 | @defer.inlineCallbacks | ||
764 | 3123 | def test_refresh_volumes(self): | 3163 | def test_refresh_volumes(self): |
765 | 3124 | """Just check that refresh_volumes method works.""" | 3164 | """Just check that refresh_volumes method works.""" |
766 | 3125 | client = DBusClient(self.bus, '/folders', DBUS_IFACE_FOLDERS_NAME) | 3165 | client = DBusClient(self.bus, '/folders', DBUS_IFACE_FOLDERS_NAME) |
767 | 3166 | list_volumes_d = defer.Deferred() | ||
768 | 3167 | self.main.action_q.list_volumes = lambda: list_volumes_d.callback(True) | ||
769 | 3168 | |||
770 | 3126 | d = defer.Deferred() | 3169 | d = defer.Deferred() |
771 | 3127 | def list_volumes(): | ||
772 | 3128 | """Stub list_volumes.""" | ||
773 | 3129 | d.callback(True) | ||
774 | 3130 | self.main.action_q.list_volumes = list_volumes | ||
775 | 3131 | client.call_method('refresh_volumes', | 3170 | client.call_method('refresh_volumes', |
777 | 3132 | reply_handler=lambda _: None, | 3171 | reply_handler=d.callback, |
778 | 3133 | error_handler=self.error_handler) | 3172 | error_handler=self.error_handler) |
780 | 3134 | return d | 3173 | yield list_volumes_d |
781 | 3174 | yield d | ||
782 | 3135 | 3175 | ||
783 | 3136 | 3176 | ||
784 | 3137 | class ShareTests(DBusTwistedTestCase): | 3177 | class ShareTests(DBusTwistedTestCase): |
785 | 3138 | """Share specific tests.""" | 3178 | """Share specific tests.""" |
786 | 3139 | 3179 | ||
787 | 3180 | @defer.inlineCallbacks | ||
788 | 3140 | def test_delete_share(self): | 3181 | def test_delete_share(self): |
789 | 3141 | """Test for Shares.delete_share.""" | 3182 | """Test for Shares.delete_share.""" |
790 | 3142 | share_path = os.path.join(self.main.shares_dir, 'share') | 3183 | share_path = os.path.join(self.main.shares_dir, 'share') |
791 | 3143 | share = Share(path=share_path, volume_id='share_id', | 3184 | share = Share(path=share_path, volume_id='share_id', |
792 | 3144 | node_id='node_id', accepted=True) | 3185 | node_id='node_id', accepted=True) |
794 | 3145 | self.main.vm.add_share(share) | 3186 | yield self.main.vm.add_share(share) |
795 | 3146 | d = defer.Deferred() | 3187 | d = defer.Deferred() |
796 | 3147 | def delete_volume(volume_id, path): | 3188 | def delete_volume(volume_id, path): |
797 | 3148 | """Fake delete_volume.""" | 3189 | """Fake delete_volume.""" |
798 | 3149 | self.main.event_q.push("AQ_DELETE_VOLUME_OK", volume_id=volume_id) | 3190 | self.main.event_q.push("AQ_DELETE_VOLUME_OK", volume_id=volume_id) |
799 | 3150 | self.main.action_q.delete_volume = delete_volume | 3191 | self.main.action_q.delete_volume = delete_volume |
800 | 3151 | def deleted_handler(info): | 3192 | def deleted_handler(info): |
802 | 3152 | """FolderDeleted handler.""" | 3193 | """ShareDeleted handler.""" |
803 | 3153 | self.assertRaises(KeyError, self.main.fs.get_by_path, | 3194 | self.assertRaises(KeyError, self.main.fs.get_by_path, |
804 | 3154 | info['path'].decode('utf-8')) | 3195 | info['path'].decode('utf-8')) |
805 | 3155 | self.assertRaises(VolumeDoesNotExist, | 3196 | self.assertRaises(VolumeDoesNotExist, |
806 | @@ -3168,14 +3209,15 @@ | |||
807 | 3168 | client.call_method('delete_share', share.volume_id, | 3209 | client.call_method('delete_share', share.volume_id, |
808 | 3169 | reply_handler=check_deleted, | 3210 | reply_handler=check_deleted, |
809 | 3170 | error_handler=self.error_handler) | 3211 | error_handler=self.error_handler) |
811 | 3171 | return d | 3212 | yield d |
812 | 3172 | 3213 | ||
813 | 3214 | @defer.inlineCallbacks | ||
814 | 3173 | def test_delete_share_from_me(self): | 3215 | def test_delete_share_from_me(self): |
815 | 3174 | """Test for Shares.delete_share with share from_me.""" | 3216 | """Test for Shares.delete_share with share from_me.""" |
816 | 3175 | share_path = os.path.join(self.main.shares_dir, 'share') | 3217 | share_path = os.path.join(self.main.shares_dir, 'share') |
817 | 3176 | share = Shared(path=share_path, volume_id='share_id', | 3218 | share = Shared(path=share_path, volume_id='share_id', |
818 | 3177 | node_id='node_id', accepted=True) | 3219 | node_id='node_id', accepted=True) |
820 | 3178 | self.main.vm.add_shared(share) | 3220 | yield self.main.vm.add_shared(share) |
821 | 3179 | d = defer.Deferred() | 3221 | d = defer.Deferred() |
822 | 3180 | def delete_share(volume_id): | 3222 | def delete_share(volume_id): |
823 | 3181 | """Fake delete_volume.""" | 3223 | """Fake delete_volume.""" |
824 | @@ -3193,14 +3235,15 @@ | |||
825 | 3193 | client.call_method('delete_share', share.volume_id, | 3235 | client.call_method('delete_share', share.volume_id, |
826 | 3194 | reply_handler=lambda _: None, | 3236 | reply_handler=lambda _: None, |
827 | 3195 | error_handler=self.error_handler) | 3237 | error_handler=self.error_handler) |
829 | 3196 | return d | 3238 | yield d |
830 | 3197 | 3239 | ||
831 | 3240 | @defer.inlineCallbacks | ||
832 | 3198 | def test_delete_share_error_signal(self): | 3241 | def test_delete_share_error_signal(self): |
833 | 3199 | """Test for Shares.delete_share with an error.""" | 3242 | """Test for Shares.delete_share with an error.""" |
834 | 3200 | share_path = os.path.join(self.main.shares_dir, 'share') | 3243 | share_path = os.path.join(self.main.shares_dir, 'share') |
835 | 3201 | share = Share(path=share_path, volume_id='share_id', | 3244 | share = Share(path=share_path, volume_id='share_id', |
836 | 3202 | node_id='node_id', accepted=True) | 3245 | node_id='node_id', accepted=True) |
838 | 3203 | self.main.vm.add_share(share) | 3246 | yield self.main.vm.add_share(share) |
839 | 3204 | d = defer.Deferred() | 3247 | d = defer.Deferred() |
840 | 3205 | # patch delete_volume to fail | 3248 | # patch delete_volume to fail |
841 | 3206 | def delete_volume(volume_id, path): | 3249 | def delete_volume(volume_id, path): |
842 | @@ -3209,7 +3252,7 @@ | |||
843 | 3209 | volume_id=volume_id, error="I'm broken") | 3252 | volume_id=volume_id, error="I'm broken") |
844 | 3210 | self.main.action_q.delete_volume = delete_volume | 3253 | self.main.action_q.delete_volume = delete_volume |
845 | 3211 | def deleted_error_handler(info, error): | 3254 | def deleted_error_handler(info, error): |
847 | 3212 | """FolderDeleteError handler.""" | 3255 | """ShareDeleteError handler.""" |
848 | 3213 | self.assertEquals(info['volume_id'], share.volume_id) | 3256 | self.assertEquals(info['volume_id'], share.volume_id) |
849 | 3214 | self.assertEquals(error, "I'm broken") | 3257 | self.assertEquals(error, "I'm broken") |
850 | 3215 | d.callback(True) | 3258 | d.callback(True) |
851 | @@ -3220,14 +3263,15 @@ | |||
852 | 3220 | client.call_method('delete_share', share.volume_id, | 3263 | client.call_method('delete_share', share.volume_id, |
853 | 3221 | reply_handler=lambda *args: None, | 3264 | reply_handler=lambda *args: None, |
854 | 3222 | error_handler=self.error_handler) | 3265 | error_handler=self.error_handler) |
856 | 3223 | return d | 3266 | yield d |
857 | 3224 | 3267 | ||
858 | 3268 | @defer.inlineCallbacks | ||
859 | 3225 | def test_delete_share_from_me_error(self): | 3269 | def test_delete_share_from_me_error(self): |
860 | 3226 | """Test failure of Shares.delete_share with a share from_me.""" | 3270 | """Test failure of Shares.delete_share with a share from_me.""" |
861 | 3227 | share_path = os.path.join(self.main.shares_dir, 'share') | 3271 | share_path = os.path.join(self.main.shares_dir, 'share') |
862 | 3228 | share = Shared(path=share_path, volume_id='share_id', | 3272 | share = Shared(path=share_path, volume_id='share_id', |
863 | 3229 | node_id='node_id', accepted=True) | 3273 | node_id='node_id', accepted=True) |
865 | 3230 | self.main.vm.add_shared(share) | 3274 | yield self.main.vm.add_shared(share) |
866 | 3231 | d = defer.Deferred() | 3275 | d = defer.Deferred() |
867 | 3232 | # patch delete_share to fail | 3276 | # patch delete_share to fail |
868 | 3233 | def delete_share(share_id): | 3277 | def delete_share(share_id): |
869 | @@ -3236,7 +3280,7 @@ | |||
870 | 3236 | share_id=share_id, error="I'm broken") | 3280 | share_id=share_id, error="I'm broken") |
871 | 3237 | self.patch(self.main.action_q, 'delete_share', delete_share) | 3281 | self.patch(self.main.action_q, 'delete_share', delete_share) |
872 | 3238 | def deleted_error_handler(info, error): | 3282 | def deleted_error_handler(info, error): |
874 | 3239 | """FolderDeleteError handler.""" | 3283 | """ShareDeleteError handler.""" |
875 | 3240 | self.assertEquals(info['volume_id'], share.volume_id) | 3284 | self.assertEquals(info['volume_id'], share.volume_id) |
876 | 3241 | self.assertEquals(error, "I'm broken") | 3285 | self.assertEquals(error, "I'm broken") |
877 | 3242 | d.callback(True) | 3286 | d.callback(True) |
878 | @@ -3247,14 +3291,14 @@ | |||
879 | 3247 | client.call_method('delete_share', share.volume_id, | 3291 | client.call_method('delete_share', share.volume_id, |
880 | 3248 | reply_handler=lambda *args: None, | 3292 | reply_handler=lambda *args: None, |
881 | 3249 | error_handler=self.error_handler) | 3293 | error_handler=self.error_handler) |
883 | 3250 | return d | 3294 | yield d |
884 | 3251 | 3295 | ||
885 | 3252 | def test_delete_share_from_me_doesnotexist(self): | 3296 | def test_delete_share_from_me_doesnotexist(self): |
886 | 3253 | """Test failure of Shares.delete_share with a share from_me.""" | 3297 | """Test failure of Shares.delete_share with a share from_me.""" |
887 | 3254 | d = defer.Deferred() | 3298 | d = defer.Deferred() |
888 | 3255 | # patch delete_share to fail | 3299 | # patch delete_share to fail |
889 | 3256 | def deleted_error_handler(info, error): | 3300 | def deleted_error_handler(info, error): |
891 | 3257 | """FolderDeleteError handler.""" | 3301 | """ShareDeleteError handler.""" |
892 | 3258 | self.assertEquals(info['volume_id'], 'missing_share_id') | 3302 | self.assertEquals(info['volume_id'], 'missing_share_id') |
893 | 3259 | self.assertEquals(error, "DOES_NOT_EXIST") | 3303 | self.assertEquals(error, "DOES_NOT_EXIST") |
894 | 3260 | d.callback(True) | 3304 | d.callback(True) |
895 | 3261 | 3305 | ||
896 | === modified file 'tests/platform/linux/test_filesystem_notifications.py' | |||
897 | --- tests/platform/linux/test_filesystem_notifications.py 2011-01-20 21:27:24 +0000 | |||
898 | +++ tests/platform/linux/test_filesystem_notifications.py 2011-02-03 17:29:42 +0000 | |||
899 | @@ -291,12 +291,13 @@ | |||
900 | 291 | class WatchTests(BaseFSMonitorTestCase): | 291 | class WatchTests(BaseFSMonitorTestCase): |
901 | 292 | """Test the EQ API to add and remove watchs.""" | 292 | """Test the EQ API to add and remove watchs.""" |
902 | 293 | 293 | ||
903 | 294 | @defer.inlineCallbacks | ||
904 | 294 | def _create_udf(self, path): | 295 | def _create_udf(self, path): |
905 | 295 | """Create an UDF and returns it and the volume""" | 296 | """Create an UDF and returns it and the volume""" |
906 | 296 | os.makedirs(path) | 297 | os.makedirs(path) |
907 | 297 | udf = volume_manager.UDF("vol_id", "node_id", path.decode('utf-8'), | 298 | udf = volume_manager.UDF("vol_id", "node_id", path.decode('utf-8'), |
908 | 298 | path, True) | 299 | path, True) |
910 | 299 | self.vm.add_udf(udf) | 300 | yield self.vm.add_udf(udf) |
911 | 300 | 301 | ||
912 | 301 | def test_add_general_watch(self): | 302 | def test_add_general_watch(self): |
913 | 302 | """Test that general watchs can be added.""" | 303 | """Test that general watchs can be added.""" |
914 | @@ -311,11 +312,12 @@ | |||
915 | 311 | # nothing in the udf ancestors watch | 312 | # nothing in the udf ancestors watch |
916 | 312 | self.assertEqual(self.monitor._ancestors_watchs, {}) | 313 | self.assertEqual(self.monitor._ancestors_watchs, {}) |
917 | 313 | 314 | ||
918 | 315 | @defer.inlineCallbacks | ||
919 | 314 | def test_add_watch_on_udf_ancestor(self): | 316 | def test_add_watch_on_udf_ancestor(self): |
920 | 315 | """Test that ancestors watchs can be added.""" | 317 | """Test that ancestors watchs can be added.""" |
921 | 316 | # create the udf and add the watch | 318 | # create the udf and add the watch |
922 | 317 | path_udf = os.path.join(self.home_dir, "path/to/UDF") | 319 | path_udf = os.path.join(self.home_dir, "path/to/UDF") |
924 | 318 | self._create_udf(path_udf) | 320 | yield self._create_udf(path_udf) |
925 | 319 | path_ancestor = os.path.join(self.home_dir, "path") | 321 | path_ancestor = os.path.join(self.home_dir, "path") |
926 | 320 | self.monitor.add_watch(path_ancestor) | 322 | self.monitor.add_watch(path_ancestor) |
927 | 321 | 323 | ||
928 | @@ -327,22 +329,24 @@ | |||
929 | 327 | # nothing in the general watch | 329 | # nothing in the general watch |
930 | 328 | self.assertEqual(self.monitor._general_watchs, {}) | 330 | self.assertEqual(self.monitor._general_watchs, {}) |
931 | 329 | 331 | ||
932 | 332 | @defer.inlineCallbacks | ||
933 | 330 | def test_add_watch_on_udf_exact(self): | 333 | def test_add_watch_on_udf_exact(self): |
934 | 331 | """Test adding the watch exactly on UDF.""" | 334 | """Test adding the watch exactly on UDF.""" |
935 | 332 | # create the udf and add the watch | 335 | # create the udf and add the watch |
936 | 333 | path_udf = os.path.join(self.home_dir, "path/to/UDF") | 336 | path_udf = os.path.join(self.home_dir, "path/to/UDF") |
938 | 334 | self._create_udf(path_udf) | 337 | yield self._create_udf(path_udf) |
939 | 335 | self.monitor.add_watch(path_udf) | 338 | self.monitor.add_watch(path_udf) |
940 | 336 | 339 | ||
941 | 337 | # pylint: disable-msg=W0212 | 340 | # pylint: disable-msg=W0212 |
942 | 338 | self.assertTrue(path_udf in self.monitor._general_watchs) | 341 | self.assertTrue(path_udf in self.monitor._general_watchs) |
943 | 339 | self.assertEqual(self.monitor._ancestors_watchs, {}) | 342 | self.assertEqual(self.monitor._ancestors_watchs, {}) |
944 | 340 | 343 | ||
945 | 344 | @defer.inlineCallbacks | ||
946 | 341 | def test_add_watch_on_udf_child(self): | 345 | def test_add_watch_on_udf_child(self): |
947 | 342 | """Test adding the watch inside UDF.""" | 346 | """Test adding the watch inside UDF.""" |
948 | 343 | # create the udf and add the watch | 347 | # create the udf and add the watch |
949 | 344 | path_udf = os.path.join(self.home_dir, "path/to/UDF") | 348 | path_udf = os.path.join(self.home_dir, "path/to/UDF") |
951 | 345 | self._create_udf(path_udf) | 349 | yield self._create_udf(path_udf) |
952 | 346 | path_ancestor = os.path.join(self.home_dir, "path/to/UDF/inside") | 350 | path_ancestor = os.path.join(self.home_dir, "path/to/UDF/inside") |
953 | 347 | os.mkdir(path_ancestor) | 351 | os.mkdir(path_ancestor) |
954 | 348 | self.monitor.add_watch(path_ancestor) | 352 | self.monitor.add_watch(path_ancestor) |
955 | @@ -364,12 +368,13 @@ | |||
956 | 364 | self.monitor.rm_watch(not_existing_dir) | 368 | self.monitor.rm_watch(not_existing_dir) |
957 | 365 | self.assertFalse(self.monitor.has_watch(not_existing_dir)) | 369 | self.assertFalse(self.monitor.has_watch(not_existing_dir)) |
958 | 366 | 370 | ||
959 | 371 | @defer.inlineCallbacks | ||
960 | 367 | def test_rm_watch_wrong(self): | 372 | def test_rm_watch_wrong(self): |
961 | 368 | """Test that general watchs can be removed.""" | 373 | """Test that general watchs can be removed.""" |
962 | 369 | # add two types of watchs | 374 | # add two types of watchs |
963 | 370 | self.monitor.add_watch(self.root_dir) | 375 | self.monitor.add_watch(self.root_dir) |
964 | 371 | path_udf = os.path.join(self.home_dir, "path/to/UDF") | 376 | path_udf = os.path.join(self.home_dir, "path/to/UDF") |
966 | 372 | self._create_udf(path_udf) | 377 | yield self._create_udf(path_udf) |
967 | 373 | path_ancestor = os.path.join(self.home_dir, "path") | 378 | path_ancestor = os.path.join(self.home_dir, "path") |
968 | 374 | self.monitor.add_watch(path_ancestor) | 379 | self.monitor.add_watch(path_ancestor) |
969 | 375 | 380 | ||
970 | @@ -388,11 +393,12 @@ | |||
971 | 388 | self.assertEqual(self.monitor._general_watchs, {}) | 393 | self.assertEqual(self.monitor._general_watchs, {}) |
972 | 389 | self.assertEqual(self.monitor._ancestors_watchs, {}) | 394 | self.assertEqual(self.monitor._ancestors_watchs, {}) |
973 | 390 | 395 | ||
974 | 396 | @defer.inlineCallbacks | ||
975 | 391 | def test_rm_watch_ancestor(self): | 397 | def test_rm_watch_ancestor(self): |
976 | 392 | """Test that ancestor watchs can be removed.""" | 398 | """Test that ancestor watchs can be removed.""" |
977 | 393 | # create the udf and add the watch | 399 | # create the udf and add the watch |
978 | 394 | path_udf = os.path.join(self.home_dir, "path/to/UDF") | 400 | path_udf = os.path.join(self.home_dir, "path/to/UDF") |
980 | 395 | self._create_udf(path_udf) | 401 | yield self._create_udf(path_udf) |
981 | 396 | path_ancestor = os.path.join(self.home_dir, "path") | 402 | path_ancestor = os.path.join(self.home_dir, "path") |
982 | 397 | self.monitor.add_watch(path_ancestor) | 403 | self.monitor.add_watch(path_ancestor) |
983 | 398 | 404 | ||
984 | @@ -414,10 +420,11 @@ | |||
985 | 414 | self.monitor.rm_watch(self.root_dir) | 420 | self.monitor.rm_watch(self.root_dir) |
986 | 415 | self.assertFalse(self.monitor.has_watch(self.root_dir)) | 421 | self.assertFalse(self.monitor.has_watch(self.root_dir)) |
987 | 416 | 422 | ||
988 | 423 | @defer.inlineCallbacks | ||
989 | 417 | def test_has_watch_ancestor(self): | 424 | def test_has_watch_ancestor(self): |
990 | 418 | """Test that an ancestor path is watched.""" | 425 | """Test that an ancestor path is watched.""" |
991 | 419 | path_udf = os.path.join(self.home_dir, "path/to/UDF") | 426 | path_udf = os.path.join(self.home_dir, "path/to/UDF") |
993 | 420 | self._create_udf(path_udf) | 427 | yield self._create_udf(path_udf) |
994 | 421 | path_ancestor = os.path.join(self.home_dir, "path") | 428 | path_ancestor = os.path.join(self.home_dir, "path") |
995 | 422 | 429 | ||
996 | 423 | self.assertFalse(self.monitor.has_watch(path_ancestor)) | 430 | self.assertFalse(self.monitor.has_watch(path_ancestor)) |
997 | 424 | 431 | ||
998 | === modified file 'tests/platform/linux/test_tools.py' | |||
999 | --- tests/platform/linux/test_tools.py 2011-01-17 20:14:09 +0000 | |||
1000 | +++ tests/platform/linux/test_tools.py 2011-02-03 17:29:42 +0000 | |||
1001 | @@ -48,14 +48,15 @@ | |||
1002 | 48 | self.rmtree(self.home_dir) | 48 | self.rmtree(self.home_dir) |
1003 | 49 | return DBusTwistedTestCase.tearDown(self) | 49 | return DBusTwistedTestCase.tearDown(self) |
1004 | 50 | 50 | ||
1005 | 51 | @defer.inlineCallbacks | ||
1006 | 51 | def create_file(self, path): | 52 | def create_file(self, path): |
1007 | 52 | """ creates a test file in fsm """ | 53 | """ creates a test file in fsm """ |
1008 | 53 | share_path = os.path.join(self.shares_dir, 'share_tools') | 54 | share_path = os.path.join(self.shares_dir, 'share_tools') |
1011 | 54 | self.main.vm.add_share(volume_manager.Share(share_path, | 55 | share = volume_manager.Share(share_path, volume_id='tools_share_id') |
1012 | 55 | volume_id='tools_share_id')) | 56 | yield self.main.vm.add_share(share) |
1013 | 56 | self.fs_manager.create(path, "tools_share_id") | 57 | self.fs_manager.create(path, "tools_share_id") |
1014 | 57 | self.fs_manager.set_node_id(path, "node_id") | 58 | self.fs_manager.set_node_id(path, "node_id") |
1016 | 58 | return 'tools_share_id', 'node_id' | 59 | defer.returnValue(('tools_share_id', 'node_id')) |
1017 | 59 | 60 | ||
1018 | 60 | 61 | ||
1019 | 61 | class TestToolsBasic(TestToolsBase): | 62 | class TestToolsBasic(TestToolsBase): |
1020 | 62 | 63 | ||
1021 | === modified file 'tests/syncdaemon/test_eq_inotify.py' | |||
1022 | --- tests/syncdaemon/test_eq_inotify.py 2011-01-12 13:30:03 +0000 | |||
1023 | +++ tests/syncdaemon/test_eq_inotify.py 2011-02-03 17:29:42 +0000 | |||
1024 | @@ -1745,23 +1745,25 @@ | |||
1025 | 1745 | self._deferred.addCallback(check) | 1745 | self._deferred.addCallback(check) |
1026 | 1746 | return self._deferred | 1746 | return self._deferred |
1027 | 1747 | 1747 | ||
1028 | 1748 | @defer.inlineCallbacks | ||
1029 | 1748 | def _create_udf(self, vol_id, path): | 1749 | def _create_udf(self, vol_id, path): |
1030 | 1749 | """Create an UDF and returns it and the volume""" | 1750 | """Create an UDF and returns it and the volume""" |
1031 | 1750 | os.makedirs(path) | 1751 | os.makedirs(path) |
1032 | 1751 | udf = volume_manager.UDF(vol_id, "node_id", path.decode('utf-8'), | 1752 | udf = volume_manager.UDF(vol_id, "node_id", path.decode('utf-8'), |
1033 | 1752 | path, True) | 1753 | path, True) |
1035 | 1753 | self.vm.add_udf(udf) | 1754 | yield self.vm.add_udf(udf) |
1036 | 1754 | 1755 | ||
1037 | 1756 | @defer.inlineCallbacks | ||
1038 | 1755 | def test_move_dir_across_volumes(self): | 1757 | def test_move_dir_across_volumes(self): |
1039 | 1756 | """Dir move between volumes is deletion and creation.""" | 1758 | """Dir move between volumes is deletion and creation.""" |
1040 | 1757 | # base dir 1 | 1759 | # base dir 1 |
1041 | 1758 | base1 = os.path.join(self.home_dir, "dir1") | 1760 | base1 = os.path.join(self.home_dir, "dir1") |
1043 | 1759 | self._create_udf('vol1', base1) | 1761 | yield self._create_udf('vol1', base1) |
1044 | 1760 | self.fs.create(path=base1, share_id='vol1', is_dir=True) | 1762 | self.fs.create(path=base1, share_id='vol1', is_dir=True) |
1045 | 1761 | 1763 | ||
1046 | 1762 | # base dir 2 | 1764 | # base dir 2 |
1047 | 1763 | base2 = os.path.join(self.home_dir, "dir2") | 1765 | base2 = os.path.join(self.home_dir, "dir2") |
1049 | 1764 | self._create_udf('vol2', base2) | 1766 | yield self._create_udf('vol2', base2) |
1050 | 1765 | self.fs.create(path=base2, share_id='vol2', is_dir=True) | 1767 | self.fs.create(path=base2, share_id='vol2', is_dir=True) |
1051 | 1766 | 1768 | ||
1052 | 1767 | # working stuff | 1769 | # working stuff |
1053 | @@ -1779,18 +1781,19 @@ | |||
1054 | 1779 | 1781 | ||
1055 | 1780 | # generate the event | 1782 | # generate the event |
1056 | 1781 | os.rename(moving1, moving2) | 1783 | os.rename(moving1, moving2) |
1058 | 1782 | return self._deferred | 1784 | yield self._deferred |
1059 | 1783 | 1785 | ||
1060 | 1786 | @defer.inlineCallbacks | ||
1061 | 1784 | def test_move_file_across_volumes(self): | 1787 | def test_move_file_across_volumes(self): |
1062 | 1785 | """File ove between volumes is deletion and creation (and write).""" | 1788 | """File ove between volumes is deletion and creation (and write).""" |
1063 | 1786 | # base dir 1 | 1789 | # base dir 1 |
1064 | 1787 | base1 = os.path.join(self.home_dir, "dir1") | 1790 | base1 = os.path.join(self.home_dir, "dir1") |
1066 | 1788 | self._create_udf('vol1', base1) | 1791 | yield self._create_udf('vol1', base1) |
1067 | 1789 | self.fs.create(path=base1, share_id='vol1', is_dir=True) | 1792 | self.fs.create(path=base1, share_id='vol1', is_dir=True) |
1068 | 1790 | 1793 | ||
1069 | 1791 | # base dir 2 | 1794 | # base dir 2 |
1070 | 1792 | base2 = os.path.join(self.home_dir, "dir2") | 1795 | base2 = os.path.join(self.home_dir, "dir2") |
1072 | 1793 | self._create_udf('vol2', base2) | 1796 | yield self._create_udf('vol2', base2) |
1073 | 1794 | self.fs.create(path=base2, share_id='vol2', is_dir=True) | 1797 | self.fs.create(path=base2, share_id='vol2', is_dir=True) |
1074 | 1795 | 1798 | ||
1075 | 1796 | # working stuff | 1799 | # working stuff |
1076 | @@ -1809,7 +1812,7 @@ | |||
1077 | 1809 | 1812 | ||
1078 | 1810 | # generate the event | 1813 | # generate the event |
1079 | 1811 | os.rename(moving1, moving2) | 1814 | os.rename(moving1, moving2) |
1081 | 1812 | return self._deferred | 1815 | yield self._deferred |
1082 | 1813 | 1816 | ||
1083 | 1814 | 1817 | ||
1084 | 1815 | def test_suite(): | 1818 | def test_suite(): |
1085 | 1816 | 1819 | ||
1086 | === modified file 'tests/syncdaemon/test_fsm.py' | |||
1087 | --- tests/syncdaemon/test_fsm.py 2011-01-20 21:27:24 +0000 | |||
1088 | +++ tests/syncdaemon/test_fsm.py 2011-02-03 17:29:42 +0000 | |||
1089 | @@ -26,6 +26,8 @@ | |||
1090 | 26 | import time | 26 | import time |
1091 | 27 | import unittest | 27 | import unittest |
1092 | 28 | 28 | ||
1093 | 29 | from twisted.internet import defer | ||
1094 | 30 | |||
1095 | 29 | from contrib.testing.testcase import ( | 31 | from contrib.testing.testcase import ( |
1096 | 30 | BaseTwistedTestCase, | 32 | BaseTwistedTestCase, |
1097 | 31 | FakeVolumeManager, | 33 | FakeVolumeManager, |
1098 | @@ -56,9 +58,21 @@ | |||
1099 | 56 | BROKEN_PICKLE = '\axb80\x02}q\x01(U\x01aU\x04testq\x02U\x01bU\x06brokenq\x03u.' | 58 | BROKEN_PICKLE = '\axb80\x02}q\x01(U\x01aU\x04testq\x02U\x01bU\x06brokenq\x03u.' |
1100 | 57 | 59 | ||
1101 | 58 | 60 | ||
1102 | 61 | @defer.inlineCallbacks | ||
1103 | 62 | def _create_share(share_id, share_name, fsm, shares_dir, access_level='Modify'): | ||
1104 | 63 | """Create a share.""" | ||
1105 | 64 | share_path = os.path.join(shares_dir, share_name) | ||
1106 | 65 | os.makedirs(share_path) | ||
1107 | 66 | share = Share(path=share_path, volume_id=share_id, | ||
1108 | 67 | access_level=access_level) | ||
1109 | 68 | yield fsm.vm.add_share(share) | ||
1110 | 69 | defer.returnValue(share) | ||
1111 | 70 | |||
1112 | 71 | |||
1113 | 59 | class FSMTestCase(unittest.TestCase): | 72 | class FSMTestCase(unittest.TestCase): |
1114 | 60 | """ Base test case for FSM """ | 73 | """ Base test case for FSM """ |
1115 | 61 | 74 | ||
1116 | 75 | @defer.inlineCallbacks | ||
1117 | 62 | def setUp(self): | 76 | def setUp(self): |
1118 | 63 | """ Setup the test """ | 77 | """ Setup the test """ |
1119 | 64 | unittest.TestCase.setUp(self) | 78 | unittest.TestCase.setUp(self) |
1120 | @@ -80,8 +94,7 @@ | |||
1121 | 80 | FakeVolumeManager(self.root_dir), self.db) | 94 | FakeVolumeManager(self.root_dir), self.db) |
1122 | 81 | self.eq = EventQueue(self.fsm) | 95 | self.eq = EventQueue(self.fsm) |
1123 | 82 | self.fsm.register_eq(self.eq) | 96 | self.fsm.register_eq(self.eq) |
1126 | 83 | self.share = self.create_share('share', 'share_name', | 97 | self.share = yield self.create_share('share', 'share_name') |
1125 | 84 | self.fsm, self.shares_dir) | ||
1127 | 85 | self.share_path = self.share.path | 98 | self.share_path = self.share.path |
1128 | 86 | 99 | ||
1129 | 87 | # add a in-memory logger handler | 100 | # add a in-memory logger handler |
1130 | @@ -109,16 +122,17 @@ | |||
1131 | 109 | os.chmod(os.path.join(dirpath, dir), 0777) | 122 | os.chmod(os.path.join(dirpath, dir), 0777) |
1132 | 110 | shutil.rmtree(path) | 123 | shutil.rmtree(path) |
1133 | 111 | 124 | ||
1136 | 112 | @staticmethod | 125 | @defer.inlineCallbacks |
1137 | 113 | def create_share(share_id, share_name, fsm, shares_dir, | 126 | def create_share(self, share_id, share_name, fsm=None, shares_dir=None, |
1138 | 114 | access_level='Modify'): | 127 | access_level='Modify'): |
1146 | 115 | """ creates a share """ | 128 | """Create a share.""" |
1147 | 116 | share_path = os.path.join(shares_dir, share_name) | 129 | if fsm is None: |
1148 | 117 | os.makedirs(share_path) | 130 | fsm = self.fsm |
1149 | 118 | share = Share(path=share_path, volume_id=share_id, | 131 | if shares_dir is None: |
1150 | 119 | access_level=access_level) | 132 | shares_dir = self.shares_dir |
1151 | 120 | fsm.vm.add_share(share) | 133 | share = yield _create_share(share_id, share_name, fsm, shares_dir, |
1152 | 121 | return share | 134 | access_level) |
1153 | 135 | defer.returnValue(share) | ||
1154 | 122 | 136 | ||
1155 | 123 | def create_node(self, name, is_dir=False, share=None): | 137 | def create_node(self, name, is_dir=False, share=None): |
1156 | 124 | """Create a node.""" | 138 | """Create a node.""" |
1157 | @@ -162,6 +176,7 @@ | |||
1158 | 162 | self.assertTrue(os.path.exists(fsmdir)) | 176 | self.assertTrue(os.path.exists(fsmdir)) |
1159 | 163 | db.shutdown() | 177 | db.shutdown() |
1160 | 164 | 178 | ||
1161 | 179 | @defer.inlineCallbacks | ||
1162 | 165 | def test_complex_startup(self): | 180 | def test_complex_startup(self): |
1163 | 166 | """Test startup after having data.""" | 181 | """Test startup after having data.""" |
1164 | 167 | # pylint: disable-msg=W0212 | 182 | # pylint: disable-msg=W0212 |
1165 | @@ -172,8 +187,8 @@ | |||
1166 | 172 | db = Tritcask(fsmdir) | 187 | db = Tritcask(fsmdir) |
1167 | 173 | fsm = FileSystemManager(fsmdir, partials_dir, | 188 | fsm = FileSystemManager(fsmdir, partials_dir, |
1168 | 174 | FakeVolumeManager(fsmdir), db) | 189 | FakeVolumeManager(fsmdir), db) |
1171 | 175 | share = FSMTestCase.create_share('share', 'share_name', | 190 | share = yield _create_share('share', 'share_name', |
1172 | 176 | fsm, fsmdir) | 191 | fsm=fsm, shares_dir=fsmdir) |
1173 | 177 | self.assertEqual(fsm._idx_path, {}) | 192 | self.assertEqual(fsm._idx_path, {}) |
1174 | 178 | self.assertEqual(fsm._idx_node_id, {}) | 193 | self.assertEqual(fsm._idx_node_id, {}) |
1175 | 179 | 194 | ||
1176 | @@ -299,6 +314,7 @@ | |||
1177 | 299 | md_version = open(os.path.join(self.fsmdir, "metadata_version")).read() | 314 | md_version = open(os.path.join(self.fsmdir, "metadata_version")).read() |
1178 | 300 | self.assertEqual(md_version, METADATA_VERSION) | 315 | self.assertEqual(md_version, METADATA_VERSION) |
1179 | 301 | 316 | ||
1180 | 317 | @defer.inlineCallbacks | ||
1181 | 302 | def test_old_metadata_None(self): | 318 | def test_old_metadata_None(self): |
1182 | 303 | """Test old metadata situation, in None.""" | 319 | """Test old metadata situation, in None.""" |
1183 | 304 | # create some stuff | 320 | # create some stuff |
1184 | @@ -307,8 +323,7 @@ | |||
1185 | 307 | mdid = self.fsm.create(path, "share") | 323 | mdid = self.fsm.create(path, "share") |
1186 | 308 | self.fsm.set_node_id(path, "uuid") | 324 | self.fsm.set_node_id(path, "uuid") |
1187 | 309 | # create a path with the old layout | 325 | # create a path with the old layout |
1190 | 310 | other_share = self.create_share('share1', 'share1_name', | 326 | other_share = yield self.create_share('share1', 'share1_name') |
1189 | 311 | self.fsm, self.shares_dir) | ||
1191 | 312 | share_mdid = self.fsm.create(other_share.path, "share1") | 327 | share_mdid = self.fsm.create(other_share.path, "share1") |
1192 | 313 | self.fsm.set_node_id(other_share.path, "uuid1") | 328 | self.fsm.set_node_id(other_share.path, "uuid1") |
1193 | 314 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 329 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1194 | @@ -358,6 +373,7 @@ | |||
1195 | 358 | self.assertFalse(old_path in newfsm._idx_path) | 373 | self.assertFalse(old_path in newfsm._idx_path) |
1196 | 359 | db.shutdown() | 374 | db.shutdown() |
1197 | 360 | 375 | ||
1198 | 376 | @defer.inlineCallbacks | ||
1199 | 361 | def test_old_metadata_1(self): | 377 | def test_old_metadata_1(self): |
1200 | 362 | """Test old metadata situation, in v1.""" | 378 | """Test old metadata situation, in v1.""" |
1201 | 363 | # create some stuff | 379 | # create some stuff |
1202 | @@ -369,8 +385,7 @@ | |||
1203 | 369 | self.fsm.set_node_id(path2, "uuid2") | 385 | self.fsm.set_node_id(path2, "uuid2") |
1204 | 370 | 386 | ||
1205 | 371 | # create a path with the old layout | 387 | # create a path with the old layout |
1208 | 372 | other_share = self.create_share('share1', 'share1_name', | 388 | other_share = yield self.create_share('share1', 'share1_name') |
1207 | 373 | self.fsm, self.shares_dir) | ||
1209 | 374 | share_mdid = self.fsm.create(other_share.path, "share1") | 389 | share_mdid = self.fsm.create(other_share.path, "share1") |
1210 | 375 | self.fsm.set_node_id(other_share.path, "uuid1") | 390 | self.fsm.set_node_id(other_share.path, "uuid1") |
1211 | 376 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 391 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1212 | @@ -423,6 +438,7 @@ | |||
1213 | 423 | self.assertFalse(old_path in newfsm._idx_path) | 438 | self.assertFalse(old_path in newfsm._idx_path) |
1214 | 424 | db.shutdown() | 439 | db.shutdown() |
1215 | 425 | 440 | ||
1216 | 441 | @defer.inlineCallbacks | ||
1217 | 426 | def test_old_metadata_2(self): | 442 | def test_old_metadata_2(self): |
1218 | 427 | """Test old metadata situation, in v2.""" | 443 | """Test old metadata situation, in v2.""" |
1219 | 428 | # create some stuff | 444 | # create some stuff |
1220 | @@ -430,8 +446,7 @@ | |||
1221 | 430 | mdid = self.fsm.create(path, "share") | 446 | mdid = self.fsm.create(path, "share") |
1222 | 431 | self.fsm.set_node_id(path, "uuid") | 447 | self.fsm.set_node_id(path, "uuid") |
1223 | 432 | # create a path with the old layout | 448 | # create a path with the old layout |
1226 | 433 | other_share = self.create_share('share1', 'share1_name', | 449 | other_share = yield self.create_share('share1', 'share1_name') |
1225 | 434 | self.fsm, self.shares_dir) | ||
1227 | 435 | share_mdid = self.fsm.create(other_share.path, "share1") | 450 | share_mdid = self.fsm.create(other_share.path, "share1") |
1228 | 436 | self.fsm.set_node_id(other_share.path, "uuid1") | 451 | self.fsm.set_node_id(other_share.path, "uuid1") |
1229 | 437 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 452 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1230 | @@ -480,6 +495,7 @@ | |||
1231 | 480 | self.assertFalse(old_path in newfsm._idx_path) | 495 | self.assertFalse(old_path in newfsm._idx_path) |
1232 | 481 | db.shutdown() | 496 | db.shutdown() |
1233 | 482 | 497 | ||
1234 | 498 | @defer.inlineCallbacks | ||
1235 | 483 | def test_old_metadata_3(self): | 499 | def test_old_metadata_3(self): |
1236 | 484 | """Test old metadata situation, in v3.""" | 500 | """Test old metadata situation, in v3.""" |
1237 | 485 | # create a path with the old layout and metadata | 501 | # create a path with the old layout and metadata |
1238 | @@ -487,8 +503,7 @@ | |||
1239 | 487 | root_mdid = self.fsm.create(self.root_dir, "") | 503 | root_mdid = self.fsm.create(self.root_dir, "") |
1240 | 488 | self.fsm.set_node_id(self.root_dir, "uuid") | 504 | self.fsm.set_node_id(self.root_dir, "uuid") |
1241 | 489 | # a share | 505 | # a share |
1244 | 490 | other_share = self.create_share('share1', 'share1_name', | 506 | other_share = yield self.create_share('share1', 'share1_name') |
1243 | 491 | self.fsm, self.shares_dir) | ||
1245 | 492 | share_mdid = self.fsm.create(other_share.path, "share1") | 507 | share_mdid = self.fsm.create(other_share.path, "share1") |
1246 | 493 | self.fsm.set_node_id(other_share.path, "uuid1") | 508 | self.fsm.set_node_id(other_share.path, "uuid1") |
1247 | 494 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 509 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1248 | @@ -1263,13 +1278,14 @@ | |||
1249 | 1263 | mdobj = self.fsm.get_by_node_id("share", "uuid") | 1278 | mdobj = self.fsm.get_by_node_id("share", "uuid") |
1250 | 1264 | self.assertEquals(self.share_path, mdobj.path) | 1279 | self.assertEquals(self.share_path, mdobj.path) |
1251 | 1265 | 1280 | ||
1252 | 1281 | @defer.inlineCallbacks | ||
1253 | 1266 | def test_get_all_by_share(self): | 1282 | def test_get_all_by_share(self): |
1254 | 1267 | """ Test that it returns all the mdids in a share. """ | 1283 | """ Test that it returns all the mdids in a share. """ |
1255 | 1268 | # create the shares | 1284 | # create the shares |
1260 | 1269 | share1 = self.create_share('share_id1', 'share_name1', self.fsm, | 1285 | share1 = yield self.create_share('share_id1', 'share_name1', |
1261 | 1270 | self.shares_dir, access_level='View') | 1286 | access_level='View') |
1262 | 1271 | share2 = self.create_share('share_id2', 'share_name2', self.fsm, | 1287 | share2 = yield self.create_share('share_id2', 'share_name2', |
1263 | 1272 | self.shares_dir, access_level='View') | 1288 | access_level='View') |
1264 | 1273 | self.fsm.create(share1.path, "share_id1", is_dir=True) | 1289 | self.fsm.create(share1.path, "share_id1", is_dir=True) |
1265 | 1274 | self.fsm.set_node_id(share1.path, "uuid1") | 1290 | self.fsm.set_node_id(share1.path, "uuid1") |
1266 | 1275 | self.fsm.create(share2.path, "share_id2", is_dir=True) | 1291 | self.fsm.create(share2.path, "share_id2", is_dir=True) |
1267 | @@ -1330,11 +1346,12 @@ | |||
1268 | 1330 | self.assertTrue(mdid7 not in all) | 1346 | self.assertTrue(mdid7 not in all) |
1269 | 1331 | self.assertTrue(mdid8 not in all) | 1347 | self.assertTrue(mdid8 not in all) |
1270 | 1332 | 1348 | ||
1271 | 1349 | @defer.inlineCallbacks | ||
1272 | 1333 | def test_get_all_by_share_mixed(self): | 1350 | def test_get_all_by_share_mixed(self): |
1273 | 1334 | """Test that it returns all the mdids in a share with mixed nodes.""" | 1351 | """Test that it returns all the mdids in a share with mixed nodes.""" |
1274 | 1335 | # create the shares | 1352 | # create the shares |
1277 | 1336 | share = self.create_share('share_id', 'sharetest', self.fsm, | 1353 | share = yield self.create_share('share_id', 'sharetest', |
1278 | 1337 | self.shares_dir, access_level='View') | 1354 | access_level='View') |
1279 | 1338 | self.fsm.create(share.path, "share_id", is_dir=True) | 1355 | self.fsm.create(share.path, "share_id", is_dir=True) |
1280 | 1339 | self.fsm.set_node_id(share.path, "uuid") | 1356 | self.fsm.set_node_id(share.path, "uuid") |
1281 | 1340 | 1357 | ||
1282 | @@ -1441,10 +1458,10 @@ | |||
1283 | 1441 | os.path.join(self.share.path, 'a', 'b'))]) | 1458 | os.path.join(self.share.path, 'a', 'b'))]) |
1284 | 1442 | self.assertEqual(expected, actual) | 1459 | self.assertEqual(expected, actual) |
1285 | 1443 | 1460 | ||
1286 | 1461 | @defer.inlineCallbacks | ||
1287 | 1444 | def test_with_two_shares(self): | 1462 | def test_with_two_shares(self): |
1288 | 1445 | """Test having 2 shares.""" | 1463 | """Test having 2 shares.""" |
1291 | 1446 | second_share = self.create_share('second_share', 'the_second', | 1464 | second_share = yield self.create_share('second_share', 'the_second') |
1290 | 1447 | self.fsm, self.shares_dir) | ||
1292 | 1448 | self.create_some_contents(second_share) | 1465 | self.create_some_contents(second_share) |
1293 | 1449 | 1466 | ||
1294 | 1450 | expected = ['a'] | 1467 | expected = ['a'] |
1295 | @@ -1452,10 +1469,10 @@ | |||
1296 | 1452 | self.fsm.get_mdobjs_in_dir(second_share.path)]) | 1469 | self.fsm.get_mdobjs_in_dir(second_share.path)]) |
1297 | 1453 | self.assertEqual(expected, actual) | 1470 | self.assertEqual(expected, actual) |
1298 | 1454 | 1471 | ||
1299 | 1472 | @defer.inlineCallbacks | ||
1300 | 1455 | def test_both_shares(self): | 1473 | def test_both_shares(self): |
1301 | 1456 | """Test having 2 shares and asking for mdobjs in shares_dir.""" | 1474 | """Test having 2 shares and asking for mdobjs in shares_dir.""" |
1304 | 1457 | second_share = self.create_share('second_share', 'the_second', | 1475 | second_share = yield self.create_share('second_share', 'the_second') |
1303 | 1458 | self.fsm, self.shares_dir) | ||
1305 | 1459 | self.create_some_contents(second_share) | 1476 | self.create_some_contents(second_share) |
1306 | 1460 | 1477 | ||
1307 | 1461 | expected = [] | 1478 | expected = [] |
1308 | @@ -1750,14 +1767,14 @@ | |||
1309 | 1750 | # it has no partial! | 1767 | # it has no partial! |
1310 | 1751 | self.fsm.remove_partial("uuid", "share") | 1768 | self.fsm.remove_partial("uuid", "share") |
1311 | 1752 | 1769 | ||
1312 | 1770 | @defer.inlineCallbacks | ||
1313 | 1753 | def test_ro_share(self): | 1771 | def test_ro_share(self): |
1314 | 1754 | """Test creating a partial of a RO share. | 1772 | """Test creating a partial of a RO share. |
1315 | 1755 | 1773 | ||
1316 | 1756 | It should leave the partials dir permissions intact. | 1774 | It should leave the partials dir permissions intact. |
1317 | 1757 | """ | 1775 | """ |
1321 | 1758 | share = self.create_share('ro_share', 'ro_share_name', | 1776 | share = yield self.create_share('ro_share', 'ro_share_name', |
1322 | 1759 | self.fsm, self.shares_dir, | 1777 | access_level='View') |
1320 | 1760 | access_level='View') | ||
1323 | 1761 | testdir = os.path.join(share.path, "path") | 1778 | testdir = os.path.join(share.path, "path") |
1324 | 1762 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=False) | 1779 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=False) |
1325 | 1763 | self.fsm.set_node_id(testdir, "uuid") | 1780 | self.fsm.set_node_id(testdir, "uuid") |
1326 | @@ -2638,22 +2655,24 @@ | |||
1327 | 2638 | self.fsm.make_dir(mdid) | 2655 | self.fsm.make_dir(mdid) |
1328 | 2639 | self.assertTrue(os.path.exists(local_dir)) | 2656 | self.assertTrue(os.path.exists(local_dir)) |
1329 | 2640 | 2657 | ||
1330 | 2658 | @defer.inlineCallbacks | ||
1331 | 2641 | def test_make_dir_in_ro_share(self): | 2659 | def test_make_dir_in_ro_share(self): |
1332 | 2642 | """Also works in a read only share.""" | 2660 | """Also works in a read only share.""" |
1335 | 2643 | share = self.create_share('ro_share_id', 'ro', self.fsm, | 2661 | share = yield self.create_share('ro_share_id', 'ro', |
1336 | 2644 | self.shares_dir, access_level='View') | 2662 | access_level='View') |
1337 | 2645 | testdir = os.path.join(share.path, "foo") | 2663 | testdir = os.path.join(share.path, "foo") |
1338 | 2646 | mdid = self.fsm.create(testdir, 'ro_share_id', is_dir=True) | 2664 | mdid = self.fsm.create(testdir, 'ro_share_id', is_dir=True) |
1339 | 2647 | self.fsm.make_dir(mdid) | 2665 | self.fsm.make_dir(mdid) |
1340 | 2648 | self.assertTrue(os.path.exists(testdir)) | 2666 | self.assertTrue(os.path.exists(testdir)) |
1341 | 2649 | 2667 | ||
1342 | 2668 | @defer.inlineCallbacks | ||
1343 | 2650 | def test_make_dir_ro_watch(self): | 2669 | def test_make_dir_ro_watch(self): |
1344 | 2651 | """Don't add the watch nor the mute on a RO share.""" | 2670 | """Don't add the watch nor the mute on a RO share.""" |
1345 | 2652 | called = [] | 2671 | called = [] |
1346 | 2653 | self.eq.add_watch = lambda p: called.append(p) | 2672 | self.eq.add_watch = lambda p: called.append(p) |
1347 | 2654 | self.eq.add_to_mute_filter = lambda *a: called.append(a) | 2673 | self.eq.add_to_mute_filter = lambda *a: called.append(a) |
1350 | 2655 | share = self.create_share('ro_share_id', 'ro', self.fsm, | 2674 | share = yield self.create_share('ro_share_id', 'ro', |
1351 | 2656 | self.shares_dir, access_level='View') | 2675 | access_level='View') |
1352 | 2657 | testdir = os.path.join(share.path, "foo") | 2676 | testdir = os.path.join(share.path, "foo") |
1353 | 2658 | mdid = self.fsm.create(testdir, 'ro_share_id', is_dir=True) | 2677 | mdid = self.fsm.create(testdir, 'ro_share_id', is_dir=True) |
1354 | 2659 | 2678 | ||
1355 | @@ -2862,17 +2881,19 @@ | |||
1356 | 2862 | os.chmod(os.path.join(dirpath, file), 0666) | 2881 | os.chmod(os.path.join(dirpath, file), 0666) |
1357 | 2863 | FSMTestCase.tearDown(self) | 2882 | FSMTestCase.tearDown(self) |
1358 | 2864 | 2883 | ||
1359 | 2884 | @defer.inlineCallbacks | ||
1360 | 2865 | def test_file_ro_share_fail(self): | 2885 | def test_file_ro_share_fail(self): |
1361 | 2866 | """ Test that manual creation of a file, fails on a ro-share. """ | 2886 | """ Test that manual creation of a file, fails on a ro-share. """ |
1364 | 2867 | share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 2887 | share = yield self.create_share('ro_share', 'ro_share_name', |
1365 | 2868 | self.shares_dir, access_level='View') | 2888 | access_level='View') |
1366 | 2869 | testfile = os.path.join(share.path, "a_file") | 2889 | testfile = os.path.join(share.path, "a_file") |
1367 | 2870 | self.assertRaises(IOError, open, testfile, 'w') | 2890 | self.assertRaises(IOError, open, testfile, 'w') |
1368 | 2871 | 2891 | ||
1369 | 2892 | @defer.inlineCallbacks | ||
1370 | 2872 | def test_dir_ro_share(self): | 2893 | def test_dir_ro_share(self): |
1371 | 2873 | """ Test that the creation of a file using fsm, works on a ro-share.""" | 2894 | """ Test that the creation of a file using fsm, works on a ro-share.""" |
1374 | 2874 | share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 2895 | share = yield self.create_share('ro_share', 'ro_share_name', |
1375 | 2875 | self.shares_dir, access_level='View') | 2896 | access_level='View') |
1376 | 2876 | testdir = os.path.join(share.path, "path2") | 2897 | testdir = os.path.join(share.path, "path2") |
1377 | 2877 | self.fsm.create(testdir, share.volume_id, is_dir=True) | 2898 | self.fsm.create(testdir, share.volume_id, is_dir=True) |
1378 | 2878 | self.fsm.set_node_id(testdir, "uuid2") | 2899 | self.fsm.set_node_id(testdir, "uuid2") |
1379 | @@ -2882,10 +2903,11 @@ | |||
1380 | 2882 | fd.close() | 2903 | fd.close() |
1381 | 2883 | self.assertTrue(os.path.exists(testdir)) | 2904 | self.assertTrue(os.path.exists(testdir)) |
1382 | 2884 | 2905 | ||
1383 | 2906 | @defer.inlineCallbacks | ||
1384 | 2885 | def test_file_ro_share(self): | 2907 | def test_file_ro_share(self): |
1385 | 2886 | """ Test that the creation of a file using fsm, works on a ro-share.""" | 2908 | """ Test that the creation of a file using fsm, works on a ro-share.""" |
1388 | 2887 | self.share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 2909 | self.share = yield self.create_share('ro_share', 'ro_share_name', |
1389 | 2888 | self.shares_dir, access_level='View') | 2910 | access_level='View') |
1390 | 2889 | testfile = os.path.join(self.share.path, "a_file") | 2911 | testfile = os.path.join(self.share.path, "a_file") |
1391 | 2890 | self.fsm.create(testfile, self.share.volume_id, is_dir=False) | 2912 | self.fsm.create(testfile, self.share.volume_id, is_dir=False) |
1392 | 2891 | self.fsm.set_node_id(testfile, "uuid3") | 2913 | self.fsm.set_node_id(testfile, "uuid3") |
1393 | @@ -2896,10 +2918,11 @@ | |||
1394 | 2896 | self.fsm.commit_partial('uuid3', self.share.volume_id, None) | 2918 | self.fsm.commit_partial('uuid3', self.share.volume_id, None) |
1395 | 2897 | self.assertTrue(os.path.exists(testfile)) | 2919 | self.assertTrue(os.path.exists(testfile)) |
1396 | 2898 | 2920 | ||
1397 | 2921 | @defer.inlineCallbacks | ||
1398 | 2899 | def test_delete_dir_ro_share(self): | 2922 | def test_delete_dir_ro_share(self): |
1399 | 2900 | """ Test that fsm is able to delete a dir in a ro.share. """ | 2923 | """ Test that fsm is able to delete a dir in a ro.share. """ |
1402 | 2901 | share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 2924 | share = yield self.create_share('ro_share', 'ro_share_name', |
1403 | 2902 | self.shares_dir, access_level='View') | 2925 | access_level='View') |
1404 | 2903 | testdir = os.path.join(share.path, "path2") | 2926 | testdir = os.path.join(share.path, "path2") |
1405 | 2904 | self.fsm.create(testdir, share.volume_id, is_dir=True) | 2927 | self.fsm.create(testdir, share.volume_id, is_dir=True) |
1406 | 2905 | self.fsm.set_node_id(testdir, "uuid2") | 2928 | self.fsm.set_node_id(testdir, "uuid2") |
1407 | @@ -2912,10 +2935,11 @@ | |||
1408 | 2912 | self.fsm.delete_file(testdir) | 2935 | self.fsm.delete_file(testdir) |
1409 | 2913 | self.assertFalse(os.path.exists(testdir)) | 2936 | self.assertFalse(os.path.exists(testdir)) |
1410 | 2914 | 2937 | ||
1411 | 2938 | @defer.inlineCallbacks | ||
1412 | 2915 | def test_delete_non_empty_dir_ro_share(self): | 2939 | def test_delete_non_empty_dir_ro_share(self): |
1413 | 2916 | """Test that fsm is able to delete a non-empty dir in a ro.share.""" | 2940 | """Test that fsm is able to delete a non-empty dir in a ro.share.""" |
1416 | 2917 | share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 2941 | share = yield self.create_share('ro_share', 'ro_share_name', |
1417 | 2918 | self.shares_dir, access_level='View') | 2942 | access_level='View') |
1418 | 2919 | testdir = os.path.join(share.path, "path2") | 2943 | testdir = os.path.join(share.path, "path2") |
1419 | 2920 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=True) | 2944 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=True) |
1420 | 2921 | self.fsm.set_node_id(testdir, "uuid2") | 2945 | self.fsm.set_node_id(testdir, "uuid2") |
1421 | @@ -2941,10 +2965,11 @@ | |||
1422 | 2941 | self.assertFalse(os.path.exists(testdir)) | 2965 | self.assertFalse(os.path.exists(testdir)) |
1423 | 2942 | self.assertFalse(os.path.exists(testfile)) | 2966 | self.assertFalse(os.path.exists(testfile)) |
1424 | 2943 | 2967 | ||
1425 | 2968 | @defer.inlineCallbacks | ||
1426 | 2944 | def test_delete_non_empty_dir_rw_share(self): | 2969 | def test_delete_non_empty_dir_rw_share(self): |
1427 | 2945 | """Test that fsm is able to delete a non-empty dir in a rw.share.""" | 2970 | """Test that fsm is able to delete a non-empty dir in a rw.share.""" |
1430 | 2946 | share = self.create_share('rw_share', 'rw_share_name', self.fsm, | 2971 | share = yield self.create_share('rw_share', 'rw_share_name', |
1431 | 2947 | self.shares_dir, access_level='Modify') | 2972 | access_level='Modify') |
1432 | 2948 | testdir = os.path.join(share.path, "path2") | 2973 | testdir = os.path.join(share.path, "path2") |
1433 | 2949 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=True) | 2974 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=True) |
1434 | 2950 | self.fsm.set_node_id(testdir, "uuid2") | 2975 | self.fsm.set_node_id(testdir, "uuid2") |
1435 | @@ -2970,10 +2995,11 @@ | |||
1436 | 2970 | self.assertFalse(os.path.exists(testdir)) | 2995 | self.assertFalse(os.path.exists(testdir)) |
1437 | 2971 | self.assertFalse(os.path.exists(testfile)) | 2996 | self.assertFalse(os.path.exists(testfile)) |
1438 | 2972 | 2997 | ||
1439 | 2998 | @defer.inlineCallbacks | ||
1440 | 2973 | def test_delete_non_empty_dir_bad_perms_rw_share(self): | 2999 | def test_delete_non_empty_dir_bad_perms_rw_share(self): |
1441 | 2974 | """Test that fsm is able to delete a non-empty dir in a rw.share.""" | 3000 | """Test that fsm is able to delete a non-empty dir in a rw.share.""" |
1444 | 2975 | share = self.create_share('rw_share', 'rw_share_name', self.fsm, | 3001 | share = yield self.create_share('rw_share', 'rw_share_name', |
1445 | 2976 | self.shares_dir, access_level='Modify') | 3002 | access_level='Modify') |
1446 | 2977 | testdir = os.path.join(share.path, "path2") | 3003 | testdir = os.path.join(share.path, "path2") |
1447 | 2978 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=True) | 3004 | mdid = self.fsm.create(testdir, share.volume_id, is_dir=True) |
1448 | 2979 | self.fsm.set_node_id(testdir, "uuid2") | 3005 | self.fsm.set_node_id(testdir, "uuid2") |
1449 | @@ -3001,10 +3027,11 @@ | |||
1450 | 3001 | self.assertTrue(os.path.exists(testdir)) | 3027 | self.assertTrue(os.path.exists(testdir)) |
1451 | 3002 | self.assertTrue(os.path.exists(testfile)) | 3028 | self.assertTrue(os.path.exists(testfile)) |
1452 | 3003 | 3029 | ||
1453 | 3030 | @defer.inlineCallbacks | ||
1454 | 3004 | def test_delete_file_ro_share(self): | 3031 | def test_delete_file_ro_share(self): |
1455 | 3005 | """ Test that fsm is able to delete a file in a ro-share. """ | 3032 | """ Test that fsm is able to delete a file in a ro-share. """ |
1458 | 3006 | self.share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 3033 | self.share = yield self.create_share('ro_share', 'ro_share_name', |
1459 | 3007 | self.shares_dir, access_level='View') | 3034 | access_level='View') |
1460 | 3008 | testfile = os.path.join(self.share.path, "a_file") | 3035 | testfile = os.path.join(self.share.path, "a_file") |
1461 | 3009 | self.fsm.create(testfile, self.share.volume_id, is_dir=False) | 3036 | self.fsm.create(testfile, self.share.volume_id, is_dir=False) |
1462 | 3010 | self.fsm.set_node_id(testfile, "uuid3") | 3037 | self.fsm.set_node_id(testfile, "uuid3") |
1463 | @@ -3017,10 +3044,11 @@ | |||
1464 | 3017 | self.fsm.delete_file(testfile) | 3044 | self.fsm.delete_file(testfile) |
1465 | 3018 | self.assertFalse(os.path.exists(testfile)) | 3045 | self.assertFalse(os.path.exists(testfile)) |
1466 | 3019 | 3046 | ||
1467 | 3047 | @defer.inlineCallbacks | ||
1468 | 3020 | def test_move_to_conflict_ro_share(self): | 3048 | def test_move_to_conflict_ro_share(self): |
1469 | 3021 | """ Test that fsm is able to handle move_to_conflict in a ro-share. """ | 3049 | """ Test that fsm is able to handle move_to_conflict in a ro-share. """ |
1472 | 3022 | self.share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 3050 | self.share = yield self.create_share('ro_share', 'ro_share_name', |
1473 | 3023 | self.shares_dir, access_level='View') | 3051 | access_level='View') |
1474 | 3024 | testfile = os.path.join(self.share.path, "a_file") | 3052 | testfile = os.path.join(self.share.path, "a_file") |
1475 | 3025 | file_mdid = self.fsm.create(testfile, self.share.volume_id, | 3053 | file_mdid = self.fsm.create(testfile, self.share.volume_id, |
1476 | 3026 | is_dir=False) | 3054 | is_dir=False) |
1477 | @@ -3034,18 +3062,18 @@ | |||
1478 | 3034 | self.fsm.move_to_conflict(file_mdid) | 3062 | self.fsm.move_to_conflict(file_mdid) |
1479 | 3035 | self.assertTrue(os.path.exists(testfile + self.fsm.CONFLICT_SUFFIX)) | 3063 | self.assertTrue(os.path.exists(testfile + self.fsm.CONFLICT_SUFFIX)) |
1480 | 3036 | 3064 | ||
1481 | 3065 | @defer.inlineCallbacks | ||
1482 | 3037 | def test_file_rw_share_no_fail(self): | 3066 | def test_file_rw_share_no_fail(self): |
1483 | 3038 | """ Test that manual creation of a file, ona rw-share. """ | 3067 | """ Test that manual creation of a file, ona rw-share. """ |
1486 | 3039 | share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 3068 | share = yield self.create_share('ro_share', 'ro_share_name') |
1485 | 3040 | self.shares_dir) | ||
1487 | 3041 | testfile = os.path.join(share.path, "a_file") | 3069 | testfile = os.path.join(share.path, "a_file") |
1488 | 3042 | open(testfile, 'w').close() | 3070 | open(testfile, 'w').close() |
1489 | 3043 | self.assertTrue(os.path.exists(testfile)) | 3071 | self.assertTrue(os.path.exists(testfile)) |
1490 | 3044 | 3072 | ||
1491 | 3073 | @defer.inlineCallbacks | ||
1492 | 3045 | def test_dir_rw_share(self): | 3074 | def test_dir_rw_share(self): |
1493 | 3046 | """ Test that the creation of a file using fsm, works on a rw-share.""" | 3075 | """ Test that the creation of a file using fsm, works on a rw-share.""" |
1496 | 3047 | share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 3076 | share = yield self.create_share('ro_share', 'ro_share_name') |
1495 | 3048 | self.shares_dir) | ||
1497 | 3049 | testdir = os.path.join(share.path, "path2") | 3077 | testdir = os.path.join(share.path, "path2") |
1498 | 3050 | self.fsm.create(testdir, share.volume_id, is_dir=True) | 3078 | self.fsm.create(testdir, share.volume_id, is_dir=True) |
1499 | 3051 | self.fsm.set_node_id(testdir, "uuid2") | 3079 | self.fsm.set_node_id(testdir, "uuid2") |
1500 | @@ -3055,10 +3083,10 @@ | |||
1501 | 3055 | fd.close() | 3083 | fd.close() |
1502 | 3056 | self.assertTrue(os.path.exists(testdir)) | 3084 | self.assertTrue(os.path.exists(testdir)) |
1503 | 3057 | 3085 | ||
1504 | 3086 | @defer.inlineCallbacks | ||
1505 | 3058 | def test_file_rw_share(self): | 3087 | def test_file_rw_share(self): |
1506 | 3059 | """ Test that the creation of a file using fsm, works on a rw-share.""" | 3088 | """ Test that the creation of a file using fsm, works on a rw-share.""" |
1509 | 3060 | self.share = self.create_share('ro_share', 'ro_share_name', self.fsm, | 3089 | self.share = yield self.create_share('ro_share', 'ro_share_name') |
1508 | 3061 | self.shares_dir) | ||
1510 | 3062 | testfile = os.path.join(self.share.path, "a_file") | 3090 | testfile = os.path.join(self.share.path, "a_file") |
1511 | 3063 | self.fsm.create(testfile, self.share.volume_id, is_dir=False) | 3091 | self.fsm.create(testfile, self.share.volume_id, is_dir=False) |
1512 | 3064 | self.fsm.set_node_id(testfile, "uuid3") | 3092 | self.fsm.set_node_id(testfile, "uuid3") |
1513 | @@ -3094,13 +3122,13 @@ | |||
1514 | 3094 | class TestEnableShareWrite(FSMTestCase): | 3122 | class TestEnableShareWrite(FSMTestCase): |
1515 | 3095 | """Tests for EnableShareWrite context manager""" | 3123 | """Tests for EnableShareWrite context manager""" |
1516 | 3096 | 3124 | ||
1517 | 3125 | @defer.inlineCallbacks | ||
1518 | 3097 | def setUp(self): | 3126 | def setUp(self): |
1519 | 3098 | """Test setup""" | 3127 | """Test setup""" |
1520 | 3099 | FSMTestCase.setUp(self) | 3128 | FSMTestCase.setUp(self) |
1521 | 3100 | # create a ro share | 3129 | # create a ro share |
1525 | 3101 | self.share_ro = self.create_share('share_ro', 'share_ro_name', | 3130 | self.share_ro = yield self.create_share('share_ro', 'share_ro_name', |
1526 | 3102 | self.fsm, self.shares_dir, | 3131 | access_level='View') |
1524 | 3103 | access_level='View') | ||
1527 | 3104 | self.share_ro_path = self.share_ro.path | 3132 | self.share_ro_path = self.share_ro.path |
1528 | 3105 | 3133 | ||
1529 | 3106 | def test_write_in_ro_share(self): | 3134 | def test_write_in_ro_share(self): |
1530 | @@ -3140,6 +3168,7 @@ | |||
1531 | 3140 | 3168 | ||
1532 | 3141 | class RealVMTestCase(FSMTestCase): | 3169 | class RealVMTestCase(FSMTestCase): |
1533 | 3142 | 3170 | ||
1534 | 3171 | @defer.inlineCallbacks | ||
1535 | 3143 | def setUp(self): | 3172 | def setUp(self): |
1536 | 3144 | """ Setup the test """ | 3173 | """ Setup the test """ |
1537 | 3145 | unittest.TestCase.setUp(self) | 3174 | unittest.TestCase.setUp(self) |
1538 | @@ -3158,8 +3187,7 @@ | |||
1539 | 3158 | self.main = FakeMain(self.root_dir, self.shares_dir, | 3187 | self.main = FakeMain(self.root_dir, self.shares_dir, |
1540 | 3159 | self.data_dir, self.partials_dir) | 3188 | self.data_dir, self.partials_dir) |
1541 | 3160 | self.fsm = self.main.fs | 3189 | self.fsm = self.main.fs |
1544 | 3161 | self.share = self.create_share('share', 'share_name', | 3190 | self.share = yield self.create_share('share', 'share_name') |
1543 | 3162 | self.fsm, self.shares_dir) | ||
1545 | 3163 | self.share_path = self.share.path | 3191 | self.share_path = self.share.path |
1546 | 3164 | 3192 | ||
1547 | 3165 | def tearDown(self): | 3193 | def tearDown(self): |
1548 | @@ -3167,14 +3195,16 @@ | |||
1549 | 3167 | self.main.shutdown() | 3195 | self.main.shutdown() |
1550 | 3168 | self.rmtree(TESTS_DIR) | 3196 | self.rmtree(TESTS_DIR) |
1551 | 3169 | 3197 | ||
1555 | 3170 | 3198 | @defer.inlineCallbacks | |
1556 | 3171 | @staticmethod | 3199 | def create_share(self, share_id, share_name, |
1554 | 3172 | def create_share(share_id, share_name, fsm, shares_dir, | ||
1557 | 3173 | access_level='Modify'): | 3200 | access_level='Modify'): |
1562 | 3174 | with allow_writes(shares_dir): | 3201 | with allow_writes(self.shares_dir): |
1563 | 3175 | return FSMTestCase.create_share(share_id, share_name, fsm, | 3202 | share = yield _create_share(share_id, share_name, self.fsm, |
1564 | 3176 | shares_dir, access_level) | 3203 | self.shares_dir, access_level) |
1565 | 3177 | 3204 | ||
1566 | 3205 | defer.returnValue(share) | ||
1567 | 3206 | |||
1568 | 3207 | @defer.inlineCallbacks | ||
1569 | 3178 | def test_old_metadata_None_missing_share(self): | 3208 | def test_old_metadata_None_missing_share(self): |
1570 | 3179 | """test loading metadata v0. that points to a share that | 3209 | """test loading metadata v0. that points to a share that |
1571 | 3180 | we don't have | 3210 | we don't have |
1572 | @@ -3185,8 +3215,7 @@ | |||
1573 | 3185 | mdid = self.fsm.create(path, "share") | 3215 | mdid = self.fsm.create(path, "share") |
1574 | 3186 | self.fsm.set_node_id(path, "uuid") | 3216 | self.fsm.set_node_id(path, "uuid") |
1575 | 3187 | # create a path with the old layout | 3217 | # create a path with the old layout |
1578 | 3188 | other_share = self.create_share('share1', 'share1_name', | 3218 | other_share = yield self.create_share('share1', 'share1_name') |
1577 | 3189 | self.fsm, self.shares_dir) | ||
1579 | 3190 | share_mdid = self.fsm.create(other_share.path, "share1") | 3219 | share_mdid = self.fsm.create(other_share.path, "share1") |
1580 | 3191 | self.fsm.set_node_id(other_share.path, "uuid1") | 3220 | self.fsm.set_node_id(other_share.path, "uuid1") |
1581 | 3192 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 3221 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1582 | @@ -3238,6 +3267,7 @@ | |||
1583 | 3238 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) | 3267 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) |
1584 | 3239 | db.shutdown() | 3268 | db.shutdown() |
1585 | 3240 | 3269 | ||
1586 | 3270 | @defer.inlineCallbacks | ||
1587 | 3241 | def test_old_metadata_1_missing_share(self): | 3271 | def test_old_metadata_1_missing_share(self): |
1588 | 3242 | """test loading metadata v1. that points to a share that | 3272 | """test loading metadata v1. that points to a share that |
1589 | 3243 | we don't have | 3273 | we don't have |
1590 | @@ -3251,8 +3281,7 @@ | |||
1591 | 3251 | self.fsm.set_node_id(path2, "uuid2") | 3281 | self.fsm.set_node_id(path2, "uuid2") |
1592 | 3252 | 3282 | ||
1593 | 3253 | # create a path with the old layout | 3283 | # create a path with the old layout |
1596 | 3254 | other_share = self.create_share('share1', 'share1_name', | 3284 | other_share = yield self.create_share('share1', 'share1_name') |
1595 | 3255 | self.fsm, self.shares_dir) | ||
1597 | 3256 | share_mdid = self.fsm.create(other_share.path, "share1") | 3285 | share_mdid = self.fsm.create(other_share.path, "share1") |
1598 | 3257 | self.fsm.set_node_id(other_share.path, "uuid3") | 3286 | self.fsm.set_node_id(other_share.path, "uuid3") |
1599 | 3258 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 3287 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1600 | @@ -3303,6 +3332,7 @@ | |||
1601 | 3303 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) | 3332 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) |
1602 | 3304 | db.shutdown() | 3333 | db.shutdown() |
1603 | 3305 | 3334 | ||
1604 | 3335 | @defer.inlineCallbacks | ||
1605 | 3306 | def test_old_metadata_2_missing_share(self): | 3336 | def test_old_metadata_2_missing_share(self): |
1606 | 3307 | """test loading metadata v2. that points to a share that | 3337 | """test loading metadata v2. that points to a share that |
1607 | 3308 | we don't have | 3338 | we don't have |
1608 | @@ -3312,8 +3342,7 @@ | |||
1609 | 3312 | mdid = self.fsm.create(path, "share") | 3342 | mdid = self.fsm.create(path, "share") |
1610 | 3313 | self.fsm.set_node_id(path, "uuid") | 3343 | self.fsm.set_node_id(path, "uuid") |
1611 | 3314 | # create a path with the old layout | 3344 | # create a path with the old layout |
1614 | 3315 | other_share = self.create_share('share1', 'share1_name', | 3345 | other_share = yield self.create_share('share1', 'share1_name') |
1613 | 3316 | self.fsm, self.shares_dir) | ||
1615 | 3317 | share_mdid = self.fsm.create(other_share.path, "share1") | 3346 | share_mdid = self.fsm.create(other_share.path, "share1") |
1616 | 3318 | self.fsm.set_node_id(other_share.path, "uuid3") | 3347 | self.fsm.set_node_id(other_share.path, "uuid3") |
1617 | 3319 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 3348 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1618 | @@ -3360,6 +3389,7 @@ | |||
1619 | 3360 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) | 3389 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) |
1620 | 3361 | db.shutdown() | 3390 | db.shutdown() |
1621 | 3362 | 3391 | ||
1622 | 3392 | @defer.inlineCallbacks | ||
1623 | 3363 | def test_old_metadata_3_missing_share(self): | 3393 | def test_old_metadata_3_missing_share(self): |
1624 | 3364 | """test loading metadata v3. that points to a share that | 3394 | """test loading metadata v3. that points to a share that |
1625 | 3365 | we don't have | 3395 | we don't have |
1626 | @@ -3369,8 +3399,7 @@ | |||
1627 | 3369 | root_mdid = self.fsm.get_by_path(self.root_dir).mdid | 3399 | root_mdid = self.fsm.get_by_path(self.root_dir).mdid |
1628 | 3370 | self.fsm.set_node_id(self.root_dir, "uuid") | 3400 | self.fsm.set_node_id(self.root_dir, "uuid") |
1629 | 3371 | # a share | 3401 | # a share |
1632 | 3372 | other_share = self.create_share('share1', 'share1_name', | 3402 | other_share = yield self.create_share('share1', 'share1_name') |
1631 | 3373 | self.fsm, self.shares_dir) | ||
1633 | 3374 | share_mdid = self.fsm.create(other_share.path, "share1") | 3403 | share_mdid = self.fsm.create(other_share.path, "share1") |
1634 | 3375 | self.fsm.set_node_id(other_share.path, "uuid1") | 3404 | self.fsm.set_node_id(other_share.path, "uuid1") |
1635 | 3376 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) | 3405 | os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
1636 | @@ -3416,6 +3445,7 @@ | |||
1637 | 3416 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) | 3445 | self.assertRaises(KeyError, newfsm.get_by_mdid, share_mdid) |
1638 | 3417 | db.shutdown() | 3446 | db.shutdown() |
1639 | 3418 | 3447 | ||
1640 | 3448 | @defer.inlineCallbacks | ||
1641 | 3419 | def test_metadata_missing_share(self): | 3449 | def test_metadata_missing_share(self): |
1642 | 3420 | """test loading current metadata that points to a share | 3450 | """test loading current metadata that points to a share |
1643 | 3421 | that we don't have | 3451 | that we don't have |
1644 | @@ -3425,8 +3455,7 @@ | |||
1645 | 3425 | self.assertEqual(md_version, METADATA_VERSION) | 3455 | self.assertEqual(md_version, METADATA_VERSION) |
1646 | 3426 | path = os.path.join(self.share.path, 'path') | 3456 | path = os.path.join(self.share.path, 'path') |
1647 | 3427 | path1 = os.path.join(self.share.path, 'path1') | 3457 | path1 = os.path.join(self.share.path, 'path1') |
1650 | 3428 | other_share = self.create_share('share1', 'share1_name', | 3458 | other_share = yield self.create_share('share1', 'share1_name') |
1649 | 3429 | self.fsm, self.shares_dir) | ||
1651 | 3430 | 3459 | ||
1652 | 3431 | path2 = os.path.join(other_share.path, 'broken_path2') | 3460 | path2 = os.path.join(other_share.path, 'broken_path2') |
1653 | 3432 | for p in [path, path1, path2]: | 3461 | for p in [path, path1, path2]: |
1654 | 3433 | 3462 | ||
1655 | === modified file 'tests/syncdaemon/test_localrescan.py' | |||
1656 | --- tests/syncdaemon/test_localrescan.py 2011-02-01 14:33:46 +0000 | |||
1657 | +++ tests/syncdaemon/test_localrescan.py 2011-02-03 17:29:42 +0000 | |||
1658 | @@ -119,19 +119,20 @@ | |||
1659 | 119 | self.rmtree(self.tmpdir) | 119 | self.rmtree(self.tmpdir) |
1660 | 120 | testcase.BaseTwistedTestCase.tearDown(self) | 120 | testcase.BaseTwistedTestCase.tearDown(self) |
1661 | 121 | 121 | ||
1664 | 122 | @staticmethod | 122 | @defer.inlineCallbacks |
1665 | 123 | def create_share(share_id, share_name, fsm, shares_dir, | 123 | def create_share(self, share_id, share_name, |
1666 | 124 | access_level='Modify', accepted=True, subscribed=True): | 124 | access_level='Modify', accepted=True, subscribed=True): |
1667 | 125 | """Create a share.""" | 125 | """Create a share.""" |
1669 | 126 | share_path = os.path.join(shares_dir, share_name) | 126 | share_path = os.path.join(self.shares_dir, share_name) |
1670 | 127 | os.makedirs(share_path) | 127 | os.makedirs(share_path) |
1671 | 128 | share = volume_manager.Share(path=share_path, volume_id=share_id, | 128 | share = volume_manager.Share(path=share_path, volume_id=share_id, |
1672 | 129 | access_level=access_level, | 129 | access_level=access_level, |
1673 | 130 | accepted=accepted, | 130 | accepted=accepted, |
1674 | 131 | subscribed=subscribed) | 131 | subscribed=subscribed) |
1677 | 132 | fsm.vm.add_share(share) | 132 | yield self.fsm.vm.add_share(share) |
1678 | 133 | return share | 133 | defer.returnValue(share) |
1679 | 134 | 134 | ||
1680 | 135 | @defer.inlineCallbacks | ||
1681 | 135 | def create_udf(self, udf_id, node_id, suggested_path, path, subscribed, | 136 | def create_udf(self, udf_id, node_id, suggested_path, path, subscribed, |
1682 | 136 | generation=None, free_bytes=100): | 137 | generation=None, free_bytes=100): |
1683 | 137 | """Create an UDF and add it to the volume manager.""" | 138 | """Create an UDF and add it to the volume manager.""" |
1684 | @@ -139,8 +140,8 @@ | |||
1685 | 139 | suggested_path.decode('utf-8')) | 140 | suggested_path.decode('utf-8')) |
1686 | 140 | udf = volume_manager.UDF.from_udf_volume(volume, path) | 141 | udf = volume_manager.UDF.from_udf_volume(volume, path) |
1687 | 141 | udf.subscribed = subscribed | 142 | udf.subscribed = subscribed |
1690 | 142 | self.fsm.vm.add_udf(udf) | 143 | yield self.fsm.vm.add_udf(udf) |
1691 | 143 | return udf | 144 | defer.returnValue(udf) |
1692 | 144 | 145 | ||
1693 | 145 | def create_node(self, path, is_dir, real=True, which_share=None): | 146 | def create_node(self, path, is_dir, real=True, which_share=None): |
1694 | 146 | """Creates a node, really (maybe) and in the metadata.""" | 147 | """Creates a node, really (maybe) and in the metadata.""" |
1695 | @@ -189,11 +190,12 @@ | |||
1696 | 189 | lr.start() | 190 | lr.start() |
1697 | 190 | self.assertEqual(toscan, [self.vm.root.path]) | 191 | self.assertEqual(toscan, [self.vm.root.path]) |
1698 | 191 | 192 | ||
1699 | 193 | @defer.inlineCallbacks | ||
1700 | 192 | def test_empty_rw(self): | 194 | def test_empty_rw(self): |
1701 | 193 | """Test with one empty Modify share.""" | 195 | """Test with one empty Modify share.""" |
1702 | 194 | # create the share | 196 | # create the share |
1705 | 195 | share = self.create_share('share_id', 'rw_share', self.fsm, | 197 | share = yield self.create_share('share_id', 'rw_share', |
1706 | 196 | self.shares_dir, access_level='Modify') | 198 | access_level='Modify') |
1707 | 197 | self.fsm.create(share.path, "share_id", is_dir=True) | 199 | self.fsm.create(share.path, "share_id", is_dir=True) |
1708 | 198 | self.fsm.set_node_id(share.path, "uuid") | 200 | self.fsm.set_node_id(share.path, "uuid") |
1709 | 199 | 201 | ||
1710 | @@ -210,11 +212,12 @@ | |||
1711 | 210 | lr.start() | 212 | lr.start() |
1712 | 211 | self.assertEqual(sorted(toscan), [share.path, self.vm.root.path]) | 213 | self.assertEqual(sorted(toscan), [share.path, self.vm.root.path]) |
1713 | 212 | 214 | ||
1714 | 215 | @defer.inlineCallbacks | ||
1715 | 213 | def test_not_empty_rw(self): | 216 | def test_not_empty_rw(self): |
1716 | 214 | """Test with a Modify share with info.""" | 217 | """Test with a Modify share with info.""" |
1717 | 215 | # create the share | 218 | # create the share |
1720 | 216 | share = self.create_share('share_id', 'ro_share', self.fsm, | 219 | share = yield self.create_share('share_id', 'ro_share', |
1721 | 217 | self.shares_dir, access_level='Modify') | 220 | access_level='Modify') |
1722 | 218 | self.fsm.create(share.path, "share_id", is_dir=True) | 221 | self.fsm.create(share.path, "share_id", is_dir=True) |
1723 | 219 | self.fsm.set_node_id(share.path, "uuid1") | 222 | self.fsm.set_node_id(share.path, "uuid1") |
1724 | 220 | 223 | ||
1725 | @@ -237,11 +240,12 @@ | |||
1726 | 237 | lr.start() | 240 | lr.start() |
1727 | 238 | self.assertEqual(sorted(toscan), [share.path, self.vm.root.path]) | 241 | self.assertEqual(sorted(toscan), [share.path, self.vm.root.path]) |
1728 | 239 | 242 | ||
1729 | 243 | @defer.inlineCallbacks | ||
1730 | 240 | def test_deleted_rw(self): | 244 | def test_deleted_rw(self): |
1731 | 241 | """Test with a deleted rw share.""" | 245 | """Test with a deleted rw share.""" |
1732 | 242 | # create the share | 246 | # create the share |
1735 | 243 | share = self.create_share('share_id', 'rw_share', self.fsm, | 247 | share = yield self.create_share('share_id', 'rw_share', |
1736 | 244 | self.shares_dir, access_level='Modify') | 248 | access_level='Modify') |
1737 | 245 | self.fsm.create(share.path, "share_id", is_dir=True) | 249 | self.fsm.create(share.path, "share_id", is_dir=True) |
1738 | 246 | self.fsm.set_node_id(share.path, "uuid") | 250 | self.fsm.set_node_id(share.path, "uuid") |
1739 | 247 | 251 | ||
1740 | @@ -266,11 +270,12 @@ | |||
1741 | 266 | self.assertEqual(vol_id, share.volume_id) | 270 | self.assertEqual(vol_id, share.volume_id) |
1742 | 267 | self.assertEqual(sorted(toscan), [self.vm.root.path]) | 271 | self.assertEqual(sorted(toscan), [self.vm.root.path]) |
1743 | 268 | 272 | ||
1744 | 273 | @defer.inlineCallbacks | ||
1745 | 269 | def test_deleted_rw_not_empty(self): | 274 | def test_deleted_rw_not_empty(self): |
1746 | 270 | """Test with a deleted rw share with some nodes in it.""" | 275 | """Test with a deleted rw share with some nodes in it.""" |
1747 | 271 | # create the share | 276 | # create the share |
1750 | 272 | share = self.create_share('share_id', 'rw_share', self.fsm, | 277 | share = yield self.create_share('share_id', 'rw_share', |
1751 | 273 | self.shares_dir, access_level='Modify') | 278 | access_level='Modify') |
1752 | 274 | self.fsm.create(share.path, "share_id", is_dir=True) | 279 | self.fsm.create(share.path, "share_id", is_dir=True) |
1753 | 275 | self.fsm.set_node_id(share.path, "uuid") | 280 | self.fsm.set_node_id(share.path, "uuid") |
1754 | 276 | 281 | ||
1755 | @@ -307,7 +312,7 @@ | |||
1756 | 307 | """Test with a deleted udf.""" | 312 | """Test with a deleted udf.""" |
1757 | 308 | # create the udf | 313 | # create the udf |
1758 | 309 | udf_path = os.path.expanduser("~/myudf") | 314 | udf_path = os.path.expanduser("~/myudf") |
1760 | 310 | udf = self.create_udf('udf_id', 'udf_root_node_id', "~/myudf", | 315 | udf = yield self.create_udf('udf_id', 'udf_root_node_id', "~/myudf", |
1761 | 311 | udf_path, True) | 316 | udf_path, True) |
1762 | 312 | os.makedirs(udf.path) | 317 | os.makedirs(udf.path) |
1763 | 313 | self.fsm.create(udf.path, 'udf_id', is_dir=True) | 318 | self.fsm.create(udf.path, 'udf_id', is_dir=True) |
1764 | @@ -337,9 +342,10 @@ | |||
1765 | 337 | class VolumeTestCase(BaseTestCase): | 342 | class VolumeTestCase(BaseTestCase): |
1766 | 338 | """Test how LocalRescan manages volumes.""" | 343 | """Test how LocalRescan manages volumes.""" |
1767 | 339 | 344 | ||
1768 | 345 | @defer.inlineCallbacks | ||
1769 | 340 | def setUp(self): | 346 | def setUp(self): |
1770 | 341 | """Init.""" | 347 | """Init.""" |
1772 | 342 | BaseTestCase.setUp(self) | 348 | yield BaseTestCase.setUp(self) |
1773 | 343 | 349 | ||
1774 | 344 | self.env_var = 'HOME' | 350 | self.env_var = 'HOME' |
1775 | 345 | self.old_value = os.environ.get(self.env_var, None) | 351 | self.old_value = os.environ.get(self.env_var, None) |
1776 | @@ -355,7 +361,8 @@ | |||
1777 | 355 | path = os.path.expanduser(suggested_path).encode("utf8") | 361 | path = os.path.expanduser(suggested_path).encode("utf8") |
1778 | 356 | os.makedirs(path) | 362 | os.makedirs(path) |
1779 | 357 | udf_id, node_id = 'udf_id%i' % i, 'node_id%i' % i | 363 | udf_id, node_id = 'udf_id%i' % i, 'node_id%i' % i |
1781 | 358 | udf = self.create_udf(udf_id, node_id, suggested_path, path, True) | 364 | udf = yield self.create_udf(udf_id, node_id, suggested_path, |
1782 | 365 | path, True) | ||
1783 | 359 | self.volumes.append(udf) | 366 | self.volumes.append(udf) |
1784 | 360 | 367 | ||
1785 | 361 | # make FSM aware of it | 368 | # make FSM aware of it |
1786 | @@ -493,6 +500,7 @@ | |||
1787 | 493 | 500 | ||
1788 | 494 | timeout = 2 | 501 | timeout = 2 |
1789 | 495 | 502 | ||
1790 | 503 | @defer.inlineCallbacks | ||
1791 | 496 | def setUp(self): | 504 | def setUp(self): |
1792 | 497 | """Set up the test.""" | 505 | """Set up the test.""" |
1793 | 498 | BaseTestCase.setUp(self) | 506 | BaseTestCase.setUp(self) |
1794 | @@ -500,8 +508,8 @@ | |||
1795 | 500 | self.lr = LocalRescan(self.vm, self.fsm, self.eq, self.aq) | 508 | self.lr = LocalRescan(self.vm, self.fsm, self.eq, self.aq) |
1796 | 501 | 509 | ||
1797 | 502 | # create a share | 510 | # create a share |
1800 | 503 | self.share = self.create_share('share_id', 'ro_share', self.fsm, | 511 | self.share = yield self.create_share('share_id', 'ro_share', |
1801 | 504 | self.shares_dir, access_level='Modify') | 512 | access_level='Modify') |
1802 | 505 | self.fsm.create(self.share.path, "share_id", is_dir=True) | 513 | self.fsm.create(self.share.path, "share_id", is_dir=True) |
1803 | 506 | self.fsm.set_node_id(self.share.path, "uuidshare") | 514 | self.fsm.set_node_id(self.share.path, "uuidshare") |
1804 | 507 | self.share.node_id = "uuidshare" | 515 | self.share.node_id = "uuidshare" |
1805 | @@ -535,14 +543,15 @@ | |||
1806 | 535 | 543 | ||
1807 | 536 | timeout = 20 | 544 | timeout = 20 |
1808 | 537 | 545 | ||
1809 | 546 | @defer.inlineCallbacks | ||
1810 | 538 | def setUp(self): | 547 | def setUp(self): |
1812 | 539 | TwistedBase.setUp(self) | 548 | yield TwistedBase.setUp(self) |
1813 | 540 | 549 | ||
1814 | 541 | # create an udf | 550 | # create an udf |
1815 | 542 | udf_path = os.path.join(self.home_dir, "myudf") | 551 | udf_path = os.path.join(self.home_dir, "myudf") |
1816 | 543 | os.mkdir(udf_path) | 552 | os.mkdir(udf_path) |
1819 | 544 | self.udf = self.create_udf('udf_id', 'udf_root_node_id', "~/myudf", | 553 | self.udf = yield self.create_udf('udf_id', 'udf_root_node_id', |
1820 | 545 | udf_path, True) | 554 | "~/myudf", udf_path, True) |
1821 | 546 | self.fsm.create(self.udf.path, 'udf_id', is_dir=True) | 555 | self.fsm.create(self.udf.path, 'udf_id', is_dir=True) |
1822 | 547 | self.fsm.set_node_id(self.udf.path, 'udf_root_node_id') | 556 | self.fsm.set_node_id(self.udf.path, 'udf_root_node_id') |
1823 | 548 | 557 | ||
1824 | @@ -954,11 +963,12 @@ | |||
1825 | 954 | reactor.callLater(.2, self.deferred.callback, None) | 963 | reactor.callLater(.2, self.deferred.callback, None) |
1826 | 955 | return self.deferred | 964 | return self.deferred |
1827 | 956 | 965 | ||
1828 | 966 | @defer.inlineCallbacks | ||
1829 | 957 | def test_one_dir_ro_share(self): | 967 | def test_one_dir_ro_share(self): |
1830 | 958 | """The dir is in a share that's RO, no error but no action.""" | 968 | """The dir is in a share that's RO, no error but no action.""" |
1831 | 959 | # create the share | 969 | # create the share |
1834 | 960 | share = self.create_share('share_id', 'ro_share2', self.fsm, | 970 | share = yield self.create_share('share_id', 'ro_share2', |
1835 | 961 | self.shares_dir, access_level='View') | 971 | access_level='View') |
1836 | 962 | self.fsm.create(share.path, "share_id", is_dir=True) | 972 | self.fsm.create(share.path, "share_id", is_dir=True) |
1837 | 963 | self.fsm.set_node_id(share.path, "uuidshare") | 973 | self.fsm.set_node_id(share.path, "uuidshare") |
1838 | 964 | 974 | ||
1839 | @@ -1155,20 +1165,21 @@ | |||
1840 | 1155 | """Test that simultaneus calls are queued.""" | 1165 | """Test that simultaneus calls are queued.""" |
1841 | 1156 | timeout = 2 | 1166 | timeout = 2 |
1842 | 1157 | 1167 | ||
1843 | 1168 | @defer.inlineCallbacks | ||
1844 | 1158 | def setUp(self): | 1169 | def setUp(self): |
1845 | 1159 | """set up the test.""" | 1170 | """set up the test.""" |
1847 | 1160 | BaseTestCase.setUp(self) | 1171 | yield BaseTestCase.setUp(self) |
1848 | 1161 | self.deferred = defer.Deferred() | 1172 | self.deferred = defer.Deferred() |
1849 | 1162 | self.eq = event_queue.EventQueue(self.fsm) | 1173 | self.eq = event_queue.EventQueue(self.fsm) |
1850 | 1163 | self.lr = LocalRescan(self.vm, self.fsm, self.eq, self.aq) | 1174 | self.lr = LocalRescan(self.vm, self.fsm, self.eq, self.aq) |
1851 | 1164 | 1175 | ||
1852 | 1165 | # create two shares | 1176 | # create two shares |
1855 | 1166 | self.share1 = self.create_share('share_id1', 'ro_share_1', self.fsm, | 1177 | self.share1 = yield self.create_share('share_id1', 'ro_share_1', |
1856 | 1167 | self.shares_dir, access_level='Modify') | 1178 | access_level='Modify') |
1857 | 1168 | self.fsm.create(self.share1.path, "share_id1", is_dir=True) | 1179 | self.fsm.create(self.share1.path, "share_id1", is_dir=True) |
1858 | 1169 | self.fsm.set_node_id(self.share1.path, "uuidshare1") | 1180 | self.fsm.set_node_id(self.share1.path, "uuidshare1") |
1861 | 1170 | self.share2 = self.create_share('share_id2', 'ro_share_2', self.fsm, | 1181 | self.share2 = yield self.create_share('share_id2', 'ro_share_2', |
1862 | 1171 | self.shares_dir, access_level='Modify') | 1182 | access_level='Modify') |
1863 | 1172 | self.fsm.create(self.share2.path, "share_id2", is_dir=True) | 1183 | self.fsm.create(self.share2.path, "share_id2", is_dir=True) |
1864 | 1173 | self.fsm.set_node_id(self.share2.path, "uuidshare2") | 1184 | self.fsm.set_node_id(self.share2.path, "uuidshare2") |
1865 | 1174 | 1185 | ||
1866 | @@ -2007,11 +2018,12 @@ | |||
1867 | 2007 | self.startTest(check) | 2018 | self.startTest(check) |
1868 | 2008 | return self.deferred | 2019 | return self.deferred |
1869 | 2009 | 2020 | ||
1870 | 2021 | @defer.inlineCallbacks | ||
1871 | 2010 | def test_SERVER_file_ro_share(self): | 2022 | def test_SERVER_file_ro_share(self): |
1872 | 2011 | """We were downloading the file, but it was interrupted in RO share.""" | 2023 | """We were downloading the file, but it was interrupted in RO share.""" |
1873 | 2012 | # create the file in metadata | 2024 | # create the file in metadata |
1876 | 2013 | ro_share = self.create_share('share_ro_id', 'share_ro2', self.fsm, | 2025 | ro_share = yield self.create_share('share_ro_id', 'share_ro2', |
1877 | 2014 | self.shares_dir, access_level='View') | 2026 | access_level='View') |
1878 | 2015 | self.fsm.create(ro_share.path, ro_share.id, is_dir=True) | 2027 | self.fsm.create(ro_share.path, ro_share.id, is_dir=True) |
1879 | 2016 | self.fsm.set_node_id(ro_share.path, "uuidshare") | 2028 | self.fsm.set_node_id(ro_share.path, "uuidshare") |
1880 | 2017 | path = os.path.join(ro_share.path, "a") | 2029 | path = os.path.join(ro_share.path, "a") |
1881 | @@ -2040,16 +2052,17 @@ | |||
1882 | 2040 | self.assertTrue(self.handler.check_debug("comp yield", "SERVER")) | 2052 | self.assertTrue(self.handler.check_debug("comp yield", "SERVER")) |
1883 | 2041 | 2053 | ||
1884 | 2042 | self.startTest(check) | 2054 | self.startTest(check) |
1886 | 2043 | return self.deferred | 2055 | yield self.deferred |
1887 | 2044 | 2056 | ||
1888 | 2057 | @defer.inlineCallbacks | ||
1889 | 2045 | def test_SERVER_dir_ro_share(self): | 2058 | def test_SERVER_dir_ro_share(self): |
1890 | 2046 | """Found a dir in SERVER in a ro_share. | 2059 | """Found a dir in SERVER in a ro_share. |
1891 | 2047 | 2060 | ||
1892 | 2048 | This was valid before, but no more, so we just fix and log in warning. | 2061 | This was valid before, but no more, so we just fix and log in warning. |
1893 | 2049 | """ | 2062 | """ |
1894 | 2050 | # create the dir in metadata | 2063 | # create the dir in metadata |
1897 | 2051 | ro_share = self.create_share('share_ro_id', 'share_ro2', self.fsm, | 2064 | ro_share = yield self.create_share('share_ro_id', 'share_ro2', |
1898 | 2052 | self.shares_dir, access_level='View') | 2065 | access_level='View') |
1899 | 2053 | self.fsm.create(ro_share.path, ro_share.id, is_dir=True) | 2066 | self.fsm.create(ro_share.path, ro_share.id, is_dir=True) |
1900 | 2054 | self.fsm.set_node_id(ro_share.path, "uuidshare") | 2067 | self.fsm.set_node_id(ro_share.path, "uuidshare") |
1901 | 2055 | 2068 | ||
1902 | @@ -2078,7 +2091,7 @@ | |||
1903 | 2078 | "Found a directory in SERVER")) | 2091 | "Found a directory in SERVER")) |
1904 | 2079 | 2092 | ||
1905 | 2080 | self.startTest(check) | 2093 | self.startTest(check) |
1907 | 2081 | return self.deferred | 2094 | yield self.deferred |
1908 | 2082 | 2095 | ||
1909 | 2083 | def test_check_stat_None(self): | 2096 | def test_check_stat_None(self): |
1910 | 2084 | """Test check_stat with oldstat = None.""" | 2097 | """Test check_stat with oldstat = None.""" |
1911 | @@ -2136,26 +2149,28 @@ | |||
1912 | 2136 | self.fsm.set_node_id(self.vm.root.path, self.vm.root.node_id) | 2149 | self.fsm.set_node_id(self.vm.root.path, self.vm.root.node_id) |
1913 | 2137 | return self._test_it(self.vm.root) | 2150 | return self._test_it(self.vm.root) |
1914 | 2138 | 2151 | ||
1915 | 2152 | @defer.inlineCallbacks | ||
1916 | 2139 | def test_SERVER_share(self): | 2153 | def test_SERVER_share(self): |
1917 | 2140 | """We were downloading the share root dir but it was interrupted.""" | 2154 | """We were downloading the share root dir but it was interrupted.""" |
1918 | 2141 | # create a share | 2155 | # create a share |
1921 | 2142 | share = self.create_share('share_id_1', 'rw_share', self.fsm, | 2156 | share = yield self.create_share('share_id_1', 'rw_share', |
1922 | 2143 | self.shares_dir, access_level='Modify') | 2157 | access_level='Modify') |
1923 | 2144 | self.fsm.create(share.path, "share_id_1", is_dir=True) | 2158 | self.fsm.create(share.path, "share_id_1", is_dir=True) |
1924 | 2145 | self.fsm.set_node_id(share.path, "uuid_share_1") | 2159 | self.fsm.set_node_id(share.path, "uuid_share_1") |
1925 | 2146 | share.node_id = "uuid_share_1" | 2160 | share.node_id = "uuid_share_1" |
1926 | 2147 | self.vm.shares['share_id_1'] = share | 2161 | self.vm.shares['share_id_1'] = share |
1928 | 2148 | return self._test_it(share) | 2162 | yield self._test_it(share) |
1929 | 2149 | 2163 | ||
1930 | 2164 | @defer.inlineCallbacks | ||
1931 | 2150 | def test_SERVER_udf(self): | 2165 | def test_SERVER_udf(self): |
1932 | 2151 | """We were downloading the udf root dir, but it was interrupted.""" | 2166 | """We were downloading the udf root dir, but it was interrupted.""" |
1933 | 2152 | udf_path = os.path.join(self.home_dir, "myudf") | 2167 | udf_path = os.path.join(self.home_dir, "myudf") |
1934 | 2153 | os.mkdir(udf_path) | 2168 | os.mkdir(udf_path) |
1937 | 2154 | udf = self.create_udf('udf_id', 'udf_root_node_id', "~/myudf", | 2169 | udf = yield self.create_udf('udf_id', 'udf_root_node_id', "~/myudf", |
1938 | 2155 | udf_path, True) | 2170 | udf_path, True) |
1939 | 2156 | self.fsm.create(udf.path, 'udf_id', is_dir=True) | 2171 | self.fsm.create(udf.path, 'udf_id', is_dir=True) |
1940 | 2157 | self.fsm.set_node_id(udf.path, 'udf_root_node_id') | 2172 | self.fsm.set_node_id(udf.path, 'udf_root_node_id') |
1942 | 2158 | return self._test_it(udf) | 2173 | yield self._test_it(udf) |
1943 | 2159 | 2174 | ||
1944 | 2160 | 2175 | ||
1945 | 2161 | class LimboTests(TwistedBase): | 2176 | class LimboTests(TwistedBase): |
1946 | @@ -2339,9 +2354,10 @@ | |||
1947 | 2339 | 2354 | ||
1948 | 2340 | timeout = 2 | 2355 | timeout = 2 |
1949 | 2341 | 2356 | ||
1950 | 2357 | @defer.inlineCallbacks | ||
1951 | 2342 | def setUp(self): | 2358 | def setUp(self): |
1952 | 2343 | """Init.""" | 2359 | """Init.""" |
1954 | 2344 | BaseTestCase.setUp(self) | 2360 | yield BaseTestCase.setUp(self) |
1955 | 2345 | self._deferred = defer.Deferred() | 2361 | self._deferred = defer.Deferred() |
1956 | 2346 | self.eq = event_queue.EventQueue(self.fsm) | 2362 | self.eq = event_queue.EventQueue(self.fsm) |
1957 | 2347 | self.original_add = self.eq.add_watch | 2363 | self.original_add = self.eq.add_watch |
1958 | @@ -2361,7 +2377,8 @@ | |||
1959 | 2361 | path = os.path.expanduser(suggested_path).encode("utf8") | 2377 | path = os.path.expanduser(suggested_path).encode("utf8") |
1960 | 2362 | os.makedirs(path) | 2378 | os.makedirs(path) |
1961 | 2363 | udf_id, node_id = 'udf_id', 'node_id' | 2379 | udf_id, node_id = 'udf_id', 'node_id' |
1963 | 2364 | self.udf = self.create_udf(udf_id, node_id, suggested_path, path, True) | 2380 | self.udf = yield self.create_udf(udf_id, node_id, suggested_path, |
1964 | 2381 | path, True) | ||
1965 | 2365 | self.ancestors = self.udf.ancestors # need a fake HOME | 2382 | self.ancestors = self.udf.ancestors # need a fake HOME |
1966 | 2366 | 2383 | ||
1967 | 2367 | # make FSM aware of it | 2384 | # make FSM aware of it |
1968 | 2368 | 2385 | ||
1969 | === modified file 'tests/syncdaemon/test_status_listener.py' | |||
1970 | --- tests/syncdaemon/test_status_listener.py 2011-01-27 20:44:23 +0000 | |||
1971 | +++ tests/syncdaemon/test_status_listener.py 2011-02-03 17:29:42 +0000 | |||
1972 | @@ -120,8 +120,8 @@ | |||
1973 | 120 | public_url = 'http://example.com/foo.mp3' | 120 | public_url = 'http://example.com/foo.mp3' |
1974 | 121 | 121 | ||
1975 | 122 | share_path = os.path.join(self.shares_dir, 'share') | 122 | share_path = os.path.join(self.shares_dir, 'share') |
1978 | 123 | self.main.vm.add_share(Share(path=share_path, volume_id='share', | 123 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share', |
1979 | 124 | other_username='other username')) | 124 | other_username='other username')) |
1980 | 125 | path = os.path.join(share_path, "foo.mp3") | 125 | path = os.path.join(share_path, "foo.mp3") |
1981 | 126 | self.main.fs.create(path, str(share_id)) | 126 | self.main.fs.create(path, str(share_id)) |
1982 | 127 | self.main.fs.set_node_id(path, str(node_id)) | 127 | self.main.fs.set_node_id(path, str(node_id)) |
1983 | @@ -144,8 +144,8 @@ | |||
1984 | 144 | public_url = 'http://example.com/foo.mp3' | 144 | public_url = 'http://example.com/foo.mp3' |
1985 | 145 | 145 | ||
1986 | 146 | share_path = os.path.join(self.shares_dir, 'share') | 146 | share_path = os.path.join(self.shares_dir, 'share') |
1989 | 147 | self.main.vm.add_share(Share(path=share_path, volume_id='share', | 147 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share', |
1990 | 148 | other_username='other username')) | 148 | other_username='other username')) |
1991 | 149 | path = os.path.join(share_path, "foo.mp3") | 149 | path = os.path.join(share_path, "foo.mp3") |
1992 | 150 | self.main.fs.create(path, str(share_id)) | 150 | self.main.fs.create(path, str(share_id)) |
1993 | 151 | self.main.fs.set_node_id(path, str(node_id)) | 151 | self.main.fs.set_node_id(path, str(node_id)) |
1994 | @@ -210,7 +210,7 @@ | |||
1995 | 210 | SHARE_ID = "fake share id" | 210 | SHARE_ID = "fake share id" |
1996 | 211 | d = defer.Deferred() | 211 | d = defer.Deferred() |
1997 | 212 | share = Share(volume_id=SHARE_ID) | 212 | share = Share(volume_id=SHARE_ID) |
1999 | 213 | self.main.vm.add_share(share) | 213 | yield self.main.vm.add_share(share) |
2000 | 214 | self._listen_for('VM_SHARE_CREATED', d.callback) | 214 | self._listen_for('VM_SHARE_CREATED', d.callback) |
2001 | 215 | self.main.event_q.push('VM_SHARE_CREATED', share) | 215 | self.main.event_q.push('VM_SHARE_CREATED', share) |
2002 | 216 | yield d | 216 | yield d |
2003 | 217 | 217 | ||
2004 | === modified file 'tests/syncdaemon/test_sync.py' | |||
2005 | --- tests/syncdaemon/test_sync.py 2011-01-25 18:29:04 +0000 | |||
2006 | +++ tests/syncdaemon/test_sync.py 2011-02-03 17:29:42 +0000 | |||
2007 | @@ -75,6 +75,7 @@ | |||
2008 | 75 | class FSKeyTestCase(BaseTwistedTestCase): | 75 | class FSKeyTestCase(BaseTwistedTestCase): |
2009 | 76 | """ Base test case for FSKey """ | 76 | """ Base test case for FSKey """ |
2010 | 77 | 77 | ||
2011 | 78 | @defer.inlineCallbacks | ||
2012 | 78 | def setUp(self): | 79 | def setUp(self): |
2013 | 79 | """ Setup the test """ | 80 | """ Setup the test """ |
2014 | 80 | unittest.TestCase.setUp(self) | 81 | unittest.TestCase.setUp(self) |
2015 | @@ -93,8 +94,7 @@ | |||
2016 | 93 | self.db) | 94 | self.db) |
2017 | 94 | self.eq = EventQueue(self.fsm) | 95 | self.eq = EventQueue(self.fsm) |
2018 | 95 | self.fsm.register_eq(self.eq) | 96 | self.fsm.register_eq(self.eq) |
2021 | 96 | self.share = self.create_share('share', 'share_name', | 97 | self.share = yield self.create_share('share', 'share_name') |
2020 | 97 | self.fsm, self.shares_dir) | ||
2022 | 98 | self.share_path = self.share.path | 98 | self.share_path = self.share.path |
2023 | 99 | 99 | ||
2024 | 100 | def tearDown(self): | 100 | def tearDown(self): |
2025 | @@ -103,16 +103,15 @@ | |||
2026 | 103 | self.db.shutdown() | 103 | self.db.shutdown() |
2027 | 104 | shutil.rmtree(self.test_dir) | 104 | shutil.rmtree(self.test_dir) |
2028 | 105 | 105 | ||
2034 | 106 | @staticmethod | 106 | @defer.inlineCallbacks |
2035 | 107 | def create_share(share_id, share_name, fsm, shares_dir, | 107 | def create_share(self, share_id, share_name, access_level='Modify'): |
2036 | 108 | access_level='Modify'): | 108 | """Create a share.""" |
2037 | 109 | """ creates a share """ | 109 | share_path = os.path.join(self.shares_dir, share_name) |
2033 | 110 | share_path = os.path.join(shares_dir, share_name) | ||
2038 | 111 | os.makedirs(share_path) | 110 | os.makedirs(share_path) |
2039 | 112 | share = Share(path=share_path, volume_id=share_id, | 111 | share = Share(path=share_path, volume_id=share_id, |
2040 | 113 | access_level=access_level) | 112 | access_level=access_level) |
2043 | 114 | fsm.vm.add_share(share) | 113 | yield self.fsm.vm.add_share(share) |
2044 | 115 | return share | 114 | defer.returnValue(share) |
2045 | 116 | 115 | ||
2046 | 117 | 116 | ||
2047 | 118 | class FSKeyTests(FSKeyTestCase): | 117 | class FSKeyTests(FSKeyTestCase): |
2048 | 119 | 118 | ||
2049 | === modified file 'tests/syncdaemon/test_u1sdtool.py' | |||
2050 | --- tests/syncdaemon/test_u1sdtool.py 2011-01-14 13:11:47 +0000 | |||
2051 | +++ tests/syncdaemon/test_u1sdtool.py 2011-02-03 17:29:42 +0000 | |||
2052 | @@ -179,12 +179,13 @@ | |||
2053 | 179 | d.addCallback(check) | 179 | d.addCallback(check) |
2054 | 180 | return d | 180 | return d |
2055 | 181 | 181 | ||
2056 | 182 | @defer.inlineCallbacks | ||
2057 | 182 | def test_show_current_transfers(self): | 183 | def test_show_current_transfers(self): |
2058 | 183 | """test the output of --current_transfers option with transfers in | 184 | """test the output of --current_transfers option with transfers in |
2059 | 184 | progress. | 185 | progress. |
2060 | 185 | """ | 186 | """ |
2061 | 186 | share_path = os.path.join(self.shares_dir, 'share') | 187 | share_path = os.path.join(self.shares_dir, 'share') |
2063 | 187 | self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) | 188 | yield self.main.vm.add_share(Share(path=share_path, volume_id='share_id')) |
2064 | 188 | # create a download | 189 | # create a download |
2065 | 189 | down_path = os.path.join(share_path, "down_path") | 190 | down_path = os.path.join(share_path, "down_path") |
2066 | 190 | self.fs_manager.create(down_path, "share_id") | 191 | self.fs_manager.create(down_path, "share_id") |
2067 | @@ -203,15 +204,13 @@ | |||
2068 | 203 | "downloads:\n path: %(down_path)s\n deflated size: " + \ | 204 | "downloads:\n path: %(down_path)s\n deflated size: " + \ |
2069 | 204 | "10\n bytes read: 1\n" | 205 | "10\n bytes read: 1\n" |
2070 | 205 | expected = expected % dict(up_path=up_path, down_path=down_path) | 206 | expected = expected % dict(up_path=up_path, down_path=down_path) |
2080 | 206 | d = self.tool.get_current_uploads() | 207 | result = yield self.tool.get_current_uploads() |
2081 | 207 | d.addCallback(lambda result: show_uploads(result, out)) | 208 | show_uploads(result, out) |
2082 | 208 | d.addCallback(lambda _: self.tool.get_current_downloads()) | 209 | |
2083 | 209 | d.addCallback(lambda result: show_downloads(result, out)) | 210 | result = yield self.tool.get_current_downloads() |
2084 | 210 | def check(result): | 211 | show_downloads(result, out) |
2085 | 211 | """check the output""" | 212 | |
2086 | 212 | self.assertEquals(out.getvalue(), expected) | 213 | self.assertEquals(out.getvalue(), expected) |
2078 | 213 | d.addCallback(check) | ||
2079 | 214 | return d | ||
2087 | 215 | 214 | ||
2088 | 216 | def test_show_state(self): | 215 | def test_show_state(self): |
2089 | 217 | """test the output of --status """ | 216 | """test the output of --status """ |
Looks good!