~raharper/curtin/new-bionic-upstream-snapshot-v1

« back to all changes in this revision

Viewing changes to tests/unittests/test_public.py

  • Committer: Scott Moser
  • Date: 2017-08-03 19:51:16 UTC
  • mfrom: (1.1.50)
  • Revision ID: smoser@ubuntu.com-20170803195116-0xc6onji18peerm5
* New upstream snapshot.
  - tests: Add CiTestCase common parent for all curtin tests.
  - vmtests: Remove force flag for centos curthooks
  - tools/jenkins-runner: improve tgtd cleanup logic
  - tests: Drop EOL Wily Vivid and Yakkety tests.
  - Disable yum plugins when installing packages, update ca-certs for https
  - Rename centos_network_curthooks -> centos_apply_network_config.
  - tests: in centos_defaults use write_files for grub serial.
  - write_files: write files after extract, change write_files signature.
  - pass network configuration through to target for ubuntu and centos
  - tests: disable yakkety tests.
  - tools/launch: automatically pass on proxy settings to curtin
  - Add top level 'proxy' to config, deprecate top level http_proxy.
  - tools/curtainer: fix to enable deb-src for -proposed.
  - Use unshare to put chroot commands in own pid namespace.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from curtin import block
 
3
from curtin import config
 
4
from curtin import futil
 
5
from curtin import util
 
6
 
 
7
from curtin.commands import curthooks
 
8
from .helpers import CiTestCase
 
9
 
 
10
 
 
11
class TestPublicAPI(CiTestCase):
 
12
    """Test entry points known to be used externally.
 
13
 
 
14
    Curtin's only known external library user is the curthooks
 
15
    that are present in the MAAS images.  This will test for presense
 
16
    of the modules and entry points that are used there.
 
17
 
 
18
    This unit test is present to just test entry points.  Function
 
19
    behavior should be present elsewhere."""
 
20
 
 
21
    def assert_has_callables(self, module, expected):
 
22
        self.assertEqual(expected, _module_has(module, expected, callable))
 
23
 
 
24
    def test_block(self):
 
25
        """Verify expected attributes in curtin.block."""
 
26
        self.assert_has_callables(
 
27
            block,
 
28
            ['get_devices_for_mp', 'get_blockdev_for_partition', '_lsblock'])
 
29
 
 
30
    def test_config(self):
 
31
        """Verify exported attributes in curtin.config."""
 
32
        self.assert_has_callables(config, ['load_config'])
 
33
 
 
34
    def test_util(self):
 
35
        """Verify exported attributes in curtin.util."""
 
36
        self.assert_has_callables(
 
37
            util, ['RunInChroot', 'load_command_environment'])
 
38
 
 
39
    def test_centos_apply_network_config(self):
 
40
        """MAAS images use centos_apply_network_config from cmd.curthooks."""
 
41
        self.assert_has_callables(curthooks, ['centos_apply_network_config'])
 
42
 
 
43
    def test_futil(self):
 
44
        """Verify exported attributes in curtin.futil."""
 
45
        self.assert_has_callables(futil, ['write_files'])
 
46
 
 
47
 
 
48
def _module_has(module, names, nfilter=None):
 
49
    found = [(name, getattr(module, name))
 
50
             for name in names if hasattr(module, name)]
 
51
    if nfilter is not None:
 
52
        found = [(name, attr) for name, attr in found if nfilter(attr)]
 
53
 
 
54
    return [name for name, _ in found]