2565.1.1
by Michael Terry
Allow user to continue if an update error occurs |
1 |
#!/usr/bin/python3
|
2 |
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
|
|
3 |
||
4 |
import logging |
|
5 |
import sys |
|
6 |
import unittest |
|
7 |
from gettext import gettext as _ |
|
8 |
from mock import patch |
|
9 |
||
10 |
from UpdateManager.Dialogs import NoUpdatesDialog |
|
11 |
from UpdateManager.UpdateManager import UpdateManager |
|
12 |
from UpdateManager.UpdatesAvailable import UpdatesAvailable |
|
13 |
||
14 |
import os |
|
15 |
CURDIR = os.path.dirname(os.path.abspath(__file__)) |
|
16 |
||
17 |
||
18 |
class TestUpdateManagerError(unittest.TestCase): |
|
19 |
||
20 |
def setUp(self): |
|
21 |
patcher = patch('UpdateManager.UpdateManager.UpdateManager') |
|
22 |
self.addCleanup(patcher.stop) |
|
23 |
self.manager = patcher.start() |
|
24 |
self.manager._check_meta_release.return_value = False |
|
2727.1.1
by Brian Murray
Include HWE support tools and information. (LP: #1498059) |
25 |
self.manager.hwe_replacement_packages = None |
2565.1.1
by Michael Terry
Allow user to continue if an update error occurs |
26 |
self.manager.datadir = os.path.join(CURDIR, '..', 'data') |
27 |
||
28 |
def test_error_no_updates(self): |
|
29 |
p = UpdateManager._make_available_pane(self.manager, 0, |
|
30 |
error_occurred=True) |
|
31 |
self.assertIsInstance(p, NoUpdatesDialog) |
|
2633.1.1
by Dylan McCall
Fixed failing tests caused by changes to UpdateManager.UpdateProgress (since merged into install backends), and to label markup. |
32 |
header_markup = "<span size='larger' weight='bold'>%s</span>" |
2636
by Martin Pitt
tests/test_update_error.py: Fix test regression from the above. |
33 |
self.assertEqual( |
34 |
p.label_header.get_label(), |
|
35 |
header_markup % _("No software updates are available.")) |
|
2565.1.1
by Michael Terry
Allow user to continue if an update error occurs |
36 |
|
37 |
def test_error_with_updates(self): |
|
38 |
p = UpdateManager._make_available_pane(self.manager, 1, |
|
39 |
error_occurred=True) |
|
40 |
self.assertIsInstance(p, UpdatesAvailable) |
|
41 |
self.assertEqual(p.custom_desc, |
|
42 |
_("Some software couldn’t be checked for updates.")) |
|
43 |
||
44 |
||
45 |
if __name__ == '__main__': |
|
46 |
if len(sys.argv) > 1 and sys.argv[1] == "-v": |
|
47 |
logging.basicConfig(level=logging.DEBUG) |
|
48 |
unittest.main() |