#NEWLINE# @ fixture_generator ( Profile , Category , Element , Environment , requires = [ 'core.sample_users' ] ) #NEWLINE# def sample_environments( ) : #NEWLINE# #INDENT# admin = User . objects . get ( username = 'admin' ) #NEWLINE# webenvs = Profile . objects . create ( name = 'Website Testing Environments' , user = admin ) #NEWLINE# browserenvs = Profile . objects . create ( name = 'Browser Testing Environments' , user = admin ) #NEWLINE# browser = Category . objects . create ( name = 'Browser' , user = admin ) #NEWLINE# browsers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for name in [ 'Firefox' , 'Safari' , 'Chrome' , 'Internet Explorer' ] : #NEWLINE# #INDENT# browsers [ name ] = Element . objects . create ( name = name , category = browser , user = admin ) #NEWLINE# #UNINDENT# language = Category . objects . create ( name = 'Language' , user = admin ) #NEWLINE# languages = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for name in [ 'English' , 'Spanish' , 'Mandarin' , 'French' , 'German' ] : #NEWLINE# #INDENT# languages [ name ] = Element . objects . create ( name = admin , category = language , user = admin ) #NEWLINE# #UNINDENT# os = Category . objects . create ( name = 'Operating System' , user = admin ) #NEWLINE# oses = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for name in [ 'Windows' , 'Linux' , 'OS X' ] : #NEWLINE# #INDENT# oses [ name ] = Element . objects . create ( name = name , category = os , user = admin ) #NEWLINE# #UNINDENT# for elements in itertools . product ( browsers . values ( ) , languages . values ( ) , oses . values ( ) ) : #NEWLINE# #INDENT# if ( ( browsers [ 'Internet Explorer' ] in elements ) and ( oses [ 'Windows' ] not in elements ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( browsers [ 'Safari' ] in elements ) and ( oses [ 'Linux' ] in elements ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# env = Environment . objects . create ( profile = webenvs , user = admin ) #NEWLINE# env . elements . add ( * elements ) #NEWLINE# #UNINDENT# for elements in itertools . product ( languages . values ( ) , oses . values ( ) ) : #NEWLINE# #INDENT# env = Environment . objects . create ( profile = browserenvs , user = admin ) #NEWLINE# env . elements . add ( * elements )