Merge lp:~ralsina/ubuntuone-client/el-sendero-de-warren-sanchez into lp:ubuntuone-client

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 1334
Merged at revision: 1331
Proposed branch: lp:~ralsina/ubuntuone-client/el-sendero-de-warren-sanchez
Merge into: lp:ubuntuone-client
Diff against target: 151 lines (+36/-7)
3 files modified
tests/platform/linux/eventlog/test_zg_listener.py (+2/-1)
tests/syncdaemon/test_action_queue.py (+30/-4)
ubuntuone/syncdaemon/action_queue.py (+4/-2)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-client/el-sendero-de-warren-sanchez
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Review via email: mp+128049@code.launchpad.net

Commit message

- Added self.path to Upload and Download objects (LP:1061490).

Description of the change

Make it so Upload and Download objects have a self.path, which is used by the sync menu.

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/linux/eventlog/test_zg_listener.py'
2--- tests/platform/linux/eventlog/test_zg_listener.py 2012-09-07 20:53:24 +0000
3+++ tests/platform/linux/eventlog/test_zg_listener.py 2012-10-04 18:24:20 +0000
4@@ -572,9 +572,10 @@
5 """Just to allow monkeypatching."""
6
7 self.share_id = ""
8+ self.mdid = self.main.fs.create(os.path.join(self.root, 'file'), '')
9 self.command = MyUpload(request_queue, share_id=self.share_id,
10 node_id='a_node_id', previous_hash='prev_hash',
11- hash='yadda', crc32=0, size=0, mdid='mdid')
12+ hash='yadda', crc32=0, size=0, mdid=self.mdid)
13 self.command.make_logger()
14 self.command.tempfile = FakeTempFile(self.mktemp('tmpdir'))
15 self.fsm = self.action_queue.main.fs
16
17=== modified file 'tests/syncdaemon/test_action_queue.py'
18--- tests/syncdaemon/test_action_queue.py 2012-09-14 19:24:25 +0000
19+++ tests/syncdaemon/test_action_queue.py 2012-10-04 18:24:20 +0000
20@@ -1,4 +1,4 @@
21-# -*- coding: utf-8 -*-
22+#-*- coding: utf-8 -*-
23 #
24 # Copyright 2009-2012 Canonical Ltd.
25 #
26@@ -2776,9 +2776,11 @@
27 yield super(DownloadUnconnectedTestCase, self).setUp()
28
29 self.rq = request_queue = RequestQueue(action_queue=self.action_queue)
30+ self.test_path = os.path.join(self.root, 'file')
31+ self.mdid = self.main.fs.create(self.test_path, '')
32 self.command = Download(request_queue, share_id='a_share_id',
33 node_id='a_node_id', server_hash='server_hash',
34- mdid='mdid')
35+ mdid=self.mdid)
36 self.command.make_logger()
37
38 def test_progress_information_setup(self):
39@@ -2798,6 +2800,11 @@
40 self.assertEqual(meth, 'get_content_request')
41 self.assertEqual(kwargs['offset'], 0) # resumable is not there yet
42
43+ def test_has_path(self):
44+ """All Downloads must have a path."""
45+ expected = os.path.join('test_has_path', 'root', 'file')
46+ self.assertIn(expected, self.command.path)
47+
48
49 class DownloadTestCase(ConnectedBaseTestCase):
50 """Test for Download ActionQueueCommand."""
51@@ -3066,8 +3073,10 @@
52
53 self.patch(self.main.fs, 'get_partial_for_writing',
54 lambda n, s: FakeFileObj())
55+ test_path = os.path.join(self.root, 'foo', 'bar')
56+ mdid = self.main.fs.create(test_path, '')
57 cmd = Download(self.rq, 'a_share_id','a_node_id', 'server_hash',
58- os.path.join(os.path.sep, 'foo','bar'))
59+ mdid)
60
61 # first run, it is just instantiated
62 cmd._run()
63@@ -3084,6 +3093,11 @@
64 self.assertEqual(cmd.fileobj.seek_count, 2)
65 self.assertEqual(cmd.fileobj.truncate_count, 2)
66
67+ def test_has_path(self):
68+ """All Downloads must have a path."""
69+ expected = os.path.join('test_has_path', 'root', 'file')
70+ self.assertIn(expected, self.command.path)
71+
72
73 class UploadUnconnectedTestCase(FactoryBaseTestCase):
74 """Test for Upload ActionQueueCommand, no connection"""
75@@ -3092,11 +3106,13 @@
76 def setUp(self):
77 """Init."""
78 yield super(UploadUnconnectedTestCase, self).setUp()
79+ self.test_path = os.path.join(self.root, 'file')
80+ self.mdid = self.main.fs.create(self.test_path, '')
81
82 self.rq = request_queue = RequestQueue(action_queue=self.action_queue)
83 self.command = Upload(request_queue, share_id='a_share_id',
84 node_id='a_node_id', previous_hash='prev_hash',
85- hash='yadda', crc32=0, size=0, mdid='mdid')
86+ hash='yadda', crc32=0, size=0, mdid=self.mdid)
87 self.command.make_logger()
88 self.command.magic_hash = FakeMagicHash()
89 self.client = FakeClient()
90@@ -3136,6 +3152,11 @@
91 self.assertTrue(isinstance(args[7], UploadProgressWrapper))
92 self.assertEqual(kwargs['magic_hash'], '666')
93
94+ def test_has_path(self):
95+ """All Uploads must have a path."""
96+ expected = os.path.join('test_has_path', 'root', 'file')
97+ self.assertIn(expected, self.command.path)
98+
99
100 class UploadProgressWrapperTestCase(BaseTwistedTestCase):
101 """Test for the UploadProgressWrapper helper class."""
102@@ -3679,6 +3700,11 @@
103 self.command._run()
104 self.assertEqual(called, [0])
105
106+ def test_has_path(self):
107+ """All Uploads must have a path."""
108+ expected = os.path.join('test_has_path', 'root', 'foo', 'bar')
109+ self.assertIn(expected, self.command.path)
110+
111
112 class CreateShareTestCase(ConnectedBaseTestCase):
113 """Test for CreateShare ActionQueueCommand."""
114
115=== modified file 'ubuntuone/syncdaemon/action_queue.py'
116--- ubuntuone/syncdaemon/action_queue.py 2012-10-02 19:52:03 +0000
117+++ ubuntuone/syncdaemon/action_queue.py 2012-10-04 18:24:20 +0000
118@@ -2363,7 +2363,7 @@
119
120 __slots__ = ('share_id', 'node_id', 'server_hash',
121 'fileobj', 'gunzip', 'mdid', 'download_req', 'tx_semaphore',
122- 'deflated_size', 'n_bytes_read_last', 'n_bytes_read')
123+ 'deflated_size', 'n_bytes_read_last', 'n_bytes_read', 'path')
124 logged_attrs = ActionQueueCommand.logged_attrs + (
125 'share_id', 'node_id', 'server_hash', 'mdid')
126 possible_markers = 'node_id',
127@@ -2381,6 +2381,7 @@
128 self.n_bytes_read_last = 0
129 self.deflated_size = None
130 self.tx_semaphore = None
131+ self.path = self._get_current_path(mdid)
132
133 @property
134 def uniqueness(self):
135@@ -2530,7 +2531,7 @@
136 __slots__ = ('share_id', 'node_id', 'previous_hash', 'hash', 'crc32',
137 'size', 'magic_hash', 'deflated_size', 'tempfile',
138 'tx_semaphore', 'n_bytes_written_last', 'upload_req',
139- 'n_bytes_written', 'upload_id', 'mdid')
140+ 'n_bytes_written', 'upload_id', 'mdid', 'path')
141
142 logged_attrs = ActionQueueCommand.logged_attrs + (
143 'share_id', 'node_id', 'previous_hash', 'hash', 'crc32',
144@@ -2557,6 +2558,7 @@
145 self.deflated_size = None
146 self.tx_semaphore = None
147 self.magic_hash = None
148+ self.path = self._get_current_path(mdid)
149
150 @property
151 def is_runnable(self):

Subscribers

People subscribed via source and target branches