Ejemplo n.º 1
0
def test_ensure_chain_creates_chain_if_doesnt_exist():
    with mock.patch.object(iptables,
                           "list_chain",
                           side_effect=iptables.ChainDoesNotExist(
                               "PAASTA.service")), mock.patch.object(
                                   iptables, "create_chain",
                                   autospec=True) as mock_create_chain:
        iptables.ensure_chain("PAASTA.service", ())

    assert mock_create_chain.mock_calls == [mock.call("PAASTA.service")]
Ejemplo n.º 2
0
def test_ensure_chain_creates_chain_if_doesnt_exist():
    with mock.patch.object(
        iptables, 'list_chain',
        side_effect=iptables.ChainDoesNotExist('PAASTA.service'),
    ), mock.patch.object(
        iptables, 'create_chain', autospec=True,
    ) as mock_create_chain:
        iptables.ensure_chain('PAASTA.service', ())

    assert mock_create_chain.mock_calls == [
        mock.call('PAASTA.service'),
    ]