#NEWLINE# @ fixture_generator ( Case , CaseVersion , CaseStep , CaseAttachment , requires = [ 'core.sample_products' , 'tags.sample_tags' , 'core.sample_users' ] ) #NEWLINE# def sample_cases( ) : #NEWLINE# #INDENT# manager = User . objects . get ( username = 'manager' ) #NEWLINE# creator = User . objects . get ( username = 'creator' ) #NEWLINE# mt = Product . objects . get ( name = 'MozTrap' ) #NEWLINE# mt6 = mt . versions . get ( version = '0.6' ) #NEWLINE# mt7 = mt . versions . get ( version = '0.7' ) #NEWLINE# mt8 = mt . versions . get ( version = '0.8' ) #NEWLINE# registration = Tag . objects . get ( name = 'registration' ) #NEWLINE# login = Case . objects . create ( product = mt , user = manager , priority = 1 ) #NEWLINE# login_data = { #NEWLINE# #INDENT# 'name' : 'Can log in.' , #NEWLINE# 'case' : login , #NEWLINE# 'description' : 'A user can log in to the app.' , #NEWLINE# 'status' : CaseVersion . STATUS . active , #NEWLINE# 'user' : manager , #NEWLINE# #UNINDENT# } #NEWLINE# login_steps = [ { #NEWLINE# #INDENT# 'instruction' : 'Click the login link in the upper right.' , #NEWLINE# 'expected' : 'See a form with username and password fields.' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'instruction' : 'Fill in a valid username and password, submit.' , #NEWLINE# 'expected' : 'See a welcome message in the upper right.' , #NEWLINE# #UNINDENT# } ] #NEWLINE# for pv in [ mt6 , mt7 , mt8 ] : #NEWLINE# #INDENT# cv = CaseVersion . objects . create ( ** dict ( login_data , productversion = pv ) ) #NEWLINE# for ( i , step_data ) in enumerate ( login_steps ) : #NEWLINE# #INDENT# CaseStep . objects . create ( ** dict ( step_data , caseversion = cv , number = i , user = manager ) ) #NEWLINE# #UNINDENT# #UNINDENT# register = Case . objects . create ( product = mt , user = creator , priority = 2 ) #NEWLINE# register_data = { #NEWLINE# #INDENT# 'name' : 'Can register.' , #NEWLINE# 'case' : register , #NEWLINE# 'description' : 'A new user can register for the app.' , #NEWLINE# 'status' : CaseVersion . STATUS . active , #NEWLINE# 'user' : creator , #NEWLINE# #UNINDENT# } #NEWLINE# register_steps = [ { #NEWLINE# #INDENT# 'instruction' : 'Click the register link in the upper right.' , #NEWLINE# 'expected' : 'See a user registration form.' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'instruction' : 'Fill in all fields, submit.' , #NEWLINE# 'expected' : 'Receive a verification email.' , #NEWLINE# #UNINDENT# } ] #NEWLINE# for pv in [ mt7 , mt8 ] : #NEWLINE# #INDENT# cv = CaseVersion . objects . create ( ** dict ( register_data , productversion = pv ) ) #NEWLINE# if ( pv is mt8 ) : #NEWLINE# #INDENT# cv . tags . add ( registration ) #NEWLINE# #UNINDENT# for ( i , step_data ) in enumerate ( register_steps , 1 ) : #NEWLINE# #INDENT# CaseStep . objects . create ( ** dict ( step_data , caseversion = ff9 , number = i , user = creator ) ) #NEWLINE# #UNINDENT# for env in cv . environments . all ( ) : #NEWLINE# #INDENT# if any ( [ ( el . name == 'Mandarin' ) for el in env . ordered_elements ( ) ] ) : #NEWLINE# #INDENT# cv . environments . remove ( env ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ff = Product . objects . get ( name = 'Firefox' ) #NEWLINE# ff9 = ff . versions . get ( version = '9' ) #NEWLINE# ff10 = ff . versions . get ( version = '10' ) #NEWLINE# key = Tag . objects . get ( name = 'key' ) #NEWLINE# fast = Case . objects . create ( product = ff , user = creator , priority = 3 ) #NEWLINE# fast_data = { #NEWLINE# #INDENT# 'name' : 'It is fast.' , #NEWLINE# 'case' : fast , #NEWLINE# 'description' : "It's a fast browser." , #NEWLINE# 'user' : creator , #NEWLINE# #UNINDENT# } #NEWLINE# for pv in [ ff9 , ff10 ] : #NEWLINE# #INDENT# cv = CaseVersion . objects . create ( ** dict ( fast_data , productversion = pv ) ) #NEWLINE# cv . tags . add ( key )