aritra24 commented on code in PR #40254:
URL: https://github.com/apache/airflow/pull/40254#discussion_r1640781036
##########
airflow/www/views.py:
##########
@@ -271,7 +271,12 @@ def get_date_time_num_runs_dag_runs_form_data(www_request,
session, dag):
base_date = (date_time +
datetime.timedelta(seconds=1)).replace(microsecond=0)
default_dag_run = conf.getint("webserver",
"default_dag_run_display_number")
- num_runs = www_request.args.get("num_runs", default=default_dag_run,
type=int)
Review Comment:
Why replace this? Both seem to be performing the same operation?
##########
tests/www/test_validators.py:
##########
@@ -164,4 +162,4 @@ def setup_method(self):
def test_read_only_validator(self):
validator = validators.ReadOnly()
assert validator(self.form_mock, self.form_read_only_field_mock) is
None
- assert self.form_read_only_field_mock.flags.readonly is True
Review Comment:
This seems to be something maybe done by the ide, might be good to fix it.
##########
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:
I'm not sure if test case 1 & 2 are testing anything new that's not also
done in 3? If they aren't maybe it might be better to skip them and just have
3.
--
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]