#NEWLINE# def testParticipants( self ) : #NEWLINE# #INDENT# user1 = User ( username = 'user1' , email = 'email1@example.com' ) #NEWLINE# user1 . save ( ) #NEWLINE# user2 = User ( username = 'user2' , email = 'email2@example.com' ) #NEWLINE# user2 . save ( ) #NEWLINE# user3 = User ( username = 'user3' , email = 'email3@example.com' ) #NEWLINE# user3 . save ( ) #NEWLINE# anonymous_visitor1 = AnonymousVisitor ( ) #NEWLINE# anonymous_visitor1 . save ( ) #NEWLINE# anonymous_visitor2 = AnonymousVisitor ( ) #NEWLINE# anonymous_visitor2 . save ( ) #NEWLINE# anonymous_visitor3 = AnonymousVisitor ( ) #NEWLINE# anonymous_visitor3 . save ( ) #NEWLINE# experiment1 = Experiment ( name = 'Experiment 1' ) #NEWLINE# experiment1 . save ( ) #NEWLINE# experiment2 = Experiment ( name = 'Experiment 2' ) #NEWLINE# experiment2 . save ( ) #NEWLINE# participant11 = Participant ( user = user1 , experiment = experiment1 , group = Participant . CONTROL_GROUP ) #NEWLINE# participant11 . save ( ) #NEWLINE# participant12 = Participant ( user = user1 , experiment = experiment2 , group = Participant . TEST_GROUP ) #NEWLINE# participant12 . save ( ) #NEWLINE# participant21 = Participant ( user = user2 , experiment = user3 , group = Participant . CONTROL_GROUP ) #NEWLINE# participant21 . save ( ) #NEWLINE# participant22 = Participant ( user = user2 , experiment = experiment2 , group = Participant . CONTROL_GROUP ) #NEWLINE# participant22 . save ( ) #NEWLINE# self . assertRaises ( Exception , ( lambda : Participant ( user = user2 , experiment = experiment2 , group = Participant . TEST_GROUP ) . save ( ) ) ) #NEWLINE# participant31 = Participant ( anonymous_visitor = anonymous_visitor1 , experiment = experiment1 , group = Participant . CONTROL_GROUP ) #NEWLINE# participant31 . save ( ) #NEWLINE# participant32 = Participant ( anonymous_visitor = anonymous_visitor1 , experiment = experiment2 , group = Participant . TEST_GROUP ) #NEWLINE# participant32 . save ( ) #NEWLINE# participant42 = Participant ( anonymous_visitor = anonymous_visitor2 , experiment = experiment2 , group = Participant . CONTROL_GROUP ) #NEWLINE# participant42 . save ( ) #NEWLINE# self . assertRaises ( Exception , ( lambda : Participant ( anonymous_visitor = anonymous_visitor1 , experiment = experiment1 , group = Participant . TEST_GROUP ) . save ( ) ) ) #NEWLINE# self . assertRaises ( Exception , ( lambda : Participant ( experiment = experiment1 , group = Participant . TEST_GROUP ) . save ( ) ) ) #NEWLINE# self . assertRaises ( Exception , ( lambda : Participant ( user = user3 , anonymous_visitor = anonymous_visitor3 , experiment = experiment1 , group = Participant . TEST_GROUP ) ) ) #NEWLINE# self . assertRaises ( Exception , ( lambda : Participant ( user = user3 , experiment = experiment1 ) . save ( ) ) ) #NEWLINE# self . assertNotEquals ( participant11 . enrollment_date , None ) #NEWLINE# participant11 . enrollment_date = None #NEWLINE# self . assertRaises ( Exception , ( lambda : participant11 . save ( ) ) ) #NEWLINE# participant12 . group = None #NEWLINE# self . assertRaises ( Exception , ( lambda : participant12 . save ( ) ) )