#NEWLINE# def test_container_state_good( self ) : #NEWLINE# #INDENT# 'Test that the finite state machine transitions with a good scheduler' #NEWLINE# url = '/v1/apps' #NEWLINE# response = self . client . post ( url , HTTP_AUTHORIZATION = 'token {}' . format ( self . token ) ) #NEWLINE# self . assertEqual ( response . status_code , 201 ) #NEWLINE# app_id = response . data [ 'id' ] #NEWLINE# app = App . objects . get ( id = app_id ) #NEWLINE# user = User . objects . get ( username = 'autotest' ) #NEWLINE# build = Build . objects . create ( owner = user , app = app , image = 'qwerty' ) #NEWLINE# release = Release . objects . create ( version = 2 , owner = user , app = app , config = app . config_set . latest ( ) , build = build ) #NEWLINE# c = Container . objects . create ( owner = user , app = app , release = release , type = 'web' , num = 1 ) #NEWLINE# self . assertEqual ( c . state , 'initialized' ) #NEWLINE# self . assertRaises ( TransitionError , ( lambda : c . start ( ) ) ) #NEWLINE# c . create ( ) #NEWLINE# self . assertEqual ( c . state , 'created' ) #NEWLINE# c . start ( ) #NEWLINE# self . assertEqual ( c . state , 'up' ) #NEWLINE# c . stop ( ) #NEWLINE# self . assertEqual ( c . state , 'down' ) #NEWLINE# c . destroy ( ) #NEWLINE# self . assertEqual ( c . state , 'destroyed' )