Exemplo n.º 1
0
def test_cloud_cfg_no_network():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG_NO_NETWORK.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    with pytest.raises(SkipComponent) as e:
        cloud_cfg(broker)
    assert 'No network section in yaml' in str(e)
Exemplo n.º 2
0
def test_cloud_cfg_bad():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG_BAD.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    with pytest.raises(SkipComponent) as e:
        cloud_cfg(broker)
    assert 'Unexpected exception' in str(e)
Exemplo n.º 3
0
def test_cloud_cfg_no_filter():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG.format(value=1).splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    with pytest.raises(SkipComponent) as e:
        cloud_cfg(broker)
    assert 'SkipComponent' in str(e)
Exemplo n.º 4
0
def test_cloud_cfg():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    result = cloud_cfg(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=json.dumps(CLOUD_CFG_JSON), relative_path=RELATIVE_PATH)
    assert result.content == expected.content
    assert result.relative_path == expected.relative_path
Exemplo n.º 5
0
def test_cloud_cfg(ssh_deletekeys):
    cloud_cfg_string = CLOUD_CFG.format(value=ssh_deletekeys)
    cloud_cfg_dict = CLOUD_CFG_JSON.copy()
    cloud_cfg_dict["ssh_deletekeys"] = ssh_deletekeys

    cloud_init_file = Mock()
    cloud_init_file.content = cloud_cfg_string.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    result = cloud_cfg(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=json.dumps(cloud_cfg_dict),
                                  relative_path=RELATIVE_PATH)
    assert result.content == expected.content
    assert result.relative_path == expected.relative_path