<s> from __future__ import absolute_import <EOL> import json <EOL> from changes . constants import Result , Status <EOL> from changes . testutils import APITestCase <EOL> class JobStepNeedsAbortTest ( APITestCase ) : <EOL> path = '<STR_LIT>' <EOL> def post ( self , jobstep_ids , ** kwargs ) : <EOL> params = { '<STR_LIT>' : jobstep_ids } <EOL> params . update ( kwargs ) <EOL> return self . client . post ( self . path , data = json . dumps ( params ) , content_type = '<STR_LIT:application/json>' ) <EOL> def test_none_needs_abort ( self ) : <EOL> project = self . create_project ( ) <EOL> build = self . create_build ( project ) <EOL> job = self . create_job ( build ) <EOL> jobphase = self . create_jobphase ( job ) <EOL> jobstep = self . create_jobstep ( jobphase ) <EOL> resp = self . post ( [ jobstep . id . hex ] ) <EOL> assert resp . status_code == <NUM_LIT:200> , resp <EOL> assert self . unserialize ( resp ) == { '<STR_LIT>' : [ ] } , resp . data <EOL> def test_several_needs_abort ( self ) : <EOL> project = self . create_project ( ) <EOL> build = self . create_build ( project ) <EOL> job = self . create_job ( build ) <EOL> jobphase = self . create_jobphase ( job ) <EOL> jobstep_ignored = self . create_jobstep ( jobphase ) <EOL> jobstep_finished_ignored = self . create_jobstep ( jobphase , status = Status . finished ) <EOL> jobstep1 = self . create_jobstep ( jobphase , status = Status . finished , result = Result . aborted ) <EOL> jobstep2 = self . create_jobstep ( jobphase , status = Status . finished , result = Result . failed , data = { '<STR_LIT>' : True } ) <EOL> resp = self . post ( [ step . id . hex for step in ( jobstep_ignored , jobstep_finished_ignored , jobstep1 , jobstep2 ) ] ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> data = self . unserialize ( resp ) [ '<STR_LIT>' ] <EOL> assert len ( data ) == <NUM_LIT:2> <EOL> assert set ( data ) == { jobstep1 . id . hex , jobstep2 . id . hex } </s>
