← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~chad.smith/cloud-init:fix/bug-1757176-get-host-name-metadata-only into cloud-init:master

 

Looks good, one comment on the docstring for the testcase

Diff comments:

> diff --git a/cloudinit/sources/tests/test_init.py b/cloudinit/sources/tests/test_init.py
> index 5065083..8e800e6 100644
> --- a/cloudinit/sources/tests/test_init.py
> +++ b/cloudinit/sources/tests/test_init.py
> @@ -268,3 +270,27 @@ class TestDataSource(CiTestCase):
>              "WARNING: Error persisting instance-data.json: 'utf8' codec can't"
>              " decode byte 0xaa in position 2: invalid start byte",
>              self.logs.getvalue())
> +
> +    def test_get_hostname_subclass_support(self):
> +        """Validate get_hostname signature on all subclasses of DataSource."""

Validate get_hostname signature matches on all subclasses of DataSource ?

> +        # Use inspect.getfullargspec when we drop py2.6 and py2.7
> +        get_args_func = inspect.getargs  # pylint: disable=W1505
> +        base_args = get_args_func(DataSource.get_hostname)
> +        # Import all DataSource subclasses so we can inspect them.
> +        modules = util.find_modules(os.path.dirname(os.path.dirname(__file__)))
> +        for loc, name in modules.items():
> +            mod_locs, _ = importer.find_module(name, ['cloudinit.sources'], [])
> +            if mod_locs:
> +                importer.import_module(mod_locs[0])
> +        for child in DataSource.__subclasses__():
> +            if 'Test' in child.dsname:
> +                continue
> +            self.assertEqual(
> +                base_args, get_args_func(child.get_hostname),
> +                '%s does not implement DataSource.get_hostname params'
> +                % child)
> +            for grandchild in child.__subclasses__():
> +                self.assertEqual(
> +                    base_args, get_args_func(grandchild.get_hostname),
> +                    '%s does not implement DataSource.get_hostname params'
> +                    % grandchild)


-- 
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/341757
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:fix/bug-1757176-get-host-name-metadata-only into cloud-init:master.