1
# -*- coding: utf-8 -*-
3
# Author: Alejandro J. Cura <alecu@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 account tab."""
21
from twisted.internet import defer
23
from ubuntuone.controlpanel.gui import qt
24
from ubuntuone.controlpanel.gui.qt import account as gui
25
from ubuntuone.controlpanel.gui.qt.tests import (
26
SAMPLE_ACCOUNT_INFO, SAMPLE_EMAIL, SAMPLE_NAME, SAMPLE_PLAN,
28
from ubuntuone.controlpanel.gui.qt.tests.test_ubuntuonebin import (
33
class AccountPanelTestCase(UbuntuOneBinTestCase):
34
"""Test the qt control panel."""
36
innerclass_ui = gui.account_ui
37
innerclass_name = "Ui_Form"
38
class_ui = gui.AccountPanel
40
@defer.inlineCallbacks
42
yield super(AccountPanelTestCase, self).setUp()
43
self.ui.backend.next_result = SAMPLE_ACCOUNT_INFO
45
def test_is_processing_while_asking_info(self):
46
"""The ui is processing while the contents are loaded."""
48
"""The ui must be is_processing."""
49
self.assertTrue(self.ui.is_processing, 'ui must be processing')
50
return SAMPLE_ACCOUNT_INFO
52
self.patch(self.ui.backend, 'account_info', check)
54
return self.ui.load() # trigger the info request
56
def test_is_not_processing_after_info_ready(self):
57
"""The ui is not processing when contents are load."""
58
self.ui.process_info(SAMPLE_ACCOUNT_INFO)
60
self.assertFalse(self.ui.is_processing)
62
@defer.inlineCallbacks
63
def test_info_is_requested_on_load(self):
64
"""The info is requested to the backend."""
66
self.assert_backend_called('account_info')
68
def test_process_info(self):
69
"""The info is processed when ready."""
70
self.ui.process_info(SAMPLE_ACCOUNT_INFO)
71
self.assertEqual(self.ui.ui.name_label.text(), SAMPLE_NAME)
72
self.assertEqual(self.ui.ui.email_label.text(), SAMPLE_EMAIL)
73
self.assertEqual(self.ui.ui.services_description_label.text(),
76
def test_edit_account_button(self):
77
"""When clicking the edit account button, the proper url is opened."""
78
self.patch(qt, 'uri_hook', self._set_called)
79
self.ui.ui.edit_profile_button.click()
81
self.assertEqual(self._called, ((gui.EDIT_PROFILE_LINK,), {}))
83
def test_edit_services_button(self):
84
"""When clicking the mobile plan button, the proper url is opened."""
85
self.patch(qt, 'uri_hook', self._set_called)
86
self.ui.ui.edit_services_button.click()
88
self.assertEqual(self._called, ((gui.EDIT_ACCOUNT_LINK,), {}))