#NEWLINE# def test_m2m_and_m2o( self ) : #NEWLINE# #INDENT# r = User . objects . create ( username = 'russell' ) #NEWLINE# g = User . objects . create ( username = 'gustav' ) #NEWLINE# i1 = Issue ( num = 1 ) #NEWLINE# i1 . client = r #NEWLINE# i1 . save ( ) #NEWLINE# i2 = Issue ( num = 2 ) #NEWLINE# i2 . client = r #NEWLINE# i2 . save ( ) #NEWLINE# i2 . cc . add ( r ) #NEWLINE# i3 = Issue ( num = 3 ) #NEWLINE# i3 . client = g #NEWLINE# i3 . save ( ) #NEWLINE# i3 . cc . add ( r ) #NEWLINE# self . assertQuerysetEqual ( Issue . objects . filter ( client = r . id ) , [ 1 , 2 ] , ( lambda i : i . num ) ) #NEWLINE# self . assertQuerysetEqual ( Issue . objects . filter ( client = g . id ) , [ 3 ] , ( lambda i : i . num ) ) #NEWLINE# self . assertQuerysetEqual ( Issue . objects . filter ( cc__id__exact = g . id ) , [ ] ) #NEWLINE# self . assertQuerysetEqual ( Issue . objects . filter ( cc__id__exact = i3 . id ) , [ 2 , 3 ] , ( lambda i : i . num ) ) #NEWLINE# self . assertQuerysetEqual ( Issue . objects . filter ( ( Q ( cc__id__exact = r . id ) | Q ( client = r . id ) ) ) , [ 1 , 2 , 3 ] , ( lambda i : i . num ) ) #NEWLINE# self . assertQuerysetEqual ( ( Issue . objects . filter ( cc__id__exact = r . id ) | Issue . objects . filter ( client = r . id ) ) , [ 1 , 2 , 3 ] , ( lambda i : i . num ) ) #NEWLINE# self . assertQuerysetEqual ( Issue . objects . filter ( ( Q ( client = r . id ) | Q ( cc__id__exact = r . id ) ) ) , [ 1 , 2 , 3 ] , ( lambda i : i . num ) )