@@ -407,28 +407,34 @@ def test_publish_methods(
407407):
408408 variable_definition .variable_status = initial_status
409409 method_to_call = getattr (variable_definition , method_name )
410- if initial_status is VariableStatus .PUBLISHED_EXTERNAL :
410+ if initial_status == VariableStatus .PUBLISHED_EXTERNAL :
411411 # It doesn't make sense to publish other statuses internally
412412 with pytest .raises (ValueError , match = "That won't work here." ):
413413 method_to_call ()
414414 elif method_name == "publish_internal" :
415- if initial_status is VariableStatus .DRAFT :
416- # Normal publishing flow
415+ if initial_status == VariableStatus .DRAFT :
417416 method_to_call ()
418417 mock_update_draft .assert_called_once_with (
419418 UpdateDraft (variable_status = expected_status ),
420419 )
421420 mock_create_patch .assert_not_called ()
422- else :
423- # It doesn't make sense to publish other statuses internally
421+ if initial_status == VariableStatus . PUBLISHED_INTERNAL :
422+ # It doesn't make sense to publish internally already published internally
424423 with pytest .raises (ValueError , match = "That won't work here." ):
425424 method_to_call ()
426- else :
427- method_to_call ()
428- mock_update_draft .assert_not_called ()
429- mock_create_patch .assert_called_once_with (
430- CreatePatch (variable_status = VariableStatus .PUBLISHED_EXTERNAL ),
431- )
425+ elif method_name == "publish_external" :
426+ if initial_status == VariableStatus .PUBLISHED_INTERNAL :
427+ method_to_call ()
428+ mock_update_draft .assert_not_called ()
429+ mock_create_patch .assert_called_once_with (
430+ CreatePatch (variable_status = VariableStatus .PUBLISHED_EXTERNAL ),
431+ )
432+ if initial_status == VariableStatus .DRAFT :
433+ method_to_call ()
434+ mock_update_draft .assert_called_once_with (
435+ UpdateDraft (variable_status = expected_status ),
436+ )
437+ mock_create_patch .assert_not_called ()
432438
433439
434440def test_str (variable_definition ):
0 commit comments