<s> import mock <EOL> from cloudferry . lib . copy_engines import base <EOL> from cloudferry . lib . copy_engines import scp_copier <EOL> from cloudferry . lib . utils import sizeof_format <EOL> from tests . lib . copy_engines import test_base <EOL> class SspCopierTestCase ( test_base . BaseTestCase ) : <EOL> copier_class = scp_copier . ScpCopier <EOL> def test_run_scp_direct_true ( self ) : <EOL> with self . mock_runner ( ) as mock_runner : <EOL> with mock . patch . object ( <EOL> self . copier , '<STR_LIT>' , <EOL> side_effect = ( False , True , False ) ) as mock_verify : <EOL> self . cfg . set_override ( '<STR_LIT>' , <NUM_LIT:2> , '<STR_LIT>' ) <EOL> self . copier . run_scp ( ** self . data ) <EOL> self . assertEqual ( <NUM_LIT:2> , mock_runner . run . call_count ) <EOL> self . assertEqual ( <NUM_LIT:2> , mock_verify . call_count ) <EOL> mock_runner . reset_mock ( ) <EOL> mock_verify . reset_mock ( ) <EOL> self . cfg . set_override ( '<STR_LIT>' , <NUM_LIT:1> , '<STR_LIT>' ) <EOL> self . assertRaises ( base . FileCopyError , self . copier . run_scp , <EOL> ** self . data ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_run_scp_direct_false ( self , mock_run ) : <EOL> self . cfg . set_override ( '<STR_LIT>' , False , '<STR_LIT>' ) <EOL> with mock . patch . object ( self . copier , '<STR_LIT>' ) as mock_verify : <EOL> self . copier . run_scp ( ** self . data ) <EOL> self . assertCalledOnce ( mock_run ) <EOL> self . assertCalledOnce ( mock_verify ) <EOL> def test_transfer ( self ) : <EOL> with self . mock_runner ( ) as runner : <EOL> with mock . patch . object ( self . copier , '<STR_LIT>' ) as mock_verify : <EOL> self . cfg . set_override ( '<STR_LIT>' , <NUM_LIT:10> , '<STR_LIT>' ) <EOL> runner . run . return_value = sizeof_format . parse_size ( '<STR_LIT>' ) <EOL> with mock . patch . object ( self . copier , '<STR_LIT>' ) as mock_run_scp : <EOL> self . copier . transfer ( self . data ) <EOL> self . assertEqual ( <NUM_LIT:10> , mock_run_scp . call_count ) <EOL> self . assertCalledOnce ( mock_verify ) <EOL> def test_verify_size ( self ) : <EOL> self . cfg . set_override ( '<STR_LIT>' , False , <EOL> '<STR_LIT>' ) <EOL> with self . mock_runner ( ) as runner : <EOL> runner . run . side_effect = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertFalse ( self . copier . verify ( ** self . data ) ) <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertTrue ( self . copier . verify ( ** self . data ) ) <EOL> def test_verify_md5 ( self ) : <EOL> self . cfg . set_override ( '<STR_LIT>' , True , <EOL> '<STR_LIT>' ) <EOL> with self . mock_runner ( ) as runner : <EOL> runner . run . side_effect = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertFalse ( self . copier . verify ( ** self . data ) ) <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> runner . run . side_effect = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertTrue ( self . copier . verify ( ** self . data ) ) </s>
