Ejemplo n.º 1
0
def test_push_list():
    frr = MagicMock()
    c = ConfigMgr(frr)
    c.push_list(["change1", "change2"])
    assert c.changes == "change1\nchange2\n"
    c.push_list(["change3", "change4"])
    assert c.changes == "change1\nchange2\nchange3\nchange4\n"
Ejemplo n.º 2
0
def commit_changes_common(write_error, restart_error, result):
    frr = MagicMock()
    frr.write = MagicMock(return_value=write_error)
    frr.restart_peer_groups = MagicMock(return_value=restart_error)
    c = ConfigMgr(frr)
    c.reset = MagicMock()
    c.push_list(["change1", "change2"])
    c.restart_peer_groups(["pg1", "pg2"])
    res = c.commit()
    assert res == result
    assert c.reset.called
    frr.write.assert_called_with('change1\nchange2\n')
    frr.restart_peer_groups.assert_called_with(["pg1", "pg2"])
Ejemplo n.º 3
0
def test_push_and_push_list():
    frr = MagicMock()
    c = ConfigMgr(frr)
    c.push("update1\nupdate2\n")
    c.push_list(["change1", "change2"])
    assert c.changes == "update1\nupdate2\n\nchange1\nchange2\n"