<s> import re <EOL> import unittest2 <EOL> from minicluster_testbase import MiniClusterTestBase <EOL> from snakebite . formatter import format_fs_stats <EOL> class DfTest ( MiniClusterTestBase ) : <EOL> def test_df ( self ) : <EOL> client_output = self . client . df ( ) <EOL> expected_output = self . cluster . df ( "<STR_LIT:/>" ) . split ( "<STR_LIT:\n>" ) [ <NUM_LIT:1> ] <EOL> ( filesystem , capacity , used , remaining , pct ) = re . split ( "<STR_LIT>" , expected_output ) <EOL> self . assertEqual ( filesystem , client_output [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( long ( capacity ) , client_output [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( long ( used ) , client_output [ "<STR_LIT>" ] ) <EOL> class StatsMock ( dict ) : <EOL> def __init__ ( self , capacity , <EOL> used , <EOL> remaining , <EOL> under_replicated , <EOL> corrupted_blocks , <EOL> missing_blocks , <EOL> filesystem ) : <EOL> super ( StatsMock , self ) . __init__ ( { "<STR_LIT>" : capacity , <EOL> "<STR_LIT>" : used , <EOL> "<STR_LIT>" : remaining , <EOL> "<STR_LIT>" : under_replicated , <EOL> "<STR_LIT>" : corrupted_blocks , <EOL> "<STR_LIT>" : missing_blocks , <EOL> "<STR_LIT>" : filesystem } ) <EOL> class DfFormatTest ( unittest2 . TestCase ) : <EOL> def test_middle ( self ) : <EOL> fake = StatsMock ( <NUM_LIT:100> , <NUM_LIT:50> , <NUM_LIT:50> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> output = format_fs_stats ( fake ) . next ( ) . split ( '<STR_LIT:\n>' ) <EOL> stats = output [ <NUM_LIT:1> ] . split ( ) <EOL> self . assertEqual ( stats [ <NUM_LIT:4> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( stats [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> def test_frag ( self ) : <EOL> fake = StatsMock ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> output = format_fs_stats ( fake ) . next ( ) . split ( '<STR_LIT:\n>' ) <EOL> stats = output [ <NUM_LIT:1> ] . split ( ) <EOL> self . assertEqual ( stats [ <NUM_LIT:4> ] , "<STR_LIT>" ) <EOL> def test_zero_size ( self ) : <EOL> fake = StatsMock ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> output = format_fs_stats ( fake ) . next ( ) . split ( '<STR_LIT:\n>' ) <EOL> stats = output [ <NUM_LIT:1> ] . split ( ) <EOL> self . assertEqual ( stats [ <NUM_LIT:4> ] , "<STR_LIT>" ) <EOL> def test_corrupted_zero_size ( self ) : <EOL> fake = StatsMock ( <NUM_LIT:0> , <NUM_LIT:50> , <NUM_LIT:50> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> output = format_fs_stats ( fake ) . next ( ) . split ( '<STR_LIT:\n>' ) <EOL> stats = output [ <NUM_LIT:1> ] . split ( ) <EOL> self . assertEqual ( stats [ <NUM_LIT:4> ] , "<STR_LIT>" ) <EOL> def test_full_size ( self ) : <EOL> fake = StatsMock ( <NUM_LIT:50> , <NUM_LIT:50> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> output = format_fs_stats ( fake ) . next ( ) . split ( '<STR_LIT:\n>' ) <EOL> stats = output [ <NUM_LIT:1> ] . split ( ) <EOL> self . assertEqual ( stats [ <NUM_LIT:4> ] , "<STR_LIT>" ) </s>
