def test_plugins(monkeypatch, config_files, capsys, command, command_args, has_templates,
has_profiles, has_playbooks, has_postprocessing_commands):
def fake_lxc_config_command(*popenargs, **kwargs):
if 'images.compression_algorithm' in popenargs[0]:
return subprocess.CompletedProcess("fakerun", 0, '')
else:
return subprocess.run(*popenargs, **kwargs)
monkeypatch.setattr(mockablerun, 'run_mockable', fake_lxc_config_command)
parser = edi._setup_command_line_interface()
command_args.append(config_files)
cli_args = parser.parse_args(command_args)
command().run_cli(cli_args)
out, err = capsys.readouterr()
assert err == ''
result = yaml.load(out)
if has_templates:
assert result.get('lxc_templates')
else:
assert not result.get('lxc_templates')
if has_profiles:
assert result.get('lxc_profiles')
else:
assert not result.get('lxc_profiles')
if has_playbooks:
assert len(result.get('playbooks')) == 3
base_system = result.get('playbooks')[0].get('10_base_system')
assert 'plugins/playbooks/foo.yml' in base_system.get('path')
assert base_system.get('dictionary').get('kernel_package') == 'linux-image-amd64-rt'
assert base_system.get('dictionary').get('edi_config_directory') == os.path.dirname(config_files)
else:
assert not result.get('playbooks')
if has_postprocessing_commands:
assert result.get('postprocessing_commands')
else:
assert not result.get('postprocessing_commands')
评论列表
文章目录