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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]