def test_main_args(self): mock_args = Mock(dry_run=False, verbose=0, prefix=None, key_file='kf', FILELIST_PATH=None, BUCKET_NAME='mybucket', LOCAL_PREFIX='/', PATH=['/foo']) with patch('%s.logger' % pbm, autospec=True): with patch.multiple(pbm, autospec=True, set_log_info=DEFAULT, set_log_debug=DEFAULT, read_filelist=DEFAULT, parse_args=DEFAULT, FileSyncer=DEFAULT, read_keyfile=DEFAULT) as mocks: mocks['parse_args'].return_value = mock_args mocks['read_keyfile'].return_value = 'mykeybinary' main(mock_args) assert mocks['set_log_info'].mock_calls == [] assert mocks['set_log_debug'].mock_calls == [] assert mocks['parse_args'].mock_calls == [] assert mocks['read_filelist'].mock_calls == [] assert mocks['read_keyfile'].mock_calls == [call('kf')] assert mocks['FileSyncer'].mock_calls == [ call('mybucket', prefix=None, dry_run=False, ssec_key='mykeybinary'), call().restore('/', ['/foo']) ]
def test_main_simple(self): mock_args = Mock(dry_run=False, verbose=0, prefix=None, key_file='kf', FILELIST_PATH=None, BUCKET_NAME='mybucket', LOCAL_PREFIX='/', PATH=['/some/path', '/other/path']) m_summary = Mock() m_summary.summary.return_value = 'foo' with patch('%s.logger' % pbm, autospec=True) as mocklogger: with patch.multiple(pbm, autospec=True, set_log_info=DEFAULT, set_log_debug=DEFAULT, read_filelist=DEFAULT, parse_args=DEFAULT, FileSyncer=DEFAULT, read_keyfile=DEFAULT) as mocks: mocks['parse_args'].return_value = mock_args mocks['read_keyfile'].return_value = 'mykeybinary' with patch.object(sys, 'argv', [ 'foo', '-f', 'kf', 'mybucket', '/', '/some/path', '/other/path' ]): main() assert mocks['set_log_info'].mock_calls == [] assert mocks['set_log_debug'].mock_calls == [] assert mocks['parse_args'].mock_calls == [ call(['-f', 'kf', 'mybucket', '/', '/some/path', '/other/path']) ] assert mocks['read_filelist'].mock_calls == [] assert mocks['read_keyfile'].mock_calls == [call('kf')] assert mocks['FileSyncer'].mock_calls == [ call('mybucket', prefix=None, dry_run=False, ssec_key='mykeybinary'), call().restore('/', ['/some/path', '/other/path']) ] assert mocklogger.mock_calls == []