andyjianzhou commented on code in PR #40254:
URL: https://github.com/apache/airflow/pull/40254#discussion_r1640800647


##########
tests/www/views/test_views_grid.py:
##########
@@ -514,3 +515,59 @@ def test_next_run_datasets_404(admin_client):
     resp = admin_client.get("/object/next_run_datasets/missingdag", 
follow_redirects=True)
     assert resp.status_code == 404, resp.json
     assert resp.json == {"error": "can't find dag missingdag"}
+
+def test_get_date_time_num_runs_dag_runs_form_data(dag_with_runs):
+    run1, _ = dag_with_runs
+
+    class Request:
+        def __init__(self, form):
+            self.form = form
+            self.args = form
+        
+        def get(self, key, default=None):
+            return self.args.get(key, default)
+
+    # Test case 1: run_id is provided
+    request_with_run_id = Request(form={
+        "execution_date": run1.execution_date.isoformat(),
+        "num_runs": "5",
+        "run_id": run1.run_id
+    })
+
+    with create_session() as session:
+        data = get_date_time_num_runs_dag_runs_form_data(request_with_run_id, 
session, run1.dag)
+
+    assert data['dttm'] == run1.execution_date
+    assert data['execution_date'] == run1.execution_date.isoformat()
+    assert data['num_runs'] == 5
+    
+    # Test case 2: base_date is provided
+    base_date = "2023-01-01T00:00:00+00:00"
+    request_with_base_date = Request(form={
+        "execution_date": run1.execution_date.isoformat(),
+        "num_runs": "5",
+        "base_date": base_date
+    })
+
+    with create_session() as session:
+        data = 
get_date_time_num_runs_dag_runs_form_data(request_with_base_date, session, 
run1.dag)
+
+    assert data['base_date'] == _safe_parse_datetime(base_date)
+    assert data['execution_date'] == run1.execution_date.isoformat()
+    assert data['num_runs'] == 5
+
+    # Test case 3: both run_id and base_date are provided

Review Comment:
   Sounds good!



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