This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 9d877b43462 Return empty list when AzureContainerInstanceHook.get_logs 
receives Logs(content=None) instead of returning [None]. (#63394)
9d877b43462 is described below

commit 9d877b43462a69040035747dfc2f0761408bad59
Author: SameerMesiah97 <[email protected]>
AuthorDate: Mon Apr 6 23:05:46 2026 +0100

    Return empty list when AzureContainerInstanceHook.get_logs receives 
Logs(content=None) instead of returning [None]. (#63394)
    
    Refactor the existing test_get_logs test to use parametrization and add 
coverage for the Logs(content=None) case.
    
    Co-authored-by: Sameer Mesiah <[email protected]>
---
 .../microsoft/azure/hooks/container_instance.py          |  2 +-
 .../microsoft/azure/hooks/test_container_instance.py     | 16 +++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git 
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/container_instance.py
 
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/container_instance.py
index bfb7940ec21..b30d729c478 100644
--- 
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/container_instance.py
+++ 
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/container_instance.py
@@ -136,7 +136,7 @@ class AzureContainerInstanceHook(AzureBaseHook):
         """
         logs = self.connection.containers.list_logs(resource_group, name, 
name, tail=tail)
         if logs.content is None:
-            return [None]
+            return []
         return logs.content.splitlines(True)
 
     def delete(self, resource_group: str, name: str) -> None:
diff --git 
a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_container_instance.py
 
b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_container_instance.py
index 850409dcc3f..a9510e90945 100644
--- 
a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_container_instance.py
+++ 
b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_container_instance.py
@@ -80,15 +80,21 @@ class TestAzureContainerInstanceHook:
         self.hook.get_state("resource_group", "aci-test")
         get_state_mock.assert_called_once_with("resource_group", "aci-test")
 
+    @pytest.mark.parametrize(
+        ("content", "expected"),
+        [
+            ("log line 1\nlog line 2\nlog line 3\n", ["log line 1\n", "log 
line 2\n", "log line 3\n"]),
+            (None, []),
+        ],
+    )
     
@patch("azure.mgmt.containerinstance.operations.ContainersOperations.list_logs")
-    def test_get_logs(self, list_logs_mock):
-        expected_messages = ["log line 1\n", "log line 2\n", "log line 3\n"]
-        logs = Logs(content="".join(expected_messages))
+    def test_get_logs(self, list_logs_mock, content, expected):
+        logs = Logs(content=content)
         list_logs_mock.return_value = logs
 
-        logs = self.hook.get_logs("resource_group", "name", "name")
+        result = self.hook.get_logs("resource_group", "name", "name")
 
-        assert logs == expected_messages
+        assert result == expected
 
     
@patch("azure.mgmt.containerinstance.operations.ContainerGroupsOperations.begin_delete")
     def test_delete(self, delete_mock):

Reply via email to