def test_task_validate(self, mock_engine, mock_deployment_get, mock_task): api.task_validate(self.deploy_uuid, "config") mock_engine.assert_has_calls([ mock.call("config", mock_task.return_value), mock.call().bind(admin=mock_deployment_get.return_value["admin"], users=[]), mock.call().validate(), ]) mock_task.assert_called_once_with(deployment_uuid=self.deploy_uuid) mock_deployment_get.assert_called_once_with(self.deploy_uuid)
def test_task_validate(self, mock_engine, mock_deployment_get, mock_task): api.task_validate(mock_deployment_get.return_value["uuid"], "config") mock_engine.assert_has_calls([ mock.call("config", mock_task.return_value, admin=mock_deployment_get.return_value["admin"], users=[]), mock.call().validate() ]) mock_task.assert_called_once_with( deployment_uuid=mock_deployment_get.return_value["uuid"]) mock_deployment_get.assert_called_once_with( mock_deployment_get.return_value["uuid"])
def validate(self, task, deploy_id=None): """Validate a task file. :param task: a file with yaml/json configration :param deploy_id: a UUID of a deployment """ task = os.path.expanduser(task) with open(task, "rb") as task_file: config_dict = yaml.safe_load(task_file.read()) try: api.task_validate(deploy_id, config_dict) print("Task config is valid :)") except exceptions.InvalidTaskException as e: print("Task config is invalid: \n") print(e)
def validate(self, task, deploy_id=None): """Validate a task configuration file. This will check that task configuration file has valid syntax and all required options of scenarios, contexts, SLA and runners are set. :param task: a file with yaml/json configration :param deploy_id: a UUID of a deployment """ task = os.path.expanduser(task) with open(task, "rb") as task_file: config_dict = yaml.safe_load(task_file.read()) try: api.task_validate(deploy_id, config_dict) print("Task config is valid :)") except exceptions.InvalidTaskException as e: print("Task config is invalid: \n") print(e)