ashb commented on a change in pull request #19712:
URL: https://github.com/apache/airflow/pull/19712#discussion_r753352042



##########
File path: tests/cli/commands/test_webserver_command.py
##########
@@ -386,63 +346,69 @@ def 
test_cli_webserver_shutdown_when_gunicorn_master_is_killed(self, _):
                 webserver_command.webserver(args)
         assert ctx.value.code == 1
 
-    def test_cli_webserver_debug(self):
-        env = os.environ.copy()
-        proc = psutil.Popen(["airflow", "webserver", "--debug"], env=env)
-        time.sleep(3)  # wait for webserver to start
-        return_code = proc.poll()
-        assert return_code is None, f"webserver terminated with return code 
{return_code} in debug mode"
-        proc.terminate()
-        assert -15 == proc.wait(60)
-
-    def test_cli_webserver_access_log_format(self):
-
-        # json access log format
-        access_logformat = (
-            "{\"ts\":\"%(t)s\",\"remote_ip\":\"%(h)s\",\"request_id\":\"%({"
-            
"X-Request-Id}i)s\",\"code\":\"%(s)s\",\"request_method\":\"%(m)s\","
-            
"\"request_path\":\"%(U)s\",\"agent\":\"%(a)s\",\"response_time\":\"%(D)s\","
-            "\"response_length\":\"%(B)s\"} "
-        )
-        with tempfile.TemporaryDirectory() as tmpdir, mock.patch.dict(
-            "os.environ",
-            AIRFLOW__CORE__DAGS_FOLDER="/dev/null",
-            AIRFLOW__CORE__LOAD_EXAMPLES="False",
-            AIRFLOW__WEBSERVER__WORKERS="1",
-        ):
-            access_logfile = f"{tmpdir}/access.log"
-            # Run webserver in foreground and terminate it.
+    def test_cli_webserver_debug(self, app):
+        with mock.patch.object(webserver_command, 'create_app') as create_app, 
mock.patch.object(
+            app, 'run'
+        ) as app_run:
+            create_app.return_value = app
 
-            proc = subprocess.Popen(
+            args = self.parser.parse_args(
+                [
+                    "webserver",
+                    "--debug",
+                ]
+            )
+            webserver_command.webserver(args)
+
+            app_run.assert_called_with(
+                debug=True,
+                use_reloader=False,
+                port=8080,
+                host='0.0.0.0',
+                ssl_context=None,
+            )
+
+    def test_cli_webserver_args(self):
+        access_logformat = "custom_log_format"

Review comment:
       Yeah fair.




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


Reply via email to