#NEWLINE# def test_filter_by( self ) : #NEWLINE# #INDENT# names = cycle ( 'ABCD' ) #NEWLINE# os = cycle ( [ consts . RELEASE_OS . centos , consts . RELEASE_OS . ubuntu ] ) #NEWLINE# for i in range ( 12 ) : #NEWLINE# #INDENT# self . env . create_release ( name = names . next ( ) , operating_system = os . next ( ) ) #NEWLINE# #UNINDENT# query_filtered = objects . ReleaseCollection . filter_by ( objects . ReleaseCollection . all ( ) , name = 'A' , operating_system = consts . RELEASE_OS . centos ) #NEWLINE# self . assertIsInstance ( query_filtered , Query ) #NEWLINE# self . assertEqual ( objects . ReleaseCollection . count ( query_filtered ) , 3 ) #NEWLINE# for r in query_filtered : #NEWLINE# #INDENT# self . assertEqual ( r . name , 'A' ) #NEWLINE# self . assertEqual ( r . operating_system , consts . RELEASE_OS . centos ) #NEWLINE# #UNINDENT# iterable_filtered = objects . ReleaseCollection . filter_by ( list ( objects . ReleaseCollection . all ( ) ) , name = 'A' , operating_system = consts . RELEASE_OS . centos ) #NEWLINE# self . assertIsInstance ( iterable_filtered , ifilter ) #NEWLINE# self . assertEqual ( objects . ReleaseCollection . count ( iterable_filtered ) , 3 ) #NEWLINE# for r in iterable_filtered : #NEWLINE# #INDENT# self . assertEqual ( r . name , 'A' ) #NEWLINE# self . assertEqual ( r . operating_system , consts . RELEASE_OS . centos ) #NEWLINE# #UNINDENT# iterable_filtered = objects . ReleaseCollection . filter_by ( list ( ) , name = 'A' ) #NEWLINE# self . assertIsInstance ( iterable_filtered , ifilter ) #NEWLINE# self . assertEquals ( 0 , len ( list ( iterable_filtered ) ) )