From 4bebd1387248e2381f36eea7611918885152de4d Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Fri, 18 Oct 2019 16:08:52 +0800 Subject: [PATCH] Fix wrong argument name in docstring and assert its value Signed-off-by: Chenxiong Qi --- module_build_service/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module_build_service/models.py b/module_build_service/models.py index 83caa79a..e3018db1 100644 --- a/module_build_service/models.py +++ b/module_build_service/models.py @@ -62,6 +62,8 @@ BUILD_STATES = { INVERSE_BUILD_STATES = {v: k for k, v in BUILD_STATES.items()} FAILED_STATES = (BUILD_STATES["failed"], BUILD_STATES["garbage"]) +STATE_TRANSITION_FAILURE_TYPES = ["unspec", "user", "infra"] + Contexts = namedtuple( "Contexts", "build_context runtime_context context build_context_no_bms") @@ -781,8 +783,11 @@ class ModuleBuild(MBSBase): :type conf: :class:`Config` :param int state: the state value to transition to. Refer to ``BUILD_STATES``. :param str state_reason: optional reason of why to transform to ``state``. - :param str failure_reason: optional failure type: 'unspec', 'user', 'infra' + :param str failure_type: optional failure type. Refer to constant + ``STATE_TRANSITION_FAILURE_TYPES`` for valid values. """ + assert failure_type in STATE_TRANSITION_FAILURE_TYPES + now = datetime.utcnow() old_state = self.state self.state = state