~nataliabidart/ubuntuone-client/use-sso-qt

« back to all changes in this revision

Viewing changes to tests/platform/windows/test_network_manager.py

  • Committer: Natalia B. Bidart
  • Date: 2012-02-22 20:50:31 UTC
  • mfrom: (1193.1.3 ubuntuone-client)
  • Revision ID: natalia.bidart@canonical.com-20120222205031-kxwlj8fxzykyvrw1
MergedĀ trunkĀ in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
#
3
 
# Author: Manuel de la Pena<manuel@canonical.com>
4
 
#
5
 
# Copyright 2011 Canonical Ltd.
6
 
#
7
 
# This program is free software: you can redistribute it and/or modify it
8
 
# under the terms of the GNU General Public License version 3, as published
9
 
# by the Free Software Foundation.
10
 
#
11
 
# This program is distributed in the hope that it will be useful, but
12
 
# WITHOUT ANY WARRANTY; without even the implied warranties of
13
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
 
# PURPOSE.  See the GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License along
17
 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 
19
 
"""Tests for the network manager."""
20
 
 
21
 
from mocker import MockerTestCase
22
 
 
23
 
from ubuntuone.platform.windows.network_manager import NetworkManager
24
 
 
25
 
 
26
 
class TestNetworkManager(MockerTestCase):
27
 
    """Test he Network Manager."""
28
 
 
29
 
    def setUp(self):
30
 
        super(TestNetworkManager, self).setUp()
31
 
        self.connection_info = self.mocker.mock()
32
 
        self.connection_no_info = self.mocker.mock()
33
 
        self.disconnected = self.mocker.mock()
34
 
        self.manager = NetworkManager(self.connection_no_info,
35
 
                                      self.connection_info, self.disconnected)
36
 
 
37
 
    def test_connection_made(self):
38
 
        """Ensure db is called."""
39
 
        self.connection_info()
40
 
        self.mocker.replay()
41
 
        self.manager.ConnectionMade()
42
 
 
43
 
    def test_connection_made_no_cb(self):
44
 
        """Ensure db is called."""
45
 
        self.manager.connected_cb_info = None
46
 
        self.mocker.replay()
47
 
        self.manager.ConnectionMade()
48
 
 
49
 
    def test_connection_made_no_info(self):
50
 
        """Ensure db is called."""
51
 
        self.connection_no_info()
52
 
        self.mocker.replay()
53
 
        self.manager.ConnectionMadeNoQOCInfo()
54
 
 
55
 
    def test_connection_made_no_info_no_cb(self):
56
 
        """Ensure db is called."""
57
 
        self.manager.connected_cb = None
58
 
        self.mocker.replay()
59
 
        self.manager.ConnectionMadeNoQOCInfo()
60
 
 
61
 
    def test_disconnection(self):
62
 
        """Ensure db is called."""
63
 
        self.disconnected()
64
 
        self.mocker.replay()
65
 
        self.manager.ConnectionLost()
66
 
 
67
 
    def test_disconnection_no_cb(self):
68
 
        """Ensure db is called."""
69
 
        self.manager.disconnected_cb = None
70
 
        self.mocker.replay()
71
 
        self.manager.ConnectionLost()