Exemplo n.º 1
0
def test_iptables_txn_with_exception():
    table = mock.Mock(autocommit=True)
    with pytest.raises(ValueError):
        with iptables.iptables_txn(table):
            raise ValueError('just testing lol')
    assert table.commit.called is False
    assert table.refresh.called is True
    assert table.autocommit is True
Exemplo n.º 2
0
def test_iptables_txn_normal():
    table = mock.Mock(autocommit=True)
    with iptables.iptables_txn(table):
        assert table.autocommit is False
        assert table.commit.called is False
        assert table.refresh.called is False
    assert table.commit.called is True
    assert table.refresh.called is True
    assert table.autocommit is True