ashb commented on issue #4772: [AIRFLOW-3937] KubernetesPodOperator support for envFrom configMapRef… URL: https://github.com/apache/airflow/pull/4772#issuecomment-474602543 @galuszkak sorry - that example wasn't so great - we now aren't actually testing the behaviour of the pod factory functions. Somewhere in the tests I'd like to see something like ```python self.assertEqual( SOMETHING['spec']['containers'][0]['envFrom'], { 'secretRef': { 'name': 'secret-name' } }, ) ``` or similar. Maybe we can do this like this: ```python @mock.patch("airflow.contrib.kubernetes.pod_launcher.PodLauncher._monitor_pod") @mock.patch("airflow.contrib.kubernetes.kube_client.get_kube_client") def test_envs_from_secrets(self, client_mock, _): # GIVEN from airflow.utils.state import State secrets = [Secret('env', None, "secret_name")] mock_resp = MagicMock() mock_resp.status.start_time = datetime.now() client_mock.create_namespaced_pod.return_value = mock_resp # WHEN k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], secrets=secrets, labels={"foo": "bar"}, name="test", task_id="task", ) k.execute(None) # THEN req = client_mock.create_namespaced_pod.call_args[0][1]['req'] self.assertEqual( req['spec']['containers'][0]['envFrom'], { 'secretRef': { 'name': 'secret-name' } }, ) ``` Note: this is untested, and we may need to mock some extra methods
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
