<s> from minicluster_testbase import MiniClusterTestBase <EOL> import os <EOL> class CatTest ( MiniClusterTestBase ) : <EOL> def test_cat_file_on_1_block ( self ) : <EOL> client_output = '<STR_LIT>' <EOL> for file_to_read in self . client . cat ( [ '<STR_LIT>' ] ) : <EOL> for data in file_to_read : <EOL> client_output += data <EOL> expected_output = self . cluster . cat ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected_output , client_output ) <EOL> def test_cat_file_on_1_block_checkcrc ( self ) : <EOL> client_output = '<STR_LIT>' <EOL> for file_to_read in self . client . cat ( [ '<STR_LIT>' ] , check_crc = True ) : <EOL> for data in file_to_read : <EOL> client_output += data <EOL> expected_output = self . cluster . cat ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected_output , client_output ) <EOL> def test_cat_file_on_2_blocks ( self ) : <EOL> self . _write_to_test_cluster ( '<STR_LIT>' , <NUM_LIT:10> , '<STR_LIT>' , <NUM_LIT:4> * <NUM_LIT> * <NUM_LIT> ) <EOL> client_output = '<STR_LIT>' <EOL> for file_to_read in self . client . cat ( [ '<STR_LIT>' ] ) : <EOL> for data in file_to_read : <EOL> client_output += data <EOL> expected_output = self . cluster . cat ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected_output , client_output ) <EOL> def test_cat_file_on_3_blocks ( self ) : <EOL> self . _write_to_test_cluster ( '<STR_LIT>' , <NUM_LIT:10> , '<STR_LIT>' , <NUM_LIT:3> * <NUM_LIT> * <NUM_LIT> ) <EOL> client_output = '<STR_LIT>' <EOL> for file_to_read in self . client . cat ( [ '<STR_LIT>' ] ) : <EOL> for data in file_to_read : <EOL> client_output += data <EOL> expected_output = self . cluster . cat ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected_output , client_output ) <EOL> def test_cat_file_on_exactly_1_block ( self ) : <EOL> self . _write_to_test_cluster ( '<STR_LIT>' , <NUM_LIT> , '<STR_LIT>' , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> ) <EOL> client_output = '<STR_LIT>' <EOL> for file_to_read in self . client . cat ( [ '<STR_LIT>' ] ) : <EOL> for data in file_to_read : <EOL> client_output += data <EOL> expected_output = self . cluster . cat ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected_output , client_output ) <EOL> def _write_to_test_cluster ( self , testfile , times , dst , block_size = <NUM_LIT> ) : <EOL> testfiles_path = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , "<STR_LIT>" ) <EOL> f = open ( '<STR_LIT>' . join ( [ testfiles_path , testfile ] ) ) <EOL> p = self . cluster . put_subprocess ( '<STR_LIT:->' , dst , block_size ) <EOL> for _ in xrange ( times ) : <EOL> f . seek ( <NUM_LIT:0> ) <EOL> for line in f . readlines ( ) : <EOL> print >> p . stdin , line <EOL> p . communicate ( ) </s>
