'Test that the right resources are cleaned up.'

def test__provision_external_connectivity_fail_expected_cleanup(self):

    subnets = [{'id': 'subnet_foo_1', 'network_id': 'network_foo'}]
    with mock.patch.object(self.mixin, '_cleanup') as mock_cleanup:
        self.mixin.l3_plugin.create_router.side_effect = n_exc.BadRequest(resource='router', msg='doh!')
        self.assertRaises(exceptions.AutoAllocationFailure, self.mixin._provision_external_connectivity, self.ctx, 'ext_net_foo', subnets, 'tenant_foo')
        mock_cleanup.assert_called_once_with(self.ctx, network_id='network_foo', router_id=None, subnets=[])
