Merge lp:~verterok/ubuntuone-client/really-disable-throttling into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Nicola Larosa
Approved revision: 278
Merged at revision: not available
Proposed branch: lp:~verterok/ubuntuone-client/really-disable-throttling
Merge into: lp:ubuntuone-client
Diff against target: 126 lines (+75/-12)
2 files modified
tests/syncdaemon/test_config.py (+64/-0)
ubuntuone/syncdaemon/dbus_interface.py (+11/-12)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/really-disable-throttling
Reviewer Review Type Date Requested Status
Nicola Larosa (community) Approve
Rick McBride (community) Approve
Review via email: mp+14908@code.launchpad.net

Commit message

Fix syncdaemon exposed DBus Config.disable_bandwidth_throttling method

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

Fix a silly bug in Syncdaemon DBus Config exposed method to disable bandwidth throttling.

278. By Guillermo Gonzalez

fix typo s/thorttling/throttling/

Revision history for this message
Rick McBride (rmcbride) wrote :

Looks good, thanks for fixing the self._set_thorttling_enabled stuff. Autocompletion kept it consistent anyhow :)

review: Approve
Revision history for this message
Nicola Larosa (teknico) wrote :

Wow, hideous bug. Thanks for the tests too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/syncdaemon/test_config.py'
--- tests/syncdaemon/test_config.py 2009-11-06 19:31:17 +0000
+++ tests/syncdaemon/test_config.py 2009-11-17 21:45:22 +0000
@@ -31,6 +31,7 @@
31)31)
32from contrib.testing.testcase import (32from contrib.testing.testcase import (
33 BaseTwistedTestCase,33 BaseTwistedTestCase,
34 DBusTwistedTestCase,
34)35)
3536
3637
@@ -293,3 +294,66 @@
293 self.assertEquals('/hola', parser(bad_value))294 self.assertEquals('/hola', parser(bad_value))
294 self.assertRaises(AttributeError, parser, invalid_value)295 self.assertRaises(AttributeError, parser, invalid_value)
295296
297
298class TestDBusConfig(DBusTwistedTestCase):
299
300 def setUp(self):
301 """Fake the user_config file, and setup all SD stuff"""
302 self.old_get_config_files = config.get_config_files
303 config.get_config_files = lambda: [os.path.join(os.environ['ROOT_DIR'],
304 'data', 'syncdaemon.conf')]
305 return DBusTwistedTestCase.setUp(self)
306
307 def tearDown(self):
308 """cleanup everything, also the config module globals"""
309 config._user_config = None
310 config.get_config_files = self.old_get_config_files
311 return DBusTwistedTestCase.tearDown(self)
312
313 def test_get_throttling_limits(self):
314 """Test getting throttling limits"""
315 dbus_config = self.main.dbus_iface.config
316 limits = dbus_config.get_throttling_limits()
317 self.assertEquals(limits['download'], -1)
318 self.assertEquals(limits['upload'], -1)
319
320 def test_set_throttling_limits(self):
321 """Test setting throttling limits"""
322 dbus_config = self.main.dbus_iface.config
323 dbus_config.set_throttling_limits(10, 20)
324 limits = dbus_config.get_throttling_limits()
325 self.assertEquals(limits['download'], 10)
326 self.assertEquals(limits['upload'], 20)
327 conf = ConfigParser()
328 conf.read(config.get_user_config().config_file)
329 self.assertEquals(conf.get(config.THROTTLING, 'read_limit'), '10')
330 self.assertEquals(conf.get(config.THROTTLING, 'write_limit'), '20')
331
332 def test_enable_bandwidth_throttling(self):
333 """Test for enabling bandwidth throttling"""
334 dbus_config = self.main.dbus_iface.config
335 enabled = dbus_config.bandwidth_throttling_enabled()
336 self.assertFalse(enabled)
337 dbus_config.enable_bandwidth_throttling()
338 enabled = dbus_config.bandwidth_throttling_enabled()
339 self.assertTrue(enabled)
340 conf = ConfigParser()
341 conf.read(config.get_user_config().config_file)
342 self.assertEquals(conf.get(config.THROTTLING, 'on'), 'True')
343
344 def test_disable_bandwidth_throttling(self):
345 """Test for disabling bandwidth throttling"""
346 dbus_config = self.main.dbus_iface.config
347 enabled = dbus_config.bandwidth_throttling_enabled()
348 self.assertFalse(enabled)
349 # enable throttling
350 dbus_config.enable_bandwidth_throttling()
351 enabled = dbus_config.bandwidth_throttling_enabled()
352 self.assertTrue(enabled)
353 # now disable throttling and check
354 dbus_config.disable_bandwidth_throttling()
355 enabled = dbus_config.bandwidth_throttling_enabled()
356 self.assertFalse(enabled)
357 conf = ConfigParser()
358 conf.read(config.get_user_config().config_file)
359 self.assertEquals(conf.get(config.THROTTLING, 'on'), 'False')
296360
=== modified file 'ubuntuone/syncdaemon/dbus_interface.py'
--- ubuntuone/syncdaemon/dbus_interface.py 2009-10-28 17:00:50 +0000
+++ ubuntuone/syncdaemon/dbus_interface.py 2009-11-17 21:45:23 +0000
@@ -889,12 +889,7 @@
889 error_handler=None):889 error_handler=None):
890 """Enable bandwidth throttling."""890 """Enable bandwidth throttling."""
891 try:891 try:
892 # modify and save the config file892 self._set_throttling_enabled(True)
893 config = get_user_config()
894 config.set_throttling(True)
895 config.save()
896 # modify AQ settings
897 self.dbus_iface.action_queue.enable_throttling(True)
898 if reply_handler:893 if reply_handler:
899 reply_handler()894 reply_handler()
900 # pylint: disable-msg=W0703895 # pylint: disable-msg=W0703
@@ -911,12 +906,7 @@
911 error_handler=None):906 error_handler=None):
912 """Disable bandwidth throttling."""907 """Disable bandwidth throttling."""
913 try:908 try:
914 # modify and save the config file909 self._set_throttling_enabled(False)
915 config = get_user_config()
916 config.set_throttling(True)
917 config.save()
918 # modify AQ settings
919 self.dbus_iface.action_queue.enable_throttling(False)
920 if reply_handler:910 if reply_handler:
921 reply_handler()911 reply_handler()
922 # pylint: disable-msg=W0703912 # pylint: disable-msg=W0703
@@ -926,6 +916,15 @@
926 else:916 else:
927 raise917 raise
928918
919 def _set_throttling_enabled(self, enabled):
920 """set throttling enabled value and save the config"""
921 # modify and save the config file
922 config = get_user_config()
923 config.set_throttling(enabled)
924 config.save()
925 # modify AQ settings
926 self.dbus_iface.action_queue.enable_throttling(enabled)
927
929 @dbus.service.method(DBUS_IFACE_CONFIG_NAME,928 @dbus.service.method(DBUS_IFACE_CONFIG_NAME,
930 in_signature='', out_signature='b',929 in_signature='', out_signature='b',
931 async_callbacks=('reply_handler', 'error_handler'))930 async_callbacks=('reply_handler', 'error_handler'))

Subscribers

People subscribed via source and target branches