1
# -*- coding: utf-8 -*-
3
# Author: Manuel de la Pena<manuel@canonical.com>
5
# Copyright 2011 Canonical Ltd.
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.
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.
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/>.
19
"""Tests for the network manager."""
21
from mocker import MockerTestCase
23
from ubuntuone.platform.windows.network_manager import NetworkManager
26
class TestNetworkManager(MockerTestCase):
27
"""Test he Network Manager."""
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)
37
def test_connection_made(self):
38
"""Ensure db is called."""
39
self.connection_info()
41
self.manager.ConnectionMade()
43
def test_connection_made_no_cb(self):
44
"""Ensure db is called."""
45
self.manager.connected_cb_info = None
47
self.manager.ConnectionMade()
49
def test_connection_made_no_info(self):
50
"""Ensure db is called."""
51
self.connection_no_info()
53
self.manager.ConnectionMadeNoQOCInfo()
55
def test_connection_made_no_info_no_cb(self):
56
"""Ensure db is called."""
57
self.manager.connected_cb = None
59
self.manager.ConnectionMadeNoQOCInfo()
61
def test_disconnection(self):
62
"""Ensure db is called."""
65
self.manager.ConnectionLost()
67
def test_disconnection_no_cb(self):
68
"""Ensure db is called."""
69
self.manager.disconnected_cb = None
71
self.manager.ConnectionLost()