[Merge] lp:~juliank/update-notifier/esm into lp:update-notifier

Patricia Gaughen patricia.gaughen at canonical.com
Fri Mar 29 17:37:56 UTC 2019



Diff comments:

> 
> === added symlink 'tests/apt_check.py'
> === target is u'../data/apt_check.py'
> === added file 'tests/test_motd.py'
> --- tests/test_motd.py	1970-01-01 00:00:00 +0000
> +++ tests/test_motd.py	2019-03-29 16:07:11 +0000
> @@ -0,0 +1,134 @@
> +#!/usr/bin/python3
> +# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
> +
> +import apt_check
> +import io
> +import os
> +import subprocess
> +import unittest
> +import textwrap
> +
> +
> +def get_message(*args, **kwds):
> +    with io.StringIO() as stream:
> +        apt_check.write_human_readable_summary(stream, *args, **kwds)
> +        return stream.getvalue()
> +
> +
> +class TestMotd(unittest.TestCase):
> +    """ ensure that the tree is pep8 clean """
> +
> +    def test_esm_disabled_upto_date_esm_avail(self):
> +        self.assertEqual(
> +            get_message(upgrades=0, security_updates=0,
> +                        esm_updates=0, have_esm=False,
> +                        disabled_esm_updates=23),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is not enabled.
> +
> +                0 updates can be installed immediately.
> +
> +                Enable ESM to get 23 additional security updates.
> +                See 'ua enable esm' or https://ubuntu.com/esm
> +                """).lstrip())
> +
> +    def test_esm_disabled_security_esm_avail(self):
> +        self.assertEqual(
> +            get_message(upgrades=15, security_updates=7,
> +                        esm_updates=0, have_esm=False,
> +                        disabled_esm_updates=23),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is not enabled.
> +
> +                15 updates can be installed immediately.
> +                7 of these updates are security updates.
> +
> +                Enable ESM to get 23 additional security updates.
> +                See 'ua enable esm' or https://ubuntu.com/esm
> +                """).lstrip())
> +
> +    def test_esm_disabled_security_no_esm_avail(self):
> +        self.assertEqual(
> +            get_message(upgrades=15, security_updates=7,
> +                        esm_updates=0, have_esm=False,
> +                        disabled_esm_updates=0),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is not enabled.
> +
> +                15 updates can be installed immediately.
> +                7 of these updates are security updates.
> +                """).lstrip())
> +
> +    def test_esm_disabled_nosecurity(self):
> +        self.assertEqual(
> +            get_message(upgrades=15, security_updates=0,
> +                        esm_updates=0, have_esm=False,
> +                        disabled_esm_updates=0),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is not enabled.
> +
> +                15 updates can be installed immediately.
> +                0 of these updates are security updates.
> +                """).lstrip())
> +
> +    def test_esm_disabled_noupdates(self):
> +        self.assertEqual(
> +            get_message(upgrades=0, security_updates=0,
> +                        esm_updates=0, have_esm=False,
> +                        disabled_esm_updates=0),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is not enabled.
> +
> +                All updates are applied.
> +                """).lstrip())
> +
> +    def test_esm_enabled_nosecurity(self):
> +        self.assertEqual(
> +            get_message(upgrades=35, security_updates=0,
> +                        esm_updates=13, have_esm=True,
> +                        disabled_esm_updates=0),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is enabled.
> +
> +                35 updates can be installed immediately.
> +                13 of these updates are provided through ESM.
> +                0 of these updates are security updates.
> +                """).lstrip())
> +
> +    def test_esm_enabled_somesecurity(self):
> +        self.assertEqual(
> +            get_message(upgrades=47, security_updates=7,
> +                        esm_updates=13, have_esm=True,
> +                        disabled_esm_updates=0),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is enabled.
> +
> +                47 updates can be installed immediately.
> +                13 of these updates are provided through ESM.
> +                7 of these updates are security updates.
> +                """).lstrip())
> +
> +    def test_esm_enabled_noupdates(self):
> +        self.assertEqual(
> +            get_message(upgrades=0, security_updates=0,
> +                        esm_updates=0, have_esm=True,
> +                        disabled_esm_updates=0),
> +            textwrap.dedent(
> +                """
> +                Extended Security Maintenance (ESM) is enabled.
> +
> +                All updates are applied.
> +                """).lstrip())

+1 to Josh's suggestion.

> +
> +
> +if __name__ == "__main__":
> +    import logging
> +    logging.basicConfig(level=logging.DEBUG)
> +    unittest.main()


-- 
https://code.launchpad.net/~juliank/update-notifier/esm/+merge/365288
Your team Ubuntu Core Development Team is requested to review the proposed merge of lp:~juliank/update-notifier/esm into lp:update-notifier.



More information about the Ubuntu-reviews mailing list