Example #1
0
def test_show():
    result_show = {
        'key': 'value'
    }
    c = DummyConnectionControl(result_show=result_show)
    name = 'MyHome'
    assert c.show(name) == result_show
Example #2
0
def test_modify():
    c = DummyConnectionControl()
    options = {
        'key': 'value'
    }
    name = 'MyHome'
    c.modify(name, options)
    assert c.modify_args[0] == (name, options)
Example #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)
Example #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)
Example #5
0
def test_show_when_no_arguments_are_passed():
    c = DummyConnectionControl()
    with pytest.raises(ValueError):
        c.show('MyHome')
Example #6
0
def test_show_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.show('MyHome')
Example #7
0
def test_down_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.down('ethernet')
Example #8
0
def test_down():
    c = DummyConnectionControl()
    name = 'MyHome'
    c.down(name)
    assert c.down_args[0] == name
Example #9
0
def test_up():
    c = DummyConnectionControl()
    name = 'MyHome'
    c.up(name)
    assert c.up_args[0] == name
Example #10
0
def test_call():
    result_call = [Connection('a', 'b', 'ethernet', 'eth0')]
    c = DummyConnectionControl(result_call)
    assert c() == result_call
Example #11
0
def test_delete():
    c = DummyConnectionControl()
    name = 'MyHome'
    c.delete(name)
    assert c.delete_args[0] == name
Example #12
0
def test_modify_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.modify('ethernet', {'key':'value'})
Example #13
0
def test_call_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c()
Example #14
0
def test_reload_when_raise_error():
    c = DummyConnectionControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.reload()
Example #15
0
def test_reload():
    c = DummyConnectionControl()
    c.reload()
    assert c.called_reload == 1