3
from gi.repository import Gtk, GObject
10
CURDIR = os.path.dirname(os.path.abspath(__file__))
13
class TestDistroEndOfLife(unittest.TestCase):
15
# we need to test two cases:
16
# - the current distro is end of life
17
# - the next release (the upgrade target) is end of life
19
def test_distro_current_distro_end_of_life(self):
20
""" this code tests that check-new-release-gtk shows a
21
dist-no-longer-supported dialog when it detects that the
22
running distribution is no longer supported
24
def _nag_dialog_close_helper(checker):
25
# this helper is called to verify that the nag dialog appears
27
dialog = getattr(checker, "no_longer_supported_nag", None)
28
self.assertNotEqual(dialog, None)
29
dialog.response(Gtk.ResponseType.DELETE_EVENT)
30
self.dialog_called = True
33
from check_new_release_gtk import CheckNewReleaseGtk
35
# This may fail in python2, since the Gtk bits needed only exist
36
# in update-manager's python3-only code
39
options.datadir = CURDIR + "/../data"
40
options.test_uri = None
41
checker = CheckNewReleaseGtk(options)
42
meta_release = mock.Mock()
43
# pretend the current distro is no longer supported
44
meta_release.no_longer_supported = subprocess.Popen(
45
["lsb_release", "-c", "-s"],
46
stdout=subprocess.PIPE,
47
universal_newlines=True).communicate()[0].strip()
48
meta_release.flavor_name = "Ubuntu"
49
meta_release.current_dist_version = "0.0"
50
# build new release mock
51
new_dist = mock.Mock()
52
new_dist.name = "zaphod"
53
new_dist.version = "127.0"
54
new_dist.supported = True
55
new_dist.releaseNotesHtmlUri = "http://www.ubuntu.com/html"
56
new_dist.releaseNotesURI = "http://www.ubuntu.com/text"
57
meta_release.upgradable_to = new_dist
58
# schedule a close event in 1 s
59
GObject.timeout_add_seconds(1, _nag_dialog_close_helper, checker)
60
# run the dialog, this will also run a gtk mainloop so that the
62
self.dialog_called = False
63
checker.new_dist_available(meta_release, new_dist)
64
self.assertTrue(self.dialog_called, True)
67
while Gtk.events_pending():
70
if __name__ == "__main__":
72
logging.basicConfig(level=logging.DEBUG)