Linting: Make Shipyard mostly pep8 compliant
This PS makes shipyard mostly pep8 compliant, with the exeption of: ./shipyard_airflow/plugins/rest_api_plugin.py which will require some rework to make compliant. Change-Id: I913f7ac696eb5558c1fed7c4f4104211bf4b5876
This commit is contained in:
parent
25c8adbe75
commit
6ae83ed258
@ -73,6 +73,7 @@ def upgrade():
|
|||||||
server_default=func.now()),
|
server_default=func.now()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
"""
|
"""
|
||||||
Remove the database objects created by this revision
|
Remove the database objects created by this revision
|
||||||
|
@ -214,6 +214,7 @@ SECTIONS = [
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def register_opts(conf):
|
def register_opts(conf):
|
||||||
"""
|
"""
|
||||||
Registers all the sections in this module.
|
Registers all the sections in this module.
|
||||||
|
@ -26,6 +26,7 @@ class ConfigSection(object):
|
|||||||
"""
|
"""
|
||||||
Defines a configuration section
|
Defines a configuration section
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, title, options, help=None):
|
def __init__(self, name, title, options, help=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.title = title
|
self.title = title
|
||||||
|
@ -30,6 +30,7 @@ DAG_STATE_MAPPING = {
|
|||||||
'PAUSED': 'Paused'
|
'PAUSED': 'Paused'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def determine_lifecycle(dag_status=None):
|
def determine_lifecycle(dag_status=None):
|
||||||
"""
|
"""
|
||||||
Convert a dag_status to an action_lifecycle value
|
Convert a dag_status to an action_lifecycle value
|
||||||
@ -38,6 +39,7 @@ def determine_lifecycle(dag_status=None):
|
|||||||
dag_status = 'NONE'
|
dag_status = 'NONE'
|
||||||
return DAG_STATE_MAPPING.get(dag_status.upper())
|
return DAG_STATE_MAPPING.get(dag_status.upper())
|
||||||
|
|
||||||
|
|
||||||
def format_action_steps(action_id, steps):
|
def format_action_steps(action_id, steps):
|
||||||
"""
|
"""
|
||||||
Converts a list of action step database records to desired format
|
Converts a list of action step database records to desired format
|
||||||
@ -51,6 +53,7 @@ def format_action_steps(action_id, steps):
|
|||||||
index=idx + 1))
|
index=idx + 1))
|
||||||
return steps_response
|
return steps_response
|
||||||
|
|
||||||
|
|
||||||
def format_step(action_id, step, index):
|
def format_step(action_id, step, index):
|
||||||
"""
|
"""
|
||||||
reformat a step (dictionary) into a common response format
|
reformat a step (dictionary) into a common response format
|
||||||
|
@ -77,10 +77,12 @@ def start_api():
|
|||||||
|
|
||||||
return control_api
|
return control_api
|
||||||
|
|
||||||
|
|
||||||
class VersionsResource(BaseResource):
|
class VersionsResource(BaseResource):
|
||||||
"""
|
"""
|
||||||
Lists the versions supported by this API
|
Lists the versions supported by this API
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def on_get(self, req, resp):
|
def on_get(self, req, resp):
|
||||||
resp.body = self.to_json({
|
resp.body = self.to_json({
|
||||||
'v1.0': {
|
'v1.0': {
|
||||||
|
@ -128,10 +128,12 @@ class BaseResource(object):
|
|||||||
"""
|
"""
|
||||||
self.log_message(ctx, logging.ERROR, msg)
|
self.log_message(ctx, logging.ERROR, msg)
|
||||||
|
|
||||||
|
|
||||||
class ShipyardRequestContext(object):
|
class ShipyardRequestContext(object):
|
||||||
"""
|
"""
|
||||||
Context object for shipyard resource requests
|
Context object for shipyard resource requests
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.log_level = 'error'
|
self.log_level = 'error'
|
||||||
self.user = None
|
self.user = None
|
||||||
|
@ -54,6 +54,8 @@ Define push function to store the content of 'action' that is
|
|||||||
defined via 'dag_run' in XCOM so that it can be used by the
|
defined via 'dag_run' in XCOM so that it can be used by the
|
||||||
Operators
|
Operators
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def xcom_push(**kwargs):
|
def xcom_push(**kwargs):
|
||||||
# Pushes action XCom
|
# Pushes action XCom
|
||||||
kwargs['ti'].xcom_push(key='action',
|
kwargs['ti'].xcom_push(key='action',
|
||||||
|
@ -35,6 +35,7 @@ promenade_conf = config.get('drydock', 'prom_yaml')
|
|||||||
parent_dag = 'deploy_site'
|
parent_dag = 'deploy_site'
|
||||||
child_dag = 'deploy_site.drydock_build'
|
child_dag = 'deploy_site.drydock_build'
|
||||||
|
|
||||||
|
|
||||||
def create_drydock_client(parent_dag_name, child_dag_name, args):
|
def create_drydock_client(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Create Drydock Client
|
Create Drydock Client
|
||||||
@ -56,6 +57,7 @@ def create_drydock_client(parent_dag_name, child_dag_name, args):
|
|||||||
|
|
||||||
return dag
|
return dag
|
||||||
|
|
||||||
|
|
||||||
def drydock_get_design_id(parent_dag_name, child_dag_name, args):
|
def drydock_get_design_id(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Get Design ID
|
Get Design ID
|
||||||
@ -73,6 +75,7 @@ def drydock_get_design_id(parent_dag_name, child_dag_name, args):
|
|||||||
|
|
||||||
return dag
|
return dag
|
||||||
|
|
||||||
|
|
||||||
def drydock_load_parts(parent_dag_name, child_dag_name, args):
|
def drydock_load_parts(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Load DryDock Yaml
|
Load DryDock Yaml
|
||||||
@ -91,6 +94,7 @@ def drydock_load_parts(parent_dag_name, child_dag_name, args):
|
|||||||
|
|
||||||
return dag
|
return dag
|
||||||
|
|
||||||
|
|
||||||
def promenade_load_parts(parent_dag_name, child_dag_name, args):
|
def promenade_load_parts(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Load Promenade Yaml
|
Load Promenade Yaml
|
||||||
@ -109,6 +113,7 @@ def promenade_load_parts(parent_dag_name, child_dag_name, args):
|
|||||||
|
|
||||||
return dag
|
return dag
|
||||||
|
|
||||||
|
|
||||||
def drydock_verify_site(parent_dag_name, child_dag_name, args):
|
def drydock_verify_site(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Verify connectivity between DryDock and MAAS
|
Verify connectivity between DryDock and MAAS
|
||||||
@ -126,6 +131,7 @@ def drydock_verify_site(parent_dag_name, child_dag_name, args):
|
|||||||
|
|
||||||
return dag
|
return dag
|
||||||
|
|
||||||
|
|
||||||
def drydock_prepare_site(parent_dag_name, child_dag_name, args):
|
def drydock_prepare_site(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Prepare site for deployment
|
Prepare site for deployment
|
||||||
@ -143,6 +149,7 @@ def drydock_prepare_site(parent_dag_name, child_dag_name, args):
|
|||||||
|
|
||||||
return dag
|
return dag
|
||||||
|
|
||||||
|
|
||||||
def drydock_prepare_node(parent_dag_name, child_dag_name, args):
|
def drydock_prepare_node(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Prepare nodes for deployment
|
Prepare nodes for deployment
|
||||||
@ -160,6 +167,7 @@ def drydock_prepare_node(parent_dag_name, child_dag_name, args):
|
|||||||
|
|
||||||
return dag
|
return dag
|
||||||
|
|
||||||
|
|
||||||
def drydock_deploy_node(parent_dag_name, child_dag_name, args):
|
def drydock_deploy_node(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Deploy Nodes
|
Deploy Nodes
|
||||||
@ -188,6 +196,7 @@ DRYDOCK_PREPARE_SITE_DAG_NAME = 'drydock_prepare_site'
|
|||||||
DRYDOCK_PREPARE_NODE_DAG_NAME = 'drydock_prepare_node'
|
DRYDOCK_PREPARE_NODE_DAG_NAME = 'drydock_prepare_node'
|
||||||
DRYDOCK_DEPLOY_NODE_DAG_NAME = 'drydock_deploy_node'
|
DRYDOCK_DEPLOY_NODE_DAG_NAME = 'drydock_deploy_node'
|
||||||
|
|
||||||
|
|
||||||
def deploy_site_drydock(parent_dag_name, child_dag_name, args):
|
def deploy_site_drydock(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
Puts all of the drydock deploy site into atomic unit
|
Puts all of the drydock deploy site into atomic unit
|
||||||
|
@ -18,6 +18,7 @@ import configparser
|
|||||||
from airflow import DAG
|
from airflow import DAG
|
||||||
from airflow.operators import DryDockOperator
|
from airflow.operators import DryDockOperator
|
||||||
|
|
||||||
|
|
||||||
def sub_dag(parent_dag_name, child_dag_name, args, schedule_interval):
|
def sub_dag(parent_dag_name, child_dag_name, args, schedule_interval):
|
||||||
dag = DAG(
|
dag = DAG(
|
||||||
'%s.%s' % (parent_dag_name, child_dag_name),
|
'%s.%s' % (parent_dag_name, child_dag_name),
|
||||||
|
@ -44,6 +44,8 @@ main_dag = DAG(
|
|||||||
# Define push function to store the content of 'action' that is
|
# Define push function to store the content of 'action' that is
|
||||||
# defined via 'dag_run' in XCOM so that it can be used by the
|
# defined via 'dag_run' in XCOM so that it can be used by the
|
||||||
# DryDock Operators
|
# DryDock Operators
|
||||||
|
|
||||||
|
|
||||||
def push(**kwargs):
|
def push(**kwargs):
|
||||||
# Pushes action XCom
|
# Pushes action XCom
|
||||||
kwargs['ti'].xcom_push(key='action',
|
kwargs['ti'].xcom_push(key='action',
|
||||||
|
@ -24,6 +24,7 @@ config_path = '/usr/local/airflow/plugins/shipyard.conf'
|
|||||||
# Note that the shipyard.conf file needs to be placed on a volume
|
# Note that the shipyard.conf file needs to be placed on a volume
|
||||||
# that can be accessed by the containers
|
# that can be accessed by the containers
|
||||||
|
|
||||||
|
|
||||||
def k8s_preflight_check(parent_dag_name, child_dag_name, args):
|
def k8s_preflight_check(parent_dag_name, child_dag_name, args):
|
||||||
'''
|
'''
|
||||||
The k8s_preflight_check checks that k8s is in a good state for
|
The k8s_preflight_check checks that k8s is in a good state for
|
||||||
|
@ -52,6 +52,8 @@ Define push function to store the content of 'action' that is
|
|||||||
defined via 'dag_run' in XCOM so that it can be used by the
|
defined via 'dag_run' in XCOM so that it can be used by the
|
||||||
Operators
|
Operators
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def xcom_push(**kwargs):
|
def xcom_push(**kwargs):
|
||||||
# Pushes action XCom
|
# Pushes action XCom
|
||||||
kwargs['ti'].xcom_push(key='action',
|
kwargs['ti'].xcom_push(key='action',
|
||||||
|
@ -54,6 +54,8 @@ Define push function to store the content of 'action' that is
|
|||||||
defined via 'dag_run' in XCOM so that it can be used by the
|
defined via 'dag_run' in XCOM so that it can be used by the
|
||||||
Operators
|
Operators
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def xcom_push(**kwargs):
|
def xcom_push(**kwargs):
|
||||||
# Pushes action XCom
|
# Pushes action XCom
|
||||||
kwargs['ti'].xcom_push(key='action',
|
kwargs['ti'].xcom_push(key='action',
|
||||||
|
@ -19,6 +19,7 @@ from shipyard_airflow.errors import DatabaseError
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DbAccess:
|
class DbAccess:
|
||||||
"""
|
"""
|
||||||
Base class for simple database access
|
Base class for simple database access
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
class AirflowStateError(Exception):
|
class AirflowStateError(Exception):
|
||||||
def __init__(self, message=""):
|
def __init__(self, message=""):
|
||||||
"""
|
"""
|
||||||
|
@ -28,6 +28,7 @@ from shipyard_airflow.db.common_db import DbAccess
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class ShipyardDbAccess(DbAccess):
|
class ShipyardDbAccess(DbAccess):
|
||||||
"""
|
"""
|
||||||
Shipyard database access
|
Shipyard database access
|
||||||
|
@ -70,6 +70,7 @@ def format_resp(req,
|
|||||||
resp.content_type = 'application/json'
|
resp.content_type = 'application/json'
|
||||||
resp.status = status_code
|
resp.status = status_code
|
||||||
|
|
||||||
|
|
||||||
def default_error_serializer(req, resp, exception):
|
def default_error_serializer(req, resp, exception):
|
||||||
"""
|
"""
|
||||||
Writes the default error message body, when we don't handle it otherwise
|
Writes the default error message body, when we don't handle it otherwise
|
||||||
@ -84,6 +85,7 @@ def default_error_serializer(req, resp, exception):
|
|||||||
error_list=[{'message': exception.description}]
|
error_list=[{'message': exception.description}]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def default_exception_handler(ex, req, resp, params):
|
def default_exception_handler(ex, req, resp, params):
|
||||||
"""
|
"""
|
||||||
Catch-all execption handler for standardized output.
|
Catch-all execption handler for standardized output.
|
||||||
@ -110,6 +112,7 @@ class AppError(Exception):
|
|||||||
"""
|
"""
|
||||||
Base error containing enough information to make a shipyard formatted error
|
Base error containing enough information to make a shipyard formatted error
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
title='Internal Server Error',
|
title='Internal Server Error',
|
||||||
description=None,
|
description=None,
|
||||||
@ -146,6 +149,7 @@ class AirflowError(AppError):
|
|||||||
"""
|
"""
|
||||||
An error to handle errors returned by the Airflow API
|
An error to handle errors returned by the Airflow API
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, description=None, error_list=None):
|
def __init__(self, description=None, error_list=None):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
title='Error response from Airflow',
|
title='Error response from Airflow',
|
||||||
@ -155,10 +159,12 @@ class AirflowError(AppError):
|
|||||||
retry=False
|
retry=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DatabaseError(AppError):
|
class DatabaseError(AppError):
|
||||||
"""
|
"""
|
||||||
An error to handle general api errors.
|
An error to handle general api errors.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
description=None,
|
description=None,
|
||||||
error_list=None,
|
error_list=None,
|
||||||
@ -178,6 +184,7 @@ class ApiError(AppError):
|
|||||||
"""
|
"""
|
||||||
An error to handle general api errors.
|
An error to handle general api errors.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
description="",
|
description="",
|
||||||
error_list=None,
|
error_list=None,
|
||||||
@ -197,6 +204,7 @@ class InvalidFormatError(AppError):
|
|||||||
"""
|
"""
|
||||||
An exception to cover invalid input formatting
|
An exception to cover invalid input formatting
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, title, description="Not Specified", error_list=None):
|
def __init__(self, title, description="Not Specified", error_list=None):
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
|
@ -430,6 +430,7 @@ class DryDockOperator(BaseOperator):
|
|||||||
else:
|
else:
|
||||||
return 'task_failed'
|
return 'task_failed'
|
||||||
|
|
||||||
|
|
||||||
class DryDockClientPlugin(AirflowPlugin):
|
class DryDockClientPlugin(AirflowPlugin):
|
||||||
name = "drydock_client_plugin"
|
name = "drydock_client_plugin"
|
||||||
operators = [DryDockOperator]
|
operators = [DryDockOperator]
|
||||||
|
@ -780,4 +780,3 @@ class REST_API_Plugin(AirflowPlugin):
|
|||||||
executors = []
|
executors = []
|
||||||
admin_views = [rest_api_view]
|
admin_views = [rest_api_view]
|
||||||
menu_links = []
|
menu_links = []
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import pytest
|
|||||||
|
|
||||||
from shipyard_airflow.conf import config
|
from shipyard_airflow.conf import config
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def setup_config():
|
def setup_config():
|
||||||
"""
|
"""
|
||||||
|
@ -142,6 +142,7 @@ def tasks_db():
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def airflow_stub(**kwargs):
|
def airflow_stub(**kwargs):
|
||||||
"""
|
"""
|
||||||
asserts that the airflow invocation method was called with the right
|
asserts that the airflow invocation method was called with the right
|
||||||
@ -152,12 +153,14 @@ def airflow_stub(**kwargs):
|
|||||||
print(kwargs)
|
print(kwargs)
|
||||||
return '2017-09-06 14:10:08.528402'
|
return '2017-09-06 14:10:08.528402'
|
||||||
|
|
||||||
|
|
||||||
def insert_action_stub(**kwargs):
|
def insert_action_stub(**kwargs):
|
||||||
"""
|
"""
|
||||||
asserts that the insert action was called with the right parameters
|
asserts that the insert action was called with the right parameters
|
||||||
"""
|
"""
|
||||||
assert kwargs['action']
|
assert kwargs['action']
|
||||||
|
|
||||||
|
|
||||||
def audit_control_command_db(action_audit):
|
def audit_control_command_db(action_audit):
|
||||||
"""
|
"""
|
||||||
Stub for inserting the invoke record
|
Stub for inserting the invoke record
|
||||||
@ -167,6 +170,7 @@ def audit_control_command_db(action_audit):
|
|||||||
|
|
||||||
context = ShipyardRequestContext()
|
context = ShipyardRequestContext()
|
||||||
|
|
||||||
|
|
||||||
def test_get_all_actions():
|
def test_get_all_actions():
|
||||||
"""
|
"""
|
||||||
Tests the main response from get all actions
|
Tests the main response from get all actions
|
||||||
@ -188,6 +192,7 @@ def test_get_all_actions():
|
|||||||
assert len(action['steps']) == 3
|
assert len(action['steps']) == 3
|
||||||
assert action['dag_status'] == 'SUCCESS'
|
assert action['dag_status'] == 'SUCCESS'
|
||||||
|
|
||||||
|
|
||||||
def test_create_action():
|
def test_create_action():
|
||||||
action_resource = ActionsResource()
|
action_resource = ActionsResource()
|
||||||
action_resource.get_all_actions_db = actions_db
|
action_resource.get_all_actions_db = actions_db
|
||||||
|
@ -47,6 +47,7 @@ def actions_db(action_id):
|
|||||||
'context_marker': '8-4-4-4-12a'
|
'context_marker': '8-4-4-4-12a'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def control_dag_run(dag_id,
|
def control_dag_run(dag_id,
|
||||||
execution_date,
|
execution_date,
|
||||||
expected_state,
|
expected_state,
|
||||||
@ -56,9 +57,11 @@ def control_dag_run(dag_id,
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def audit_control_command_db(action_audit):
|
def audit_control_command_db(action_audit):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_get_action():
|
def test_get_action():
|
||||||
"""
|
"""
|
||||||
Tests the main response from get all actions
|
Tests the main response from get all actions
|
||||||
|
@ -20,6 +20,7 @@ DATE_TWO = datetime(2017, 9, 13, 11, 13, 5, 57000)
|
|||||||
DATE_ONE_STR = DATE_ONE.strftime('%Y-%m-%dT%H:%M:%S')
|
DATE_ONE_STR = DATE_ONE.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
DATE_TWO_STR = DATE_TWO.strftime('%Y-%m-%dT%H:%M:%S')
|
DATE_TWO_STR = DATE_TWO.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
|
||||||
|
|
||||||
def actions_db(action_id):
|
def actions_db(action_id):
|
||||||
"""
|
"""
|
||||||
replaces the actual db call
|
replaces the actual db call
|
||||||
@ -35,6 +36,7 @@ def actions_db(action_id):
|
|||||||
'context_marker': '8-4-4-4-12a'
|
'context_marker': '8-4-4-4-12a'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def dag_runs_db(dag_id, execution_date):
|
def dag_runs_db(dag_id, execution_date):
|
||||||
"""
|
"""
|
||||||
replaces the actual db call
|
replaces the actual db call
|
||||||
@ -49,6 +51,7 @@ def dag_runs_db(dag_id, execution_date):
|
|||||||
'end_date': DATE_ONE
|
'end_date': DATE_ONE
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
def tasks_db(dag_id, execution_date):
|
def tasks_db(dag_id, execution_date):
|
||||||
"""
|
"""
|
||||||
replaces the actual db call
|
replaces the actual db call
|
||||||
@ -98,6 +101,7 @@ def tasks_db(dag_id, execution_date):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_validations(action_id):
|
def get_validations(action_id):
|
||||||
"""
|
"""
|
||||||
Stub to return validations
|
Stub to return validations
|
||||||
@ -111,6 +115,7 @@ def get_validations(action_id):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_ac_audit(action_id):
|
def get_ac_audit(action_id):
|
||||||
"""
|
"""
|
||||||
Stub to return command audit response
|
Stub to return command audit response
|
||||||
@ -132,6 +137,7 @@ def get_ac_audit(action_id):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_get_action():
|
def test_get_action():
|
||||||
"""
|
"""
|
||||||
Tests the main response from get all actions
|
Tests the main response from get all actions
|
||||||
|
@ -38,6 +38,7 @@ def actions_db(action_id):
|
|||||||
'context_marker': '8-4-4-4-12a'
|
'context_marker': '8-4-4-4-12a'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def tasks_db(dag_id, execution_date):
|
def tasks_db(dag_id, execution_date):
|
||||||
"""
|
"""
|
||||||
replaces the actual db call
|
replaces the actual db call
|
||||||
@ -87,6 +88,7 @@ def tasks_db(dag_id, execution_date):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_get_action_steps():
|
def test_get_action_steps():
|
||||||
"""
|
"""
|
||||||
Tests the main response from get all actions
|
Tests the main response from get all actions
|
||||||
|
@ -17,6 +17,7 @@ from shipyard_airflow.control.actions_validations_id_api import (
|
|||||||
)
|
)
|
||||||
from shipyard_airflow.errors import ApiError
|
from shipyard_airflow.errors import ApiError
|
||||||
|
|
||||||
|
|
||||||
def actions_db(action_id):
|
def actions_db(action_id):
|
||||||
"""
|
"""
|
||||||
replaces the actual db call
|
replaces the actual db call
|
||||||
@ -35,6 +36,7 @@ def actions_db(action_id):
|
|||||||
'context_marker': '8-4-4-4-12a'
|
'context_marker': '8-4-4-4-12a'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_validations(validation_id):
|
def get_validations(validation_id):
|
||||||
"""
|
"""
|
||||||
Stub to return validations
|
Stub to return validations
|
||||||
@ -49,6 +51,7 @@ def get_validations(validation_id):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def test_get_action_validation():
|
def test_get_action_validation():
|
||||||
"""
|
"""
|
||||||
Tests the main response from get all actions
|
Tests the main response from get all actions
|
||||||
|
@ -98,6 +98,7 @@ def test_find_conflicting_dag():
|
|||||||
assert cco.find_conflicting_dag('buffalo') != 'monkey'
|
assert cco.find_conflicting_dag('buffalo') != 'monkey'
|
||||||
assert cco.find_conflicting_dag('buffalo') == 'chicken'
|
assert cco.find_conflicting_dag('buffalo') == 'chicken'
|
||||||
|
|
||||||
|
|
||||||
def test_execute_exception():
|
def test_execute_exception():
|
||||||
"""
|
"""
|
||||||
Run the whole execute function for testing
|
Run the whole execute function for testing
|
||||||
@ -114,6 +115,7 @@ def test_execute_exception():
|
|||||||
except AirflowException as airflow_exception:
|
except AirflowException as airflow_exception:
|
||||||
assert 'Aborting run' in airflow_exception.args[0]
|
assert 'Aborting run' in airflow_exception.args[0]
|
||||||
|
|
||||||
|
|
||||||
def test_execute_success():
|
def test_execute_success():
|
||||||
"""
|
"""
|
||||||
Run the whole execute function for testing - successfully!
|
Run the whole execute function for testing - successfully!
|
||||||
|
2
tox.ini
2
tox.ini
@ -28,7 +28,7 @@ commands = oslopolicy-sample-generator --config-file=generator/policy-generator.
|
|||||||
# NOTE(Bryan Strassner) ignoring F841 because of the airflow example pattern
|
# NOTE(Bryan Strassner) ignoring F841 because of the airflow example pattern
|
||||||
# of naming variables even if they aren't used for DAGs and Operators.
|
# of naming variables even if they aren't used for DAGs and Operators.
|
||||||
# Doing so adds readability and context in this case.
|
# Doing so adds readability and context in this case.
|
||||||
ignore = E302,H306,D100,D101,D102,F841
|
ignore = F841
|
||||||
# NOTE(Bryan Strassner) excluding 3rd party and generated code that is brought into the
|
# NOTE(Bryan Strassner) excluding 3rd party and generated code that is brought into the
|
||||||
# codebase.
|
# codebase.
|
||||||
exclude = *plugins/rest_api_plugin.py,*lib/python*,*egg,.git*,*.md,.tox*,alembic/env.py,build/*
|
exclude = *plugins/rest_api_plugin.py,*lib/python*,*egg,.git*,*.md,.tox*,alembic/env.py,build/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user