<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import httplib2 <EOL> from gslib import util <EOL> import gslib . tests . testcase as testcase <EOL> from gslib . tests . util import SetEnvironmentForTest <EOL> from gslib . util import CompareVersions <EOL> class TestUtil ( testcase . GsUtilUnitTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_MakeHumanReadable ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ** <NUM_LIT:2> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ** <NUM_LIT:3> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ** <NUM_LIT:3> * <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ** <NUM_LIT:4> * <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ** <NUM_LIT:5> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeHumanReadable ( <NUM_LIT> ** <NUM_LIT:6> ) , '<STR_LIT>' ) <EOL> def test_MakeBitsHumanReadable ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ** <NUM_LIT:2> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ** <NUM_LIT:3> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ** <NUM_LIT:3> * <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ** <NUM_LIT:4> * <NUM_LIT> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ** <NUM_LIT:5> ) , '<STR_LIT>' ) <EOL> self . assertEqual ( util . MakeBitsHumanReadable ( <NUM_LIT> ** <NUM_LIT:6> ) , '<STR_LIT>' ) <EOL> def test_HumanReadableToBytes ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT:1>' ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT:15> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT:15> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT:16> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:2> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:2> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:2> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:2> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:3> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:3> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:3> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:3> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:4> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:4> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:4> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:4> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:5> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:5> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:5> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:5> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:6> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:6> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:6> ) <EOL> self . assertEqual ( util . HumanReadableToBytes ( '<STR_LIT>' ) , <NUM_LIT> ** <NUM_LIT:6> ) <EOL> def test_CompareVersions ( self ) : <EOL> """<STR_LIT>""" <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT:2>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertTrue ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT:2>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertFalse ( g ) <EOL> self . assertFalse ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertTrue ( m ) <EOL> ( g , m ) = CompareVersions ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( g ) <EOL> self . assertFalse ( m ) <EOL> def _AssertProxyInfosEqual ( self , pi1 , pi2 ) : <EOL> self . assertEqual ( pi1 . proxy_type , pi2 . proxy_type ) <EOL> self . assertEqual ( pi1 . proxy_host , pi2 . proxy_host ) <EOL> self . assertEqual ( pi1 . proxy_port , pi2 . proxy_port ) <EOL> self . assertEqual ( pi1 . proxy_rdns , pi2 . proxy_rdns ) <EOL> self . assertEqual ( pi1 . proxy_user , pi2 . proxy_user ) <EOL> self . assertEqual ( pi1 . proxy_pass , pi2 . proxy_pass ) <EOL> def test_ProxyInfoFromEnvironmentVar ( self ) : <EOL> """<STR_LIT>""" <EOL> valid_variables = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if not util . IS_WINDOWS : <EOL> valid_variables . append ( '<STR_LIT>' ) <EOL> clear_dict = { } <EOL> for key in valid_variables : <EOL> clear_dict [ key ] = None <EOL> with SetEnvironmentForTest ( clear_dict ) : <EOL> for env_var in valid_variables : <EOL> for url_string in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> with SetEnvironmentForTest ( { env_var : url_string } ) : <EOL> self . _AssertProxyInfosEqual ( <EOL> util . ProxyInfoFromEnvironmentVar ( env_var ) , <EOL> httplib2 . ProxyInfo ( <EOL> httplib2 . socks . PROXY_TYPE_HTTP , '<STR_LIT>' , <EOL> <NUM_LIT> if env_var . lower ( ) . startswith ( '<STR_LIT>' ) else <NUM_LIT> ) ) <EOL> for other_env_var in valid_variables : <EOL> if other_env_var == env_var : continue <EOL> self . _AssertProxyInfosEqual ( <EOL> util . ProxyInfoFromEnvironmentVar ( other_env_var ) , <EOL> httplib2 . ProxyInfo ( httplib2 . socks . PROXY_TYPE_HTTP , None , <NUM_LIT:0> ) ) <EOL> for url_string in [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] : <EOL> with SetEnvironmentForTest ( { env_var : url_string } ) : <EOL> self . _AssertProxyInfosEqual ( <EOL> util . ProxyInfoFromEnvironmentVar ( env_var ) , <EOL> httplib2 . ProxyInfo ( httplib2 . socks . PROXY_TYPE_HTTP , '<STR_LIT>' , <EOL> <NUM_LIT:50> ) ) <EOL> for url_string in [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] : <EOL> with SetEnvironmentForTest ( { env_var : url_string } ) : <EOL> self . _AssertProxyInfosEqual ( <EOL> util . ProxyInfoFromEnvironmentVar ( env_var ) , <EOL> httplib2 . ProxyInfo ( httplib2 . socks . PROXY_TYPE_HTTP , <EOL> '<STR_LIT>' , <NUM_LIT:50> , proxy_user = '<STR_LIT:foo>' , <EOL> proxy_pass = '<STR_LIT:bar>' ) ) <EOL> for url_string in [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] : <EOL> with SetEnvironmentForTest ( { env_var : url_string } ) : <EOL> self . _AssertProxyInfosEqual ( <EOL> util . ProxyInfoFromEnvironmentVar ( env_var ) , <EOL> httplib2 . ProxyInfo ( httplib2 . socks . PROXY_TYPE_HTTP , '<STR_LIT>' , <EOL> <NUM_LIT:50> , proxy_pass = '<STR_LIT:bar>' ) ) <EOL> for env_var in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> for url_string in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> with SetEnvironmentForTest ( { env_var : url_string } ) : <EOL> self . _AssertProxyInfosEqual ( <EOL> util . ProxyInfoFromEnvironmentVar ( env_var ) , <EOL> httplib2 . ProxyInfo ( httplib2 . socks . PROXY_TYPE_HTTP , None , <NUM_LIT:0> ) ) </s>
