Ejemplo n.º 1
0
def test_load_hosts_should_load_single_hosts_section(add_root):
    e = Environment('name')
    config = Config(None)
    config.config.read_string("""
[hosts]
foo = bar
    """)
    e.load_hosts(config)
    add_root.assert_called_once_with('bar', 'foo', [], False)
Ejemplo n.º 2
0
def test_load_hosts_should_load_single_hosts_section(add_root):
    e = Environment("name")
    config = Config(None)
    config.config.read_string("""
[hosts]
foo = bar
    """)
    e.load_hosts(config)
    add_root.assert_called_once_with("bar", e.hosts["foo"], [], False)
Ejemplo n.º 3
0
def test_host_data_is_passed_to_host_object():
    e = Environment('name')
    config = Config(None)
    config.config.read_string("""
[host:foo]
components = bar
data-alias = baz
    """)
    e.load_hosts(config)
    assert 'baz' == e.hosts['foo'].data['alias']
Ejemplo n.º 4
0
def test_load_hosts_single_should_use_env_platform(add_root):
    e = Environment('name')
    e.platform = mock.sentinel.platform
    config = Config(None)
    config.config.read_string("""
[hosts]
foo = bar
    """)
    e.load_hosts(config)
    assert e.hosts['foo'].platform == mock.sentinel.platform
Ejemplo n.º 5
0
def test_host_data_is_passed_to_host_object():
    e = Environment("name")
    config = Config(None)
    config.config.read_string("""
[host:foo]
components = bar
data-alias = baz
    """)
    e.load_hosts(config)
    assert "baz" == e.hosts["foo"].data["alias"]
Ejemplo n.º 6
0
def test_load_hosts_should_load_multi_hosts_section(add_root):
    pass
    e = Environment("name")
    config = Config(None)
    config.config.read_string("""
[host:foo]
components = bar
    """)
    e.load_hosts(config)
    add_root.assert_called_once_with("bar", e.hosts['foo'], [], False)
Ejemplo n.º 7
0
def test_load_hosts_multi_should_use_env_platform(add_root):
    e = Environment('name')
    e.platform = mock.sentinel.platform
    config = Config(None)
    config.config.read_string("""
[host:foo]
components = bar
ignore = True
    """)
    e.load_hosts(config)
    assert e.hosts['foo'].platform == mock.sentinel.platform
Ejemplo n.º 8
0
def test_load_hosts_multi_should_use_ignore_flag(add_root):
    pass
    e = Environment('name')
    config = Config(None)
    config.config.read_string("""
[host:foo]
components = bar
ignore = True
    """)
    e.load_hosts(config)
    assert e.hosts['foo'].ignore
Ejemplo n.º 9
0
def test_load_hosts_multi_should_use_host_platform_if_given(add_root):
    pass
    e = Environment('name')
    e.platform = mock.sentinel.platform
    config = Config(None)
    config.config.read_string("""
[host:foo]
components = bar
platform = specific
    """)
    e.load_hosts(config)
    assert e.hosts['foo'].platform == 'specific'
Ejemplo n.º 10
0
def test_load_hosts_should_break_on_duplicate_definition(add_root):
    e = Environment('name')
    config = Config(None)
    config.config.read_string("""
[hosts]
foo = bar
[host:foo]
components = bar
    """)
    e.load_hosts(config)
    assert e.exceptions
    assert 'foo' == e.exceptions[0].hostname
Ejemplo n.º 11
0
def test_load_hosts_should_merge_single_and_multi_definition(add_root):
    e = Environment('name')
    config = Config(None)
    config.config.read_string("""
[hosts]
foo = bar
[host:baz]
components = bar
    """)
    e.load_hosts(config)
    assert [mock.call('bar', 'foo', [], False),
            mock.call('bar', 'baz', [], False)] == \
        add_root.call_args_list
Ejemplo n.º 12
0
def test_load_hosts_should_merge_single_and_multi_definition(add_root):
    e = Environment("name")
    config = Config(None)
    config.config.read_string("""
[hosts]
foo = bar
[host:baz]
components = bar
    """)
    e.load_hosts(config)
    assert [
        mock.call("bar", e.hosts["foo"], [], False),
        mock.call("bar", e.hosts["baz"], [], False),
    ] == add_root.call_args_list