You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/11/24 13:38:16 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #19806: Psrp advanced options

uranusjr commented on a change in pull request #19806:
URL: https://github.com/apache/airflow/pull/19806#discussion_r756083794



##########
File path: tests/providers/microsoft/psrp/hooks/test_psrp.py
##########
@@ -29,43 +30,67 @@
 CONNECTION_ID = "conn_id"
 
 
-class TestPSRPHook(unittest.TestCase):
-    @patch(
-        f"{PSRPHook.__module__}.{PSRPHook.__name__}.get_connection",
-        return_value=Connection(
-            login='username',
-            password='password',
-            host='remote_host',
-        ),
-    )
-    @patch(f"{PSRPHook.__module__}.WSMan")
-    @patch(f"{PSRPHook.__module__}.PowerShell")
-    @patch(f"{PSRPHook.__module__}.RunspacePool")
-    @patch("logging.Logger.info")
-    def test_invoke_powershell(self, log_info, runspace_pool, powershell, ws_man, get_connection):
-        with PSRPHook(CONNECTION_ID) as hook:
-            ps = powershell.return_value = MagicMock()
-            ps.state = PSInvocationState.RUNNING
-            ps.output = []
-            ps.streams.debug = []
-            ps.streams.information = []
-            ps.streams.error = []
+def mock_powershell():

Review comment:
       FWIW you can subclass `Mock` (or `MagicMock`. This could make this a bit more readable?

##########
File path: tests/providers/microsoft/psrp/hooks/test_psrp.py
##########
@@ -29,43 +30,67 @@
 CONNECTION_ID = "conn_id"
 
 
-class TestPSRPHook(unittest.TestCase):
-    @patch(
-        f"{PSRPHook.__module__}.{PSRPHook.__name__}.get_connection",
-        return_value=Connection(
-            login='username',
-            password='password',
-            host='remote_host',
-        ),
-    )
-    @patch(f"{PSRPHook.__module__}.WSMan")
-    @patch(f"{PSRPHook.__module__}.PowerShell")
-    @patch(f"{PSRPHook.__module__}.RunspacePool")
-    @patch("logging.Logger.info")
-    def test_invoke_powershell(self, log_info, runspace_pool, powershell, ws_man, get_connection):
-        with PSRPHook(CONNECTION_ID) as hook:
-            ps = powershell.return_value = MagicMock()
-            ps.state = PSInvocationState.RUNNING
-            ps.output = []
-            ps.streams.debug = []
-            ps.streams.information = []
-            ps.streams.error = []
+def mock_powershell():

Review comment:
       FWIW you can subclass `Mock` or `MagicMock`. This could make this a bit more readable?




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org