def test_setup_teardown_content_matches_template(self, hook, monkeypatch):
if list(self.kwargs.keys()) == ['binary_customisation_script']:
pytest.skip('Test only applies to chroot hooks.')
expected_string = '#!/bin/sh\n-- specific test content --'
monkeypatch.setattr(
generate_build_config,
"{}_CONTENT".format(hook.upper()), expected_string)
generate_build_config._write_cloud_config(
open(self.output_file.strpath, 'w'), **self.kwargs)
cloud_config = yaml.load(self.output_file.open())
contents = [base64.b64decode(stanza['content'])
for stanza in cloud_config['write_files']]
expected_bytes = expected_string.encode('utf-8')
assert expected_bytes in contents
assert 1 == len(
[content for content in contents if expected_bytes == content])
评论列表
文章目录