def test_validate_deployment_action_full(self, *args): """Test the function that runs the validator class""" try: validate_deployment_action_full({ 'id': '123', 'name': 'deploy_site', 'committed_rev_id': 1 }) except Exception as ex: # any exception is a failure assert False, str(ex)
def test_validate_deployment_action_dep_strategy_exc_oth(self, *args): """Test the function that runs the validator class""" with pytest.raises(ApiError) as apie: validate_deployment_action_full({ 'id': '123', 'name': 'deploy_site', 'committed_rev_id': 1 }) assert apie.value.description == 'InvalidConfigurationDocuments' assert apie.value.error_list[0]['name'] == ( 'DocumentValidationProcessingError')
def test_validate_deployment_action_full_missing_dep_strat(self, *args): """Test the function that runs the validator class with a missing deployment strategy - specified, but not present """ with pytest.raises(ApiError) as apie: validate_deployment_action_full({ 'id': '123', 'name': 'deploy_site', 'committed_rev_id': 1 }) assert apie.value.description == 'InvalidConfigurationDocuments' assert apie.value.error_list[0]['name'] == 'DocumentNotFoundError'
def test_validate_deployment_action_full_cycle(self, *args): """Test the function that runs the validator class with a deployment strategy that has a cycle in the groups """ with pytest.raises(ApiError) as apie: validate_deployment_action_full({ 'id': '123', 'name': 'deploy_site', 'committed_rev_id': 1 }) assert apie.value.description == 'InvalidConfigurationDocuments' assert ('The following are involved in a circular dependency:' ) in apie.value.error_list[0]['diagnostic']
def test_validate_deployment_action_full_default_dep_strat(self, *args): """Test the function that runs the validator class with a defaulted deployment strategy (not specified) """ try: validate_deployment_action_full({ 'id': '123', 'name': 'deploy_site', 'committed_rev_id': 1 }) except Exception: # any exception is a failure assert False
def test_validate_deployment_action_full_continue_failure(self, *args): """Test the function that runs the validator class with a missing deployment strategy (not specified), but continue-on-fail specified """ try: validate_deployment_action_full({ 'id': '123', 'name': 'deploy_site', 'committed_rev_id': 1, 'parameters': { 'continue-on-fail': 'true' } }) except Exception: # any exception is a failure assert False
def test_validate_deployment_action_dep_strategy_exceptions(self, *args): """Test the function that runs the validator class for exceptions""" to_catch = [ InvalidDeploymentGroupNodeLookupError, InvalidDeploymentGroupError, DeploymentGroupCycleError ] for exc in to_catch: with mock.patch( "shipyard_airflow.control.validators." "validate_deployment_strategy._get_deployment_group_manager", side_effect=exc()): with pytest.raises(ApiError) as apie: validate_deployment_action_full({ 'id': '123', 'name': 'deploy_site', 'committed_rev_id': 1 }) assert apie.value.description == 'InvalidConfigurationDocuments' assert apie.value.error_list[0]['name'] == (exc.__name__)