~ubuntu-branches/ubuntu/precise/ubuntuone-client/precise-201201132228

« back to all changes in this revision

Viewing changes to tests/platform/linux/test_config.py

  • Committer: Package Import Robot
  • Author(s): Rodney Dawes
  • Date: 2011-12-21 15:46:25 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20111221154625-ujvunri4frsecj2k
Tags: 2.99.0-0ubuntu1
* New upstream release.
  - Verify timestamp to avoid invalid auth failures (LP: #692597)
  - Files in new UDFs not uploaded due to filtering (LP: #869920)
* debian/patches:
  - Remove upstreamed patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
 
3
 
# Copyright 2010-2011 Canonical Ltd.
4
 
#
5
 
# This program is free software: you can redistribute it and/or modify it
6
 
# under the terms of the GNU General Public License version 3, as published
7
 
# by the Free Software Foundation.
8
 
#
9
 
# This program is distributed in the hope that it will be useful, but
10
 
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
 
# PURPOSE.  See the GNU General Public License for more details.
13
 
#
14
 
# You should have received a copy of the GNU General Public License along
15
 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
 
17
 
from ConfigParser import ConfigParser
18
 
 
19
 
from tests.platform.linux.test_dbus import DBusTwistedTestCase
20
 
from ubuntuone.syncdaemon import config
21
 
 
22
 
 
23
 
class TestDBusConfig(DBusTwistedTestCase):
24
 
 
25
 
    def test_get_throttling_limits(self):
26
 
        """Test getting throttling limits"""
27
 
        dbus_config = self.main.external.dbus_iface.config
28
 
        limits = dbus_config.get_throttling_limits()
29
 
        self.assertEquals(limits['download'], -1)
30
 
        self.assertEquals(limits['upload'], -1)
31
 
 
32
 
    def test_set_throttling_limits(self):
33
 
        """Test setting throttling limits"""
34
 
        dbus_config = self.main.external.dbus_iface.config
35
 
        dbus_config.set_throttling_limits(10, 20)
36
 
        limits = dbus_config.get_throttling_limits()
37
 
        self.assertEquals(limits['download'], 10)
38
 
        self.assertEquals(limits['upload'], 20)
39
 
        conf = ConfigParser()
40
 
        conf.read(config.get_user_config().config_file)
41
 
        self.assertEquals(conf.get(config.THROTTLING, 'read_limit'), '10')
42
 
        self.assertEquals(conf.get(config.THROTTLING, 'write_limit'), '20')
43
 
 
44
 
    def test_enable_bandwidth_throttling(self):
45
 
        """Test for enabling bandwidth throttling"""
46
 
        dbus_config = self.main.external.dbus_iface.config
47
 
        enabled = dbus_config.bandwidth_throttling_enabled()
48
 
        self.assertFalse(enabled)
49
 
        dbus_config.enable_bandwidth_throttling()
50
 
        enabled = dbus_config.bandwidth_throttling_enabled()
51
 
        self.assertTrue(enabled)
52
 
        conf = ConfigParser()
53
 
        conf.read(config.get_user_config().config_file)
54
 
        self.assertEquals(conf.get(config.THROTTLING, 'on'), 'True')
55
 
 
56
 
    def test_disable_bandwidth_throttling(self):
57
 
        """Test for disabling bandwidth throttling"""
58
 
        dbus_config = self.main.external.dbus_iface.config
59
 
        enabled = dbus_config.bandwidth_throttling_enabled()
60
 
        self.assertFalse(enabled)
61
 
        # enable throttling
62
 
        dbus_config.enable_bandwidth_throttling()
63
 
        enabled = dbus_config.bandwidth_throttling_enabled()
64
 
        self.assertTrue(enabled)
65
 
        # now disable throttling and check
66
 
        dbus_config.disable_bandwidth_throttling()
67
 
        enabled = dbus_config.bandwidth_throttling_enabled()
68
 
        self.assertFalse(enabled)
69
 
        conf = ConfigParser()
70
 
        conf.read(config.get_user_config().config_file)
71
 
        self.assertEquals(conf.get(config.THROTTLING, 'on'), 'False')
72
 
 
73
 
    def test_files_sync_enabled(self):
74
 
        """Test for toggling files sync."""
75
 
        dbus_config = self.main.external.dbus_iface.config
76
 
        enabled = dbus_config.files_sync_enabled()
77
 
        self.assertTrue(enabled)
78
 
        dbus_config.set_files_sync_enabled(False)
79
 
        enabled = dbus_config.files_sync_enabled()
80
 
        self.assertFalse(enabled)
81
 
        dbus_config.set_files_sync_enabled(True)
82
 
        enabled = dbus_config.files_sync_enabled()
83
 
        self.assertTrue(enabled)
84
 
        conf = ConfigParser()
85
 
        conf.read(config.get_user_config().config_file)
86
 
        self.assertEquals(conf.get(config.MAIN, 'files_sync_enabled'), 'True')