← Back to team overview

curtin-dev team mailing list archive

[Merge] ~dbungert/curtin:py-apt-prep into curtin:master

 

Dan Bungert has proposed merging ~dbungert/curtin:py-apt-prep into curtin:master.

Commit message:
tests: update to demonstrate python-apt functional

Prior to pulling in python{,3}-apt functionality, show a simple set of tests
that demonstrate that it is functional in the test environments.

Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/407871
-- 
Your team curtin developers is requested to review the proposed merge of ~dbungert/curtin:py-apt-prep into curtin:master.
diff --git a/tests/unittests/test_tox_environ.py b/tests/unittests/test_tox_environ.py
new file mode 100644
index 0000000..ecc7597
--- /dev/null
+++ b/tests/unittests/test_tox_environ.py
@@ -0,0 +1,17 @@
+# This file is part of curtin. See LICENSE file for copyright and license info.
+
+""" test_tox_environ
+verify that systems running tests contain the environmental packages expected
+"""
+
+from aptsources.sourceslist import SourceEntry
+from .helpers import CiTestCase
+
+
+class TestPythonPackages(CiTestCase):
+    def test_python_apt(self):
+        """test_python_apt - Ensure the python-apt package is available"""
+
+        line = 'deb http://us.archive.ubuntu.com/ubuntu/ hirsute main'
+
+        self.assertEqual(line, str(SourceEntry(line)))
diff --git a/tests/vmtests/test_python_apt.py b/tests/vmtests/test_python_apt.py
new file mode 100644
index 0000000..dacc1b5
--- /dev/null
+++ b/tests/vmtests/test_python_apt.py
@@ -0,0 +1,44 @@
+# This file is part of curtin. See LICENSE file for copyright and license info.
+
+from aptsources.sourceslist import SourceEntry
+
+from . import VMBaseClass
+from .releases import base_vm_classes as relbase
+
+import textwrap
+
+
+class TestPythonApt(VMBaseClass):
+    """TestPythonApt - apt sources manipulation with python{,3}-apt"""
+    test_type = 'config'
+    conf_file = "examples/tests/apt_source_custom.yaml"
+
+    def test_python_apt(self):
+        """test_python_apt - Ensure the python-apt package is available"""
+
+        line = 'deb http://us.archive.ubuntu.com/ubuntu/ hirsute main'
+
+        self.assertEqual(line, str(SourceEntry(line)))
+
+
+class XenialTestPythonApt(relbase.xenial, TestPythonApt):
+    __test__ = True
+
+
+class BionicTestPythonApt(relbase.bionic, TestPythonApt):
+    __test__ = True
+
+
+class FocalTestPythonApt(relbase.focal, TestPythonApt):
+    __test__ = True
+
+
+class HirsuteTestPythonApt(relbase.hirsute, TestPythonApt):
+    __test__ = True
+
+
+class ImpishTestPythonApt(relbase.impish, TestPythonApt):
+    __test__ = True
+
+
+# vi: ts=4 expandtab syntax=python
diff --git a/tools/noproxy b/tools/noproxy
deleted file mode 100644
index 911cc7a..0000000
--- a/tools/noproxy
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-# This file is part of curtin. See LICENSE file for copyright and license info.
-
-# clean http_proxy variables from environment as they make httpretty
-# fail, but may be in the environment for reasons such as pip install
-import os
-import sys
-
-for k in ('http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY'):
-    if k in os.environ:
-        del os.environ[k]
-
-os.execvpe(sys.argv[1], sys.argv[1:], os.environ)
-
-# vi: ts=4 expandtab syntax=python
diff --git a/tools/run-pep8 b/tools/run-pep8
index 227129c..5c85ad0 100755
--- a/tools/run-pep8
+++ b/tools/run-pep8
@@ -8,7 +8,6 @@ pycheck_dirs=(
     "tools/report_webhook_logger"
     "tools/block-discover-to-config"
     "tools/curtin-log-print"
-    "tools/noproxy"
     "tools/schema-validate-storage"
     "tools/ssh-keys-list"
     "tools/vmtest-filter"
diff --git a/tools/vmtest-system-setup b/tools/vmtest-system-setup
index b9185db..30a8246 100755
--- a/tools/vmtest-system-setup
+++ b/tools/vmtest-system-setup
@@ -11,6 +11,13 @@ case "$(uname -m)" in
   ppc*) qemu="qemu-system-ppc";;
   s390x) qemu="qemu-system-s390x";;
 esac
+
+case "$rel" in
+    "t"|"u"|"x"*) python_apt="python-apt";;
+    "b"|"f"*) python_apt="python-apt python3-apt";;
+    *) python_apt="python3-apt";;
+esac
+
 DEPS=(
   cloud-image-utils
   make
@@ -20,6 +27,7 @@ DEPS=(
   python3-nose
   python3-simplestreams
   python3-yaml
+  $python_apt
   ovmf
   simplestreams
   $qemu
diff --git a/tox.ini b/tox.ini
index 04b43b6..6b293ae 100644
--- a/tox.ini
+++ b/tox.ini
@@ -22,15 +22,17 @@ setenv = VIRTUAL_ENV={envdir}
     LC_ALL = en_US.utf-8
 deps = -r{toxinidir}/test-requirements.txt
     -r{toxinidir}/requirements.txt
-commands = {envpython} {toxinidir}/tools/noproxy nosetests \
+commands = {envpython} -m nose \
     {posargs:--with-coverage --cover-erase --cover-branches \
        --cover-package=curtin --cover-inclusive tests/unittests}
 
 [testenv:py3]
 basepython = python3
+sitepackages = true
 
 [testenv:py27]
 basepython = python2.7
+sitepackages = true
 # https://github.com/pypa/setuptools/issues/1963
 deps = {[testenv]deps}
     setuptools<45
@@ -107,13 +109,14 @@ deps = {[testenv:trusty]deps}
     setuptools<45
 
 basepython = python2.7
-commands = {envpython} {toxinidir}/tools/noproxy nosetests \
+sitepackages = true
+commands = {envpython} -m nose \
     {posargs:tests/unittests}
 
 [testenv:trusty-py3]
 deps = {[testenv:trusty]deps}
 basepython = python3
-commands = {envpython} {toxinidir}/tools/noproxy nosetests \
+commands = {envpython} -m nose \
     {posargs:tests/unittests}
 
 [testenv:xenial]
@@ -127,13 +130,14 @@ deps =
 basepython = python27
 deps = {[testenv:xenial]deps}
    {[testenv:py27]deps}
-commands = {envpython} {toxinidir}/tools/noproxy nosetests \
+commands = {envpython} -m nose \
     {posargs:tests/unittests}
 
 [testenv:xenial-py3]
 basepython = python3
+sitepackages = true
 deps = {[testenv:xenial]deps}
-commands = {envpython} {toxinidir}/tools/noproxy nosetests \
+commands = {envpython} -m nose \
     {posargs:tests/unittests}
 
 [testenv:tip-pycodestyle]

Follow ups