Repository: apache/airflow
File: helm-tests/tests/helm_tests/airflow_aux/test_configmap.py (Python)

Code before:
            (False, "my-secret", None, False),
            (False, None, "my-key", False),
        ],
    )
    def test_pod_template_git_sync_ssh_key_volume(
        self, git_sync_enabled, ssh_key_secret, ssh_key, expected_volume
    ):
        dag_values = {"gitSync": {"enabled": git_sync_enabled}}
        if ssh_key_secret:
            dag_values["gitSync"]["sshKeySecret"] = ssh_key_secret
        if ssh_key:
            dag_values["gitSync"]["sshKey"] = ssh_key

        docs = render_chart(
            values={
                "executor": "KubernetesExecutor",
                "dags": dag_values,
            },
            show_only=["templates/configmaps/configmap.yaml"],
        )

        pod_template_file = jmespath.search('data."pod_template_file.yaml"', docs[0])
        if expected_volume:
            assert "git-sync-ssh-key" in pod_template_file
        else:
            assert "git-sync-ssh-key" not in pod_template_file

    @pytest.mark.parametrize(
        ("scheduler_cpu_limit", "expected_sync_parallelism"),
        [
            ("1m", "1"),
            ("1000m", "1"),
            ("1001m", "2"),
            ("0.1", "1"),
            ("1", "1"),
            ("1.01", "2"),
            (None, 0),
            (0, 0),
        ],
    )
    def test_expected_celery_sync_parallelism(self, scheduler_cpu_limit, expected_sync_parallelism):
        scheduler_resources_cpu_limit = {}
        if scheduler_cpu_limit is not None:
            scheduler_resources_cpu_limit = {
                "scheduler": {"resources": {"limits": {"cpu": scheduler_cpu_limit}}}
            }

        configmap = render_chart(
            values=scheduler_resources_cpu_limit,
            show_only=["templates/configmaps/configmap.yaml"],
        )

Review comment (suggestion):
```suggestion
        assert ("git-sync-ssh-key" in pod_template_file) == expected_volume
```

Code after:
    )
    def test_pod_template_git_sync_ssh_key_volume_with_ssh_key_secret_name(
        self, git_sync_enabled, ssh_key_secret, expected_volume
    ):
        dag_values = {"gitSync": {"enabled": git_sync_enabled, "sshKeySecret": ssh_key_secret}}
        docs = render_chart(
            values={
                "executor": "KubernetesExecutor",
                "dags": dag_values,
            },
            show_only=["templates/configmaps/configmap.yaml"],
        )

        pod_template_file = jmespath.search('data."pod_template_file.yaml"', docs[0])
        assert ("git-sync-ssh-key" in pod_template_file) == expected_volume

    @pytest.mark.parametrize(
        ("git_sync_enabled", "ssh_key", "expected_volume"),
        [
            (True, "my-key", True),
            (True, None, False),
            (False, "my-key", False),
        ],
    )
    def test_pod_template_git_sync_ssh_key_volume_with_ssh_key(
        self, git_sync_enabled, ssh_key, expected_volume
    ):
        dag_values = {"gitSync": {"enabled": git_sync_enabled, "sshKey": ssh_key}}
        docs = render_chart(
            values={
                "executor": "KubernetesExecutor",
                "dags": dag_values,
            },
            show_only=["templates/configmaps/configmap.yaml"],
        )

        pod_template_file = jmespath.search('data."pod_template_file.yaml"', docs[0])
        assert ("git-sync-ssh-key" in pod_template_file) == expected_volume

    @pytest.mark.parametrize(
        ("scheduler_cpu_limit", "expected_sync_parallelism"),
        [
            ("1m", "1"),
            ("1000m", "1"),
            ("1001m", "2"),
            ("0.1", "1"),
            ("1", "1"),
            ("1.01", "2"),
            (None, 0),
            (0, 0),
        ],