def test_delete(self, mocked_delete): s3(["delete"]) mocked_delete.assert_called_with( False, None, False, [], [], "", False, False, False, False ) s3( [ "delete", "-P", "root", "-b", "kazhala", "-r", "-m", "111111", "010010", "-v", "-V", "--clean", "--deletemark", ] ) mocked_delete.assert_called_with( "root", "kazhala", True, [], [], "111111 010010", True, True, True, True )
def test_object(self, mocked_object): s3(["object"]) mocked_object.assert_called_with( False, None, False, False, False, [], [], False ) s3(["object", "-b", "hello", "-r", "-v", "-V", "-n"]) mocked_object.assert_called_with(False, "hello", True, True, True, [], [], True)
def test_bucket(self, mocked_bucket): s3(["bucket"]) mocked_bucket.assert_called_with( False, None, None, False, False, [], [], False, False ) s3(["bucket", "-b", "kazhala", "-t", "yes", "-r", "-s"]) mocked_bucket.assert_called_with( False, "kazhala", "yes", True, True, [], [], False, False )
def test_ls(self, mocked_ls): s3(["ls"]) mocked_ls.assert_called_with( False, False, False, False, False, False, False, False, False, None ) s3(["ls", "-P", "-v", "-d", "-b"]) mocked_ls.assert_called_with( True, True, True, True, False, False, False, False, False, None )
def test_download(self, mocked_download): s3(["download"]) mocked_download.assert_called_with( False, None, None, False, False, False, [], [], False, False ) s3(["download", "-r", "-R", "-s", "-e", "lol", "-v", "-H"]) mocked_download.assert_called_with( False, None, None, True, True, True, ["lol"], [], True, True ) s3(["download", "-P", "root", "-b", "kazhala-file"]) mocked_download.assert_called_with( "root", "kazhala-file", None, False, False, False, [], [], False, False )
def test_upload(self, mocked_upload): s3(["upload"]) mocked_upload.assert_called_with( False, None, [], False, False, False, False, [], [], False ) s3(["upload", "-P", "-b", "kazhala-file-transfer/", "-p", "hello.txt", "-E"]) mocked_upload.assert_called_with( True, "kazhala-file-transfer/", ["hello.txt"], False, False, False, False, [], [], True, ) s3( [ "upload", "-P", "root", "-r", "-R", "-H", "-s", "-e", "*.git", "*.lol", "-i", "hello.txt", ] ) mocked_upload.assert_called_with( "root", None, [], True, True, True, True, ["*.git", "*.lol"], ["hello.txt"], False, )
def main() -> None: """Entry function of the fzf.aws module.""" try: parser = argparse.ArgumentParser( description="An interactive aws cli experience powered by fzf.", prog="fzfaws", ) parser.add_argument( "-v", "--version", action="store_true", default=False, help="display the current version", ) parser.add_argument( "--copy-config", dest="copy_config", action="store_true", default=False, help= "copy the configuration file to $XDG_CONFIG_HOME/fzfaws/ or $HOME/.config/fzfaws/", ) subparsers = parser.add_subparsers(dest="subparser_name") subparsers.add_parser("cloudformation") subparsers.add_parser("ec2") subparsers.add_parser("s3") if len(sys.argv) < 2: parser.print_help() sys.exit(1) args = parser.parse_args([sys.argv[1]]) if args.copy_config: copy_config() sys.exit(0) elif args.version: version = pkg_resources.require("fzfaws")[0].version print("Current fzfaws version: %s" % version) sys.exit(0) fileloader = FileLoader() fileloader.load_config_file() argument_list = get_default_args(args.subparser_name, sys.argv[2:]) if args.subparser_name == "cloudformation": cloudformation(argument_list) elif args.subparser_name == "ec2": ec2(argument_list) elif args.subparser_name == "s3": s3(argument_list) except InvalidFileType: print("Selected file is not a valid file type") sys.exit(1) except SystemExit: raise except (KeyboardInterrupt, SystemError): sys.exit(1) except NoSelectionMade: print("No selection was made or the result was empty") sys.exit(1) except (ClientError, Exception) as e: print(e) sys.exit(1)
def test_presign(self, mocked_presign): s3(["presign"]) mocked_presign.assert_called_with(False, None, False, 3600) s3(["presign", "-e", "111111", "-v"]) mocked_presign.assert_called_with(False, None, True, 111111)