-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
But haven't asserted the return object against the doc
- Loading branch information
Showing
11 changed files
with
315 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Airflow API (Stable) | ||
Apache Airflow management API. # noqa: E501 | ||
The version of the OpenAPI document: 1.0.0 | ||
Contact: zach.z.liu@gmail.com | ||
Generated by: https://openapi-generator.tech | ||
""" | ||
|
||
import logging | ||
|
||
from test.integration.conftest import BCOLORS | ||
|
||
from airflow_python_sdk.model.pool import Pool | ||
|
||
POOL_DICT = { | ||
"name": "test_pool", | ||
"slots": 1, | ||
} | ||
|
||
INIT_POOL = Pool(**POOL_DICT) | ||
|
||
def test_create_pool(pool_api_setup): | ||
"""Test the post /pools API EP""" | ||
api_response = pool_api_setup.post_pool(INIT_POOL) | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
|
||
def test_update_pool(pool_api_setup): | ||
"""Test the patch /pools/{pool_id} API EP""" | ||
POOL_DICT["slots"] = 2 | ||
updated_pool = Pool(**POOL_DICT) | ||
api_response = pool_api_setup.patch_pool( | ||
"test_pool", | ||
updated_pool, | ||
) | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
|
||
def test_get_pool(pool_api_setup): | ||
"""Test the get /pools/{pool_id} API EP""" | ||
POOL_DICT["occupied_slots"] = 0 | ||
POOL_DICT["open_slots"] = POOL_DICT["slots"] | ||
POOL_DICT["queued_slots"] = 0 | ||
POOL_DICT["running_slots"] = 0 | ||
updated_pool = Pool(**POOL_DICT) | ||
api_response = pool_api_setup.get_pool("test_pool") | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
assert api_response == updated_pool | ||
|
||
def test_delete_pool(pool_api_setup): | ||
"""Test the delete /pools/{pool_id} API EP""" | ||
api_response = pool_api_setup.delete_pool("test_pool") | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") |
54 changes: 54 additions & 0 deletions
54
test/integration/test_create_update_get_delete_variable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Airflow API (Stable) | ||
Apache Airflow management API. # noqa: E501 | ||
The version of the OpenAPI document: 1.0.0 | ||
Contact: zach.z.liu@gmail.com | ||
Generated by: https://openapi-generator.tech | ||
""" | ||
|
||
import logging | ||
|
||
from test.integration.conftest import BCOLORS | ||
|
||
from airflow_python_sdk.model.variable import Variable | ||
|
||
VARIABLE_DICT = { | ||
"key": "test_variable", | ||
"value": "{1:2, 3:4}", | ||
} | ||
|
||
INIT_VARIABLE = Variable(**VARIABLE_DICT) | ||
|
||
def test_create_variable(variable_api_setup): | ||
"""Test the post /variables API EP""" | ||
api_response = variable_api_setup.post_variables(INIT_VARIABLE) | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
|
||
def test_update_variable(variable_api_setup): | ||
"""Test the patch /variables/{variable_key} API EP""" | ||
VARIABLE_DICT["value"] = "{1:2,5:6}" | ||
updated_variable = Variable(**VARIABLE_DICT) | ||
api_response = variable_api_setup.patch_variable( | ||
"test_variable", | ||
updated_variable, | ||
) | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
|
||
def test_get_variable(variable_api_setup): | ||
"""Test the get /variables/{variable_key} API EP""" | ||
VARIABLE_DICT["value"] = "{1:2,5:6}" | ||
updated_variable = Variable(**VARIABLE_DICT) | ||
api_response = variable_api_setup.get_variable("test_variable") | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
assert api_response == updated_variable | ||
|
||
def test_delete_variable(variable_api_setup): | ||
"""Test the delete /variables/{variable_key} API EP""" | ||
api_response = variable_api_setup.delete_variable("test_variable") | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Airflow API (Stable) | ||
Apache Airflow management API. # noqa: E501 | ||
The version of the OpenAPI document: 1.0.0 | ||
Contact: zach.z.liu@gmail.com | ||
Generated by: https://openapi-generator.tech | ||
""" | ||
|
||
import logging | ||
|
||
from test.integration.conftest import BCOLORS | ||
|
||
|
||
def test_get_dag(dag_api_setup): | ||
"""Test the /dags/{dag_id} API EP""" | ||
api_response = dag_api_setup.get_dag(dag_id="example_bash_operator") | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
|
||
def test_get_dag_code(dag_api_setup): | ||
"""Test the /dagSources/{file_token} API EP""" | ||
api_response = dag_api_setup.get_dag(dag_id="example_bash_operator") | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
|
||
file_token = api_response.file_token | ||
|
||
api_response = dag_api_setup.get_dag_source(file_token=file_token) | ||
logging.getLogger().info("%s", api_response) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Airflow API (Stable) | ||
Apache Airflow management API. # noqa: E501 | ||
The version of the OpenAPI document: 1.0.0 | ||
Contact: zach.z.liu@gmail.com | ||
Generated by: https://openapi-generator.tech | ||
""" | ||
|
||
import logging | ||
from datetime import datetime | ||
from time import sleep | ||
|
||
from test.integration.conftest import BCOLORS | ||
|
||
from airflow_python_sdk.model.dag_run import DAGRun | ||
from dateutil.parser import parse | ||
|
||
def test_trigger_delete_dag_run(dag_run_api_setup): | ||
"""Test the /dags/{dag_id}/dagRuns API EP (post) & | ||
/dags/{dag_id}/dagRuns/{dag_run_id} API EP (delete)""" | ||
time_now = datetime.now().strftime("%Y-%m-%dT%H:%M:%S+00:00") | ||
dag_run_id = "test2__{}".format(time_now) | ||
dag_run = DAGRun( | ||
dag_run_id=dag_run_id, | ||
execution_date=parse(time_now), | ||
conf={}, | ||
) | ||
trigger_resp = dag_run_api_setup.post_dag_run( | ||
dag_id="example_bash_operator", | ||
dag_run=dag_run, | ||
) | ||
logging.getLogger().info("%s", trigger_resp) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") | ||
|
||
sleep(5) | ||
|
||
delete_resp = dag_run_api_setup.delete_dag_run( | ||
dag_id="example_bash_operator", | ||
dag_run_id=dag_run_id, | ||
) | ||
logging.getLogger().info("%s", delete_resp) | ||
print(f"{BCOLORS.OKGREEN}OK{BCOLORS.ENDC}") |