cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #06416
Re: [Merge] ~bitfehler/cloud-init:bitfehler/load_seed into cloud-init:master
Diff comments:
> diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
> index 0e71db8..a31031a 100644
> --- a/tests/unittests/test_util.py
> +++ b/tests/unittests/test_util.py
> @@ -724,21 +724,52 @@ class TestMessageFromString(helpers.TestCase):
> self.assertNotIn('\x00', roundtripped)
>
>
> -class TestReadSeeded(helpers.TestCase):
> +class TestLoadSeed(helpers.TestCase):
> def setUp(self):
> - super(TestReadSeeded, self).setUp()
> + super(TestLoadSeed, self).setUp()
> self.tmp = tempfile.mkdtemp()
> self.addCleanup(shutil.rmtree, self.tmp)
>
> - def test_unicode_not_messed_up(self):
> + def test_simple_seed(self):
Sorry, I didn't see this comment in my email notifications. I added another commit that (hopefully) addresses your comments.
Thanks, Conrad
> ud = b"userdatablob"
> helpers.populate_dir(
> self.tmp, {'meta-data': "key1: val1", 'user-data': ud})
> - sdir = self.tmp + os.path.sep
> - (found_md, found_ud) = util.read_seeded(sdir)
> + seed = util.load_seed(self.tmp, required=['meta-data', 'user-data'])
> + found_md = seed.get('meta-data', {})
> + found_ud = seed.get('user-data', '')
> +
> + self.assertEqual(found_md, {'key1': 'val1'})
> + self.assertEqual(found_ud, ud)
> +
> + def test_ignores_optional(self):
> + ud = b"userdatablob"
> + helpers.populate_dir(
> + self.tmp, {'meta-data': 'key1: val1', 'user-data': ud})
> + seed = util.load_seed(
> + self.tmp, ['meta-data', 'user-data'], ['network-config'])
> + found_md = seed.get('meta-data', {})
> + found_ud = seed.get('user-data', '')
> +
> + self.assertEqual(found_md, {'key1': 'val1'})
> + self.assertEqual(found_ud, ud)
> +
> + def test_loads_optional(self):
> + ud = b"userdatablob"
> + helpers.populate_dir(
> + self.tmp, {
> + 'meta-data': 'key1: val1',
> + 'user-data': ud,
> + 'network-config': 'key: val'
> + })
> + seed = util.load_seed(
> + self.tmp, ['meta-data', 'user-data'], ['network-config'])
> + found_md = seed.get('meta-data', {})
> + found_ud = seed.get('user-data', '')
> + found_nc = seed.get('network-config', {})
>
> self.assertEqual(found_md, {'key1': 'val1'})
> self.assertEqual(found_ud, ud)
> + self.assertEqual(found_nc, {'key': 'val'})
>
>
> class TestSubp(helpers.CiTestCase):
--
https://code.launchpad.net/~bitfehler/cloud-init/+git/cloud-init/+merge/369814
Your team cloud-init commiters is requested to review the proposed merge of ~bitfehler/cloud-init:bitfehler/load_seed into cloud-init:master.
References