예제 #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")]
예제 #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'),
    ]