Example #1
0
def test_garbage_collect_old_service_chains():
    with mock.patch.object(
            iptables,
            'delete_chain',
            autospec=True,
    ) as mock_delete_chain, mock.patch.object(
            iptables,
            'all_chains',
            autospec=True,
            return_value={
                'INPUT',
                'OUTPUT',
                'FORWARD',
                'DOCKER',
                'PAASTA',
                'PAASTA-INTERNET',
                'PAASTA.chain1',
                'PAASTA.chain3',
            },
    ):
        firewall.garbage_collect_old_service_chains({
            'PAASTA.chain1': {'mac1', 'mac2'},
            'PAASTA.chain2': {'mac3'},
        })

    assert mock_delete_chain.mock_calls == [
        mock.call('PAASTA.chain3'),
    ]
Example #2
0
def test_garbage_collect_old_service_chains():
    with mock.patch.object(
        iptables, "delete_chain", autospec=True
    ) as mock_delete_chain, mock.patch.object(
        iptables,
        "all_chains",
        autospec=True,
        return_value={
            "INPUT",
            "OUTPUT",
            "FORWARD",
            "DOCKER",
            "PAASTA",
            "PAASTA-INTERNET",
            "PAASTA.chain1",
            "PAASTA.chain3",
        },
    ):
        firewall.garbage_collect_old_service_chains(
            {"PAASTA.chain1": {"mac1", "mac2"}, "PAASTA.chain2": {"mac3"}}
        )

    assert mock_delete_chain.mock_calls == [mock.call("PAASTA.chain3")]