~didrocks/ubuntuone-client/dont-suffer-zg-crash

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_u1sdtool.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-01-25 16:42:52 UTC
  • mto: This revision was merged to the branch mainline in revision 64.
  • Revision ID: james.westby@ubuntu.com-20110125164252-rl1pybasx1nsqgoy
Tags: upstream-1.5.3
ImportĀ upstreamĀ versionĀ 1.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from operator import itemgetter
21
21
from StringIO import StringIO
22
22
from tests.platform.linux.test_tools import TestToolsBase, FakeCommand
 
23
from ubuntuone.syncdaemon.action_queue import Upload
23
24
from ubuntuone.syncdaemon.volume_manager import Share, UDF
24
25
from ubuntuone.platform.linux.tools import (
25
26
    show_dirty_nodes,
85
86
        self.fs_manager.create(path, "")
86
87
        self.fs_manager.set_node_id(path, "node_id")
87
88
        # helper function, pylint: disable-msg=C0111
88
 
        def fake_create_share(node_id, user, name, access_level, marker):
 
89
        def fake_create_share(node_id, user, name, access_level, marker, path):
89
90
            self.main.vm.handle_AQ_CREATE_SHARE_OK(share_id='share_id',
90
91
                                              marker=marker)
91
92
        self.main.action_q.create_share = fake_create_share
218
219
        expected = [
219
220
            "State: QUEUE_MANAGER",
220
221
            "connection: With User With Network",
221
 
            "description: processing queues",
 
222
            "description: processing the commands pool",
222
223
            "is_connected: True",
223
224
            "is_error: False",
224
225
            "is_online: True",
246
247
        # inject the fake data
247
248
        cmd1 = FakeCommand("", "node_id_1")
248
249
        cmd2 = FakeCommand("", "node_id_2")
249
 
        self.action_q.meta_queue.waiting.extend([cmd1, cmd2])
 
250
        self.action_q.queue.waiting.extend([cmd1, cmd2])
250
251
        out = StringIO()
251
252
        temp = "FakeCommand(share_id='', node_id='%s', path='%s', other='')"
252
253
        exp1 = temp % ("node_id_1", path_1)
259
260
 
260
261
    def test_show_waiting_content(self):
261
262
        """Test the output of --waiting-content"""
262
 
        class FakeCommand2(FakeCommand):
263
 
            pass
 
263
        class FakeCommand1(FakeCommand, Upload):
 
264
            """Fake command that goes in content queue."""
 
265
            def __init__(self, *args):
 
266
                FakeCommand.__init__(self, *args)
 
267
 
 
268
        class FakeCommand2(FakeCommand1):
 
269
            """Fake command that goes in content queue."""
 
270
 
264
271
        path = os.path.join(self.root_dir, "foo")
265
272
        self.fs_manager.create(path, "")
266
273
        self.fs_manager.set_node_id(path, "node_id")
274
281
        self.fs_manager.create(path_3, "")
275
282
        self.fs_manager.set_node_id(path_3, "node_id_3")
276
283
        # inject the fake data
277
 
        self.action_q.content_queue.waiting.extend([
278
 
                FakeCommand("", "node_id"),
 
284
        self.action_q.queue.waiting.extend([
 
285
                FakeCommand1("", "node_id"),
279
286
                FakeCommand2("", "node_id_2"),
280
 
                FakeCommand("", "node_id_1"),
 
287
                FakeCommand1("", "node_id_1"),
281
288
                FakeCommand2("", "node_id_3")])
282
289
        out = StringIO()
283
 
        expected = u"operation='FakeCommand' node_id='node_id' share_id='' " + \
 
290
        expected = u"operation='FakeCommand1' node_id='node_id' share_id='' " + \
284
291
                "path='%(path)s'\n" + \
285
292
                "operation='FakeCommand2' node_id='node_id_2' share_id='' " + \
286
293
                "path='%(path_2)s'\n" + \
287
 
                "operation='FakeCommand' node_id='node_id_1' share_id='' " + \
 
294
                "operation='FakeCommand1' node_id='node_id_1' share_id='' " + \
288
295
                "path='%(path_1)s'\n" + \
289
296
                "operation='FakeCommand2' node_id='node_id_3' share_id=''" + \
290
297
                " path='%(path_3)s'\n"