~facundo/magicicada-client/add-dbus-dep

« back to all changes in this revision

Viewing changes to contrib/testing/testcase.py

  • Committer: Magicicada Bot
  • Author(s): Facundo Batista
  • Date: 2018-04-25 20:17:26 UTC
  • mfrom: (1442.2.3 remove-sync-menu)
  • Revision ID: magicicada_bot-20180425201726-2zmh9i295rai1qj2
[r=nataliabidart] Remove SyncMenu traces - no more UI client except Magicicada own shiny thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    main,
59
59
    local_rescan,
60
60
    tritcask,
61
 
    RECENT_TRANSFERS,
62
 
    UPLOADING,
63
61
)
64
62
from ubuntuone.syncdaemon import logger
65
63
from ubuntuone import platform
78
76
                     'password': 'test_password'}
79
77
 
80
78
 
 
79
def NOOP(*a, **kw):
 
80
    """Do nothing."""
 
81
 
 
82
 
81
83
@contextlib.contextmanager
82
84
def environ(env_var, new_value):
83
85
    """context manager to replace/add an environ value"""
190
192
    node_is_with_queued_move = cleanup = get_public_files = disconnect
191
193
 
192
194
 
193
 
class FakeStatusListener(object):
194
 
    """A fake StatusListener."""
195
 
 
196
 
    def menu_data(self):
197
 
        """Fake menu_data."""
198
 
        return {RECENT_TRANSFERS: [], UPLOADING: []}
199
 
 
200
 
 
201
195
class FakeMonitor(object):
202
196
    """A fake FilesystemMonitor."""
203
197
 
259
253
        self.vm = volume_manager.VolumeManager(self)
260
254
        self.fs = fs_manager.FileSystemManager(
261
255
            self.data_dir, self.partials_dir, self.vm, self.db)
262
 
        self.event_q = event_queue.EventQueue(self.fs,
263
 
                                              monitor_class=self._monitor_class)
 
256
        self.event_q = event_queue.EventQueue(
 
257
            self.fs, monitor_class=self._monitor_class)
264
258
        self.fs.register_eq(self.event_q)
265
259
        self.action_q = self._fake_AQ_class(self.event_q, self,
266
260
                                            *self._fake_AQ_params)
275
269
        self.lr = local_rescan.LocalRescan(self.vm, self.fs,
276
270
                                           self.event_q, self.action_q)
277
271
 
278
 
        self.status_listener = FakeStatusListener()
279
 
 
280
272
    def _connect_aq(self, _):
281
273
        """Connect the fake action queue."""
282
274
        self.action_q.connect()
408
400
        self.patch(platform, "user_home", self.home_dir)
409
401
 
410
402
        # use the config from the branch
411
 
        new_get_config_files = lambda: [os.path.join(os.environ['ROOTDIR'],
412
 
                                                     'data', 'syncdaemon.conf')]
413
 
        self.patch(config, 'get_config_files', new_get_config_files)
 
403
        self.patch(config, 'get_config_files', lambda: [
 
404
            os.path.join(os.environ['ROOTDIR'], 'data', 'syncdaemon.conf')])
414
405
 
415
406
        # fake a very basic config file with sane defaults for the tests
416
407
        config_dir = self.mktemp('config')
626
617
        try:
627
618
            result = super(FakedObject, self).__getattribute__(attr_name)
628
619
        except AttributeError:
629
 
            result = lambda *a, **kw: None
 
620
            result = NOOP
630
621
            super(FakedObject, self).__setattr__(attr_name, result)
631
622
 
632
623
        if attr_name == '_called':