← Back to team overview

curtin-dev team mailing list archive

Re: [Merge] ~nacc/curtin:nacc/lp1892494 into curtin:master

 

Review: Approve

Otherwise, much better :)

Diff comments:

> diff --git a/tests/unittests/test_apt_source.py b/tests/unittests/test_apt_source.py
> index 6556399..183f72a 100644
> --- a/tests/unittests/test_apt_source.py
> +++ b/tests/unittests/test_apt_source.py
> @@ -215,23 +228,49 @@ class TestAptSourceConfig(CiTestCase):
>                 self.aptlistfile3: {'source': 'deb $MIRROR $RELEASE universe'}}
>          self._apt_src_replace_tri(cfg)
>  
> -    def _apt_src_keyid(self, filename, cfg, keynum):
> +    def _apt_src_keyid_txt(self, filename, cfg):
>          """ _apt_src_keyid
>          Test specification of a source + keyid
>          """
>          params = self._get_default_params()
>  
> -        with mock.patch("curtin.util.subp",
> -                        return_value=('fakekey 1234', '')) as mockobj:
> +        with mock.patch.object(gpg, 'getkeybyid',
> +                               return_value=EXPECTEDKEY_NOVER):
>              self._add_apt_sources(cfg, TARGET, template_params=params,
>                                    aa_repo_match=self.matcher)
>  
> -        # check if it added the right ammount of keys
> -        calls = []
> -        for _ in range(keynum):
> -            calls.append(call(['apt-key', 'add', '-'], data=b'fakekey 1234',
> -                              target=TARGET))
> -        mockobj.assert_has_calls(calls, any_order=True)
> +        for ent in cfg:
> +            key_filename = cfg[ent].get('filename', ent)
> +            self.assertTrue(os.path.isfile(key_filename + '.asc'))
> +            contents = load_tfile(key_filename + '.asc')
> +            self.assertMultiLineEqual(EXPECTEDKEY_NOVER, contents)
> +
> +    def _apt_src_keyid_bin(self, filename, cfg):
> +        """ _apt_src_keyid
> +        Test specification of a source + keyid
> +        """
> +        params = self._get_default_params()
> +
> +        with mock.patch.object(gpg, 'getkeybyid',
> +                               return_value=EXPECTED_BINKEY):
> +            self._add_apt_sources(cfg, TARGET, template_params=params,
> +                                  aa_repo_match=self.matcher)
> +
> +        for ent in cfg:
> +            key_filename = cfg[ent].get('filename', ent)
> +            # without knowing the key, do not know the suffix

This comment is inappropriate now?

> +            self.assertTrue(os.path.isfile(key_filename + '.gpg'))
> +            contents = load_tfile(key_filename + '.gpg', decode=False)
> +            self.assertEqual(EXPECTED_BINKEY, contents)
> +
> +    def _apt_src_keyid(self, filename, cfg, key_type="txt"):
> +        """ _apt_src_keyid
> +        Test specification of a source + keyid
> +        """
> +        if key_type == "txt":
> +            self._apt_src_keyid_txt(filename, cfg)
> +        else:
> +            self._apt_src_keyid_bin(filename, cfg)
>  
>          self.assertTrue(os.path.isfile(filename))
>  


-- 
https://code.launchpad.net/~nacc/curtin/+git/curtin/+merge/393661
Your team curtin developers is subscribed to branch curtin:master.


Follow ups

References