<s> from changes . api . serializer import Crumbler , register <EOL> from changes . models . test import TestCase <EOL> @ register ( TestCase ) <EOL> class TestCaseCrumbler ( Crumbler ) : <EOL> def crumble ( self , instance , attrs ) : <EOL> return { <EOL> '<STR_LIT:id>' : instance . id . hex , <EOL> '<STR_LIT>' : instance . name_sha , <EOL> '<STR_LIT>' : { '<STR_LIT:id>' : instance . job_id . hex } , <EOL> '<STR_LIT>' : { '<STR_LIT:id>' : instance . project_id . hex } , <EOL> '<STR_LIT:name>' : instance . name , <EOL> '<STR_LIT>' : instance . package , <EOL> '<STR_LIT>' : instance . short_name , <EOL> '<STR_LIT>' : instance . duration or <NUM_LIT:0> , <EOL> '<STR_LIT:result>' : instance . result , <EOL> '<STR_LIT>' : instance . reruns or <NUM_LIT:0> , <EOL> '<STR_LIT>' : instance . date_created , <EOL> } <EOL> class TestCaseWithJobCrumbler ( TestCaseCrumbler ) : <EOL> def crumble ( self , instance , attrs ) : <EOL> data = super ( TestCaseWithJobCrumbler , self ) . crumble ( instance , attrs ) <EOL> data [ '<STR_LIT>' ] = instance . job <EOL> return data <EOL> class TestCaseWithOriginCrumbler ( TestCaseCrumbler ) : <EOL> def crumble ( self , instance , attrs ) : <EOL> data = super ( TestCaseWithOriginCrumbler , self ) . crumble ( instance , attrs ) <EOL> data [ '<STR_LIT>' ] = getattr ( instance , '<STR_LIT>' , None ) <EOL> return data <EOL> class GeneralizedTestCase ( Crumbler ) : <EOL> def crumble ( self , instance , attrs ) : <EOL> return { <EOL> '<STR_LIT>' : instance . name_sha , <EOL> '<STR_LIT>' : { '<STR_LIT:id>' : instance . project_id . hex } , <EOL> '<STR_LIT>' : instance . duration or <NUM_LIT:0> , <EOL> '<STR_LIT:name>' : instance . name , <EOL> '<STR_LIT>' : instance . package , <EOL> '<STR_LIT>' : instance . short_name , <EOL> } </s>
