def test_compile_circuit_replaces_swaps():
    """Tests that the compiler never sees the SwapPermutationGates from the
    router."""
    compiler_mock = MagicMock(side_effect=lambda circuit: circuit)
    a, b, c = cirq.LineQubit.range(3)
    # Create a circuit that will require some swaps.
    model_circuit = cirq.Circuit(
        [
            cirq.Moment([cirq.CNOT(a, b)]),
            cirq.Moment([cirq.CNOT(a, c)]),
            cirq.Moment([cirq.CNOT(b, c)]),
        ]
    )
    compilation_result = cirq.contrib.quantum_volume.compile_circuit(
        model_circuit,
        device_graph=ccr.gridqubits_to_graph_device(FakeDevice().qubits),
        compiler=compiler_mock,
        routing_attempts=1,
    )

    # Assert that there were some swaps in the result
    compiler_mock.assert_called_with(compilation_result.circuit)
    assert (
        len(
            list(compilation_result.circuit.findall_operations_with_gate_type(cirq.ops.SwapPowGate))
        )
        > 0
    )
    # Assert that there were not SwapPermutations in the result.
    assert (
        len(
            list(
                compilation_result.circuit.findall_operations_with_gate_type(
                    cirq.contrib.acquaintance.SwapPermutationGate
                )
            )
        )
        == 0
    )
Tests that the compiler never sees the SwapPermutationGates from the
    router.
cirq-core/cirq/contrib/quantum_volume/quantum_volume_test.py