def test_reset(): frr = MagicMock() c = ConfigMgr(frr) c.reset() assert c.frr == frr assert c.current_config is None assert c.current_config_raw is None assert c.changes == "" assert c.peer_groups_to_restart == []
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"])