state machine last CREATED state transition to COMPLETED
This commit is contained in:
parent
18c26a0c0e
commit
4569066024
@ -58,6 +58,18 @@ def _build_transitions(csp_stages):
|
||||
transitions = []
|
||||
states = []
|
||||
for stage_i, csp_stage in enumerate(csp_stages):
|
||||
# the last CREATED stage has a transition to COMPLETED
|
||||
if stage_i == len(csp_stages) - 1:
|
||||
transitions.append(
|
||||
dict(
|
||||
trigger="complete",
|
||||
source=compose_state(
|
||||
list(csp_stages)[stage_i], StageStates.CREATED
|
||||
),
|
||||
dest=FSMStates.COMPLETED,
|
||||
)
|
||||
)
|
||||
|
||||
for state in StageStates:
|
||||
states.append(
|
||||
dict(
|
||||
|
@ -125,6 +125,15 @@ class PortfolioStateMachine(
|
||||
self.fail_stage(stage)
|
||||
|
||||
elif state_obj.is_CREATED:
|
||||
# if last CREATED state then transition to COMPLETED
|
||||
if list(AzureStages)[-1].name == state_obj.name.split("_CREATED")[
|
||||
0
|
||||
] and "complete" in self.machine.get_triggers(state_obj.name):
|
||||
app.logger.info(
|
||||
"last stage completed. transitioning to COMPLETED state"
|
||||
)
|
||||
self.trigger("complete", **kwargs)
|
||||
|
||||
# the create trigger for the next stage should be in the available
|
||||
# triggers for the current state
|
||||
create_trigger = next(
|
||||
|
@ -116,6 +116,7 @@ def test_fsm_transition_start(mock_cloud_provider, portfolio: Portfolio):
|
||||
FSMStates.TENANT_ADMIN_OWNERSHIP_CREATED,
|
||||
FSMStates.TENANT_PRINCIPAL_OWNERSHIP_CREATED,
|
||||
FSMStates.BILLING_OWNER_CREATED,
|
||||
FSMStates.COMPLETED,
|
||||
]
|
||||
|
||||
if portfolio.csp_data is not None:
|
||||
@ -139,7 +140,7 @@ def test_fsm_transition_start(mock_cloud_provider, portfolio: Portfolio):
|
||||
"first_name": ppoc.first_name,
|
||||
"last_name": ppoc.last_name,
|
||||
"country_code": "US",
|
||||
"password_recovery_email_address": "email@example.com", # ppoc.email,
|
||||
"password_recovery_email_address": ppoc.email,
|
||||
"address": { # TODO: TBD if we're sourcing this from data or config
|
||||
"company_name": "",
|
||||
"address_line_1": "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user