Skip to content

Commit

Permalink
cleaning up tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWheating committed Jun 10, 2021
1 parent ee77628 commit a331f55
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion airflow/api_connexion/endpoints/dag_endpoint.py
Expand Up @@ -65,7 +65,7 @@ def get_dags(limit, session, offset=0, only_active=True):
if only_active:
dags_query = session.query(DagModel).filter(~DagModel.is_subdag, DagModel.is_active)
else:
dags_query = session.query(DagModel).filter(~DagModel.is_subdag)
dags_query = session.query(DagModel).filter(~DagModel.is_subdag)

readable_dags = current_app.appbuilder.sm.get_accessible_dag_ids(g.user)

Expand Down
7 changes: 0 additions & 7 deletions airflow/api_connexion/openapi/v1.yaml
Expand Up @@ -931,13 +931,6 @@ paths:
parameters:
- $ref: '#/components/parameters/PageLimit'
- $ref: '#/components/parameters/PageOffset'
- name: only_active
in: query
schema:
type: boolean
default: true
required: false
description: Only return active DAGs.
responses:
'200':
description: Success.
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/dag.py
Expand Up @@ -2106,7 +2106,7 @@ class DagModel(Base):
is_paused = Column(Boolean, default=is_paused_at_creation)
# Whether the DAG is a subdag
is_subdag = Column(Boolean, default=False)
# Whether that DAG is currently seen by the scheduler(s)
# Whether that DAG was seen on the last DagBag load
is_active = Column(Boolean, default=False)
# Last time the scheduler started
last_parsed_time = Column(UtcDateTime)
Expand Down
22 changes: 7 additions & 15 deletions tests/api_connexion/endpoints/test_dag_endpoint.py
Expand Up @@ -454,13 +454,9 @@ def test_should_respond_200(self, session):
"total_entries": 2,
} == response.json

@provide_session
def test_only_active_true_returns_active_dags(self, session):
def test_only_active_true_returns_active_dags(self):
self._create_dag_models(1)
dag_model = DagModel(
dag_id="TEST_DAG_2", fileloc="/tmp/dag_2.py", schedule_interval="2 2 * * *", is_active=False
)
session.add(dag_model)
self._create_deactivated_dag()
response = self.client.get("api/v1/dags?only_active=True", environ_overrides={'REMOTE_USER': "test"})
file_token = SERIALIZER.dumps("/tmp/dag_1.py")
assert response.status_code == 200
Expand All @@ -486,16 +482,12 @@ def test_only_active_true_returns_active_dags(self, session):
"total_entries": 1,
} == response.json

@provide_session
def test_only_active_false_returns_all_dags(self, session):
def test_only_active_false_returns_all_dags(self):
self._create_dag_models(1)
dag_model = DagModel(
dag_id="TEST_DAG_2", fileloc="/tmp/dag_2.py", schedule_interval="2 2 * * *", is_active=False
)
session.add(dag_model)
self._create_deactivated_dag()
response = self.client.get("api/v1/dags?only_active=False", environ_overrides={'REMOTE_USER': "test"})
file_token = SERIALIZER.dumps("/tmp/dag_1.py")
file_token_2 = SERIALIZER.dumps("/tmp/dag_2.py")
file_token_2 = SERIALIZER.dumps("/tmp/dag_del_1.py")
assert response.status_code == 200
assert {
"dags": [
Expand All @@ -516,9 +508,9 @@ def test_only_active_false_returns_all_dags(self, session):
"tags": [],
},
{
"dag_id": "TEST_DAG_2",
"dag_id": "TEST_DAG_DELETED_1",
"description": None,
"fileloc": "/tmp/dag_2.py",
"fileloc": "/tmp/dag_del_1.py",
"file_token": file_token_2,
"is_paused": False,
"is_active": False,
Expand Down

0 comments on commit a331f55

Please sign in to comment.