launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14532
[Merge] lp:~allenap/maas/one-root-to-rule-them-all into lp:maas
Gavin Panella has proposed merging lp:~allenap/maas/one-root-to-rule-them-all into lp:maas.
Commit message:
Record the root of the tree in maastesting.root, and use it everywhere.
Previously this was being calculated in several different places in different ways.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~allenap/maas/one-root-to-rule-them-all/+merge/136130
Salvaged from rejected merge https://code.launchpad.net/~allenap/maas/keep-rendered-man-pages-test/+merge/135878.
--
https://code.launchpad.net/~allenap/maas/one-root-to-rule-them-all/+merge/136130
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/one-root-to-rule-them-all into lp:maas.
=== modified file 'src/maascli/tests/test_integration.py'
--- src/maascli/tests/test_integration.py 2012-11-19 16:12:25 +0000
+++ src/maascli/tests/test_integration.py 2012-11-26 10:28:00 +0000
@@ -19,17 +19,12 @@
STDOUT,
)
+from maastesting import root
from maastesting.testcase import TestCase
-def locate_dev_root():
- """Root of development tree that this test is in."""
- return os.path.join(
- os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)
-
-
def locate_maascli():
- return os.path.join(locate_dev_root(), 'bin', 'maascli')
+ return os.path.join(root, 'bin', 'maascli')
class TestMAASCli(TestCase):
=== modified file 'src/maastesting/__init__.py'
--- src/maastesting/__init__.py 2012-05-17 16:09:33 +0000
+++ src/maastesting/__init__.py 2012-11-26 10:28:00 +0000
@@ -0,0 +1,26 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Testing infrastructure for MAAS."""
+
+from __future__ import (
+ absolute_import,
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+__all__ = [
+ "root",
+ ]
+
+from os.path import (
+ abspath,
+ dirname,
+ join,
+ pardir,
+ )
+
+
+# The root of the source tree.
+root = abspath(join(dirname(__file__), pardir, pardir))
=== modified file 'src/provisioningserver/dhcp/tests/test_writer.py'
--- src/provisioningserver/dhcp/tests/test_writer.py 2012-11-22 03:18:35 +0000
+++ src/provisioningserver/dhcp/tests/test_writer.py 2012-11-26 10:28:00 +0000
@@ -21,9 +21,9 @@
)
import sys
+from maastesting import root
from maastesting.matchers import ContainsAll
from maastesting.testcase import TestCase
-import provisioningserver
from provisioningserver.dhcp import writer
from testtools.matchers import MatchesStructure
@@ -43,10 +43,7 @@
)
def test_script_executable(self):
- dev_root = os.path.join(
- os.path.dirname(provisioningserver.__file__),
- os.pardir, os.pardir)
- script = ["%s/bin/maas-provision" % dev_root, "generate-dhcp-config"]
+ script = ["%s/bin/maas-provision" % root, "generate-dhcp-config"]
script.extend(self.test_args)
cmd = Popen(
script, stdout=PIPE, env=dict(PYTHONPATH=":".join(sys.path)))
=== modified file 'src/provisioningserver/tests/test_config.py'
--- src/provisioningserver/tests/test_config.py 2012-08-30 11:19:16 +0000
+++ src/provisioningserver/tests/test_config.py 2012-11-26 10:28:00 +0000
@@ -20,6 +20,7 @@
from fixtures import EnvironmentVariableFixture
import formencode
+from maastesting import root
from maastesting.factory import factory
from maastesting.testcase import TestCase
from provisioningserver.config import Config
@@ -179,9 +180,7 @@
def test_load_example(self):
# The example configuration is designed for development.
- filename = os.path.join(
- os.path.dirname(__file__), os.pardir,
- os.pardir, os.pardir, "etc", "pserv.yaml")
+ filename = os.path.join(root, "etc", "pserv.yaml")
self.assertEqual(
self.default_development_config,
Config.load(filename))
=== modified file 'src/provisioningserver/tests/test_customize_config.py'
--- src/provisioningserver/tests/test_customize_config.py 2012-09-10 04:46:41 +0000
+++ src/provisioningserver/tests/test_customize_config.py 2012-11-26 10:28:00 +0000
@@ -22,20 +22,13 @@
import sys
from textwrap import dedent
+from maastesting import root
from maastesting.factory import factory
from maastesting.testcase import TestCase
-import provisioningserver
from provisioningserver import customize_config
from provisioningserver.utils import maas_custom_config_markers
-def locate_dev_root():
- """Return root of development source tree."""
- return os.path.join(
- os.path.dirname(provisioningserver.__file__),
- os.pardir, os.pardir)
-
-
class TestCustomizeConfig(TestCase):
def run_command(self, input_file, stdin):
@@ -49,7 +42,7 @@
def test_runs_as_script(self):
original_text = factory.getRandomString()
original_file = self.make_file(original_text)
- script = "%s/bin/maas-provision" % locate_dev_root()
+ script = os.path.join(root, "bin", "maas-provision")
command = Popen(
[script, "customize-config", original_file],
stdin=PIPE, stdout=PIPE,
=== modified file 'src/provisioningserver/tests/test_maas_import_pxe_files.py'
--- src/provisioningserver/tests/test_maas_import_pxe_files.py 2012-11-12 14:32:26 +0000
+++ src/provisioningserver/tests/test_maas_import_pxe_files.py 2012-11-26 10:28:00 +0000
@@ -15,6 +15,7 @@
import os
from subprocess import check_call
+from maastesting import root
from maastesting.factory import factory
from maastesting.testcase import TestCase
from maastesting.utils import (
@@ -146,10 +147,7 @@
"""
# TODO: Use path.py <http://pypi.python.org/pypi/path.py> instead, or
# something similar; this is tedious stuff.
- here = os.path.dirname(__file__)
- root = os.path.join(here, os.pardir, os.pardir, os.pardir)
script = os.path.join(root, "scripts", "maas-import-pxe-files")
-
path = [os.path.join(root, "bin"), os.path.join(root, "scripts")]
path.extend(os.environ.get("PATH", "").split(os.pathsep))
env = {
=== modified file 'src/provisioningserver/tests/test_utils.py'
--- src/provisioningserver/tests/test_utils.py 2012-11-08 06:34:48 +0000
+++ src/provisioningserver/tests/test_utils.py 2012-11-26 10:28:00 +0000
@@ -31,6 +31,7 @@
import time
import types
+from maastesting import root
from maastesting.factory import factory
from maastesting.fakemethod import FakeMethod
from maastesting.testcase import TestCase
@@ -734,11 +735,8 @@
self.assertFalse(args.no_overwrite)
def test_script_executable(self):
- dev_root = os.path.join(
- os.path.dirname(provisioningserver.__file__),
- os.pardir, os.pardir)
content = factory.getRandomString()
- script = ["%s/bin/maas-provision" % dev_root, 'atomic-write']
+ script = ["%s/bin/maas-provision" % root, 'atomic-write']
target_file = self.make_file()
script.extend(('--filename', target_file, '--mode', '615'))
cmd = Popen(