← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/maas/keep-rendered-man-pages-test into lp:maas

 

Gavin Panella has proposed merging lp:~allenap/maas/keep-rendered-man-pages-test into lp:maas.

Commit message:
Ensure that the generated man pages are up-to-date.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1081957 in MAAS: "Not generating man pages during build"
  https://bugs.launchpad.net/maas/+bug/1081957

For more details, see:
https://code.launchpad.net/~allenap/maas/keep-rendered-man-pages-test/+merge/135878
-- 
https://code.launchpad.net/~allenap/maas/keep-rendered-man-pages-test/+merge/135878
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/keep-rendered-man-pages-test into lp:maas.
=== added directory 'src/maastesting/meta'
=== added file 'src/maastesting/meta/__init__.py'
--- src/maastesting/meta/__init__.py	1970-01-01 00:00:00 +0000
+++ src/maastesting/meta/__init__.py	2012-11-23 12:10:50 +0000
@@ -0,0 +1,4 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Code that relates to the MAAS source tree as a whole."""

=== added directory 'src/maastesting/meta/tests'
=== added file 'src/maastesting/meta/tests/__init__.py'
--- src/maastesting/meta/tests/__init__.py	1970-01-01 00:00:00 +0000
+++ src/maastesting/meta/tests/__init__.py	2012-11-23 12:10:50 +0000
@@ -0,0 +1,25 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tests for the MAAS source tree as a whole."""
+
+from __future__ import (
+    absolute_import,
+    print_function,
+    unicode_literals,
+    )
+
+__metaclass__ = type
+__all__ = [
+    "root",
+    ]
+
+from os.path import (
+    abspath,
+    dirname,
+    join,
+    pardir,
+    )
+
+
+root = abspath(join(dirname(__file__), pardir, pardir, pardir, pardir))

=== added file 'src/maastesting/meta/tests/test_man.py'
--- src/maastesting/meta/tests/test_man.py	1970-01-01 00:00:00 +0000
+++ src/maastesting/meta/tests/test_man.py	2012-11-23 12:10:50 +0000
@@ -0,0 +1,54 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tests of MAAS's man pages."""
+
+from __future__ import (
+    absolute_import,
+    print_function,
+    unicode_literals,
+    )
+
+__metaclass__ = type
+__all__ = []
+
+from glob import iglob
+from os.path import (
+    basename,
+    getmtime,
+    join,
+    relpath,
+    splitext,
+    )
+
+from maastesting.testcase import TestCase
+from testtools.matchers import (
+    AfterPreprocessing,
+    Equals,
+    FileExists,
+    GreaterThan,
+    MatchesAny,
+    )
+
+from . import root
+
+
+class TestFreshness(TestCase):
+    """Ensure that the man pages are up-to-date."""
+
+    scenarios = [
+        (relpath(filename, root), {"source": filename})
+        for filename in iglob(join(root, "docs", "man", "*.rst"))
+        ]
+
+    @property
+    def target(self):
+        name, ext = splitext(self.source)
+        return join(root, "man", basename(name))
+
+    def test_generated_and_up_to_date(self):
+        self.assertThat(self.target, FileExists())
+        ref = getmtime(self.source)
+        is_up_to_date = MatchesAny(GreaterThan(ref), Equals(ref))
+        file_is_up_to_date = AfterPreprocessing(getmtime, is_up_to_date)
+        self.assertThat(self.target, file_is_up_to_date)