#NEWLINE# def test_create_groups( self ) : #NEWLINE# #INDENT# p = df . Pipeline ( 'DirectPipelineRunner' ) #NEWLINE# group_ids_pcoll = ( p | df . Create ( 'create_group_ids' , [ 'A' , 'B' , 'C' ] ) ) #NEWLINE# corpus_pcoll = ( p | df . Create ( 'create_corpus' , [ { #NEWLINE# #INDENT# 'f' : 'corpus1' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'f' : 'corpus2' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'f' : 'corpus3' , #NEWLINE# #UNINDENT# } ] ) ) #NEWLINE# words_pcoll = ( p | df . Create ( 'create_words' , [ { #NEWLINE# #INDENT# 'f' : 'word1' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'f' : 'word2' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'f' : 'word3' , #NEWLINE# #UNINDENT# } ] ) ) #NEWLINE# ignore_corpus_pcoll = ( p | df . Create ( 'create_ignore_corpus' , [ 'corpus1' ] ) ) #NEWLINE# ignore_word_pcoll = ( p | df . Create ( 'create_ignore_word' , [ 'word1' ] ) ) #NEWLINE# groups = bigquery_side_input . create_groups ( group_ids_pcoll , corpus_pcoll , words_pcoll , ignore_corpus_pcoll , ignore_word_pcoll ) #NEWLINE# def group_matcher( actual ) : #NEWLINE# #INDENT# self . assertEqual ( len ( actual ) , 3 ) #NEWLINE# for group in actual : #NEWLINE# #INDENT# self . assertEqual ( len ( group ) , 3 ) #NEWLINE# self . assertTrue ( group [ 1 ] . startswith ( 'corpus' ) ) #NEWLINE# self . assertNotEqual ( group [ 1 ] , 'corpus1' ) #NEWLINE# self . assertTrue ( group [ 2 ] . startswith ( 'word' ) ) #NEWLINE# self . assertNotEqual ( group [ 2 ] , 'word1' ) #NEWLINE# #UNINDENT# #UNINDENT# df . assert_that ( groups , group_matcher ) #NEWLINE# p . run ( )