示例#1
0
def test_show():
    result_show = {
        'key': 'value'
    }
    c = DummyConnectionControl(result_show=result_show)
    name = 'MyHome'
    assert c.show(name) == result_show
示例#2
0
def test_modify():
    c = DummyConnectionControl()
    options = {
        'key': 'value'
    }
    name = 'MyHome'
    c.modify(name, options)
    assert c.modify_args[0] == (name, options)
示例#3
0
def test_add():
    c = DummyConnectionControl()
    conn_type = 'ethernet'
    options = {'key': 'value'}
    ifname = 'eth0'
    name = 'MyHome'
    autoconnect = True
    c.add(conn_type, options, ifname, name, autoconnect)
    assert c.add_args[0] == (conn_type, options, ifname, name, autoconnect)
示例#4
0
def test_down():
    c = DummyConnectionControl()
    name = 'MyHome'
    c.down(name)
    assert c.down_args[0] == (name, None)

    c.down(name, wait=10)
    assert c.down_args[1] == (name, 10)
示例#5
0
def test_show_when_no_arguments_are_passed():
    c = DummyConnectionControl()
    with pytest.raises(ValueError):
        c.show('MyHome')
示例#6
0
def test_show_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.show('MyHome')
示例#7
0
def test_down_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.down('ethernet')
示例#8
0
def test_down():
    c = DummyConnectionControl()
    name = 'MyHome'
    c.down(name)
    assert c.down_args[0] == name
示例#9
0
def test_up():
    c = DummyConnectionControl()
    name = 'MyHome'
    c.up(name)
    assert c.up_args[0] == name
示例#10
0
def test_call():
    result_call = [Connection('a', 'b', 'ethernet', 'eth0')]
    c = DummyConnectionControl(result_call)
    assert c() == result_call
示例#11
0
def test_delete():
    c = DummyConnectionControl()
    name = 'MyHome'
    c.delete(name)
    assert c.delete_args[0] == name
示例#12
0
def test_modify_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.modify('ethernet', {'key':'value'})
示例#13
0
def test_call_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c()
示例#14
0
def test_reload_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.reload()
示例#15
0
def test_reload():
    c = DummyConnectionControl()
    c.reload()
    assert c.called_reload == 1