723
731
messages = ['<small>Test me</small>', 'A <b>little</b> bit more']
734
class AccountTestCase(ControlPanelMixinTestCase):
735
"""The test suite for the account panel."""
737
klass = gui.AccountPanel
738
ui_filename = 'account.ui'
740
def assert_account_info_correct(self, info):
741
"""Check that the displayed account info matches 'info'."""
742
self.assertEqual(self.ui.name_label.get_text(),
743
FAKE_ACCOUNT_INFO['name'])
744
self.assertEqual(self.ui.type_label.get_text(),
745
FAKE_ACCOUNT_INFO['type'])
746
self.assertEqual(self.ui.email_label.get_text(),
747
FAKE_ACCOUNT_INFO['email'])
749
def test_is_a_vbox(self):
750
"""Inherits from gtk.VBox."""
751
self.assertIsInstance(self.ui, gui.gtk.VBox)
753
def test_inner_widget_is_packed(self):
754
"""The 'itself' vbox is packed into the widget."""
755
self.assertIn(self.ui.itself, self.ui.get_children())
757
def test_is_visible(self):
759
self.assertTrue(self.ui.get_visible())
761
def test_type_label_is_loading(self):
762
"""Placeholder for type label is a Loading widget."""
763
self.assertIsInstance(self.ui.type_label, gui.LabelLoading)
764
self.assertIn(self.ui.type_label, self.ui.type_box.get_children())
766
def test_email_label_is_loading(self):
767
"""Placeholder for email label is a Loading widget."""
768
self.assertIsInstance(self.ui.email_label, gui.LabelLoading)
769
self.assertIn(self.ui.email_label, self.ui.email_box.get_children())
771
def test_backend_signals(self):
772
"""The proper signals are connected to the backend."""
773
self.assertEqual(self.ui.backend._signals['AccountInfoReady'],
774
[self.ui.on_account_info_ready])
775
self.assertEqual(self.ui.backend._signals['AccountInfoError'],
776
[self.ui.on_account_info_error])
778
def test_on_account_info_ready(self):
779
"""Account info is processed when ready."""
780
self.ui.on_account_info_ready(FAKE_ACCOUNT_INFO)
781
self.assert_account_info_correct(FAKE_ACCOUNT_INFO)
783
for widget in (self.ui.name_label, self.ui.type_label,
784
self.ui.email_label):
785
self.assertFalse(widget.active)
787
def test_on_account_info_error(self):
788
"""Account info couldn't be retrieved."""
789
self.ui.on_account_info_error()
790
for widget in (self.ui.name_label, self.ui.type_label,
791
self.ui.email_label):
792
self.assert_warning_correct(widget, self.ui.VALUE_ERROR)
793
self.assertFalse(widget.active)
796
class ContactsTestCase(ControlPanelMixinTestCase):
797
"""The test suite for the contacts panel."""
799
klass = gui.ContactsPanel
800
ui_filename = 'contacts.ui'
802
def test_is_a_vbox(self):
803
"""Inherits from gtk.VBox."""
804
self.assertIsInstance(self.ui, gui.gtk.VBox)
806
def test_inner_widget_is_packed(self):
807
"""The 'itself' vbox is packed into the widget."""
808
self.assertIn(self.ui.itself, self.ui.get_children())
810
def test_is_visible(self):
812
self.assertTrue(self.ui.get_visible())
815
class DevicesTestCase(ControlPanelMixinTestCase):
816
"""The test suite for the devices panel."""
818
klass = gui.DevicesPanel
819
ui_filename = 'devices.ui'
821
def test_is_a_vbox(self):
822
"""Inherits from gtk.VBox."""
823
self.assertIsInstance(self.ui, gui.gtk.VBox)
825
def test_inner_widget_is_packed(self):
826
"""The 'itself' vbox is packed into the widget."""
827
self.assertIn(self.ui.itself, self.ui.get_children())
829
def test_is_visible(self):
831
self.assertTrue(self.ui.get_visible())
834
class ApplicationsTestCase(ControlPanelMixinTestCase):
835
"""The test suite for the applications panel."""
837
klass = gui.ApplicationsPanel
838
ui_filename = 'applications.ui'
840
def test_is_a_vbox(self):
841
"""Inherits from gtk.VBox."""
842
self.assertIsInstance(self.ui, gui.gtk.VBox)
844
def test_inner_widget_is_packed(self):
845
"""The 'itself' vbox is packed into the widget."""
846
self.assertIn(self.ui.itself, self.ui.get_children())
848
def test_is_visible(self):
850
self.assertTrue(self.ui.get_visible())
726
853
class ManagementPanelTestCase(ControlPanelMixinTestCase):
727
854
"""The test suite for the management panel."""
729
856
klass = gui.ManagementPanel
730
857
ui_filename = 'management.ui'
731
fake_account_info = {'type': 'Payed', 'name': 'Test me',
732
'email': 'test.com', 'quota_total': '12345', 'quota_used': '9999'}
734
859
def assert_account_info_correct(self, info):
735
860
"""Check that the displayed account info matches 'info'."""
789
927
"""Account info is requested to the backend."""
790
928
self.assert_backend_called('account_info', ())
930
def test_account_panel_is_packed(self):
931
"""The account panel is packed."""
932
self.assertIsInstance(self.ui.account, gui.AccountPanel)
933
actual = self.ui.notebook.get_nth_page(self.ui.ACCOUNT_PAGE)
934
self.assertTrue(self.ui.account is actual)
936
def test_contacts_panel_is_packed(self):
937
"""The contacts panel is packed."""
938
self.assertIsInstance(self.ui.contacts, gui.ContactsPanel)
939
actual = self.ui.notebook.get_nth_page(self.ui.CONTACTS_PAGE)
940
self.assertTrue(self.ui.contacts is actual)
942
def test_devices_panel_is_packed(self):
943
"""The devices panel is packed."""
944
self.assertIsInstance(self.ui.devices, gui.DevicesPanel)
945
actual = self.ui.notebook.get_nth_page(self.ui.DEVICES_PAGE)
946
self.assertTrue(self.ui.devices is actual)
948
def test_applications_panel_is_packed(self):
949
"""The applications panel is packed."""
950
self.assertIsInstance(self.ui.applications, gui.ApplicationsPanel)
951
actual = self.ui.notebook.get_nth_page(self.ui.APPLICATIONS_PAGE)
952
self.assertTrue(self.ui.applications is actual)
792
954
def test_placeholders_are_loading(self):
793
955
"""Placeholders for labels are a Loading widget."""
794
956
widgets = (self.ui.quota_label, self.ui.status_label)