@@ -75,9 +75,106 @@ def test_create_new_pod(
7575 gpu_count = 1 ,
7676 support_public_ip = True ,
7777 ports = "22/tcp" ,
78+ encrypt_volume = False , # Accept the new default argument
7879 )
7980 mock_echo .assert_called_with ("Pod sample_id has been created." )
8081
82+ @patch ("runpod.cli.groups.pod.commands.click.prompt" )
83+ @patch ("runpod.cli.groups.pod.commands.click.confirm" )
84+ @patch ("runpod.cli.groups.pod.commands.click.echo" )
85+ @patch ("runpod.cli.groups.pod.commands.create_pod" )
86+ def test_create_new_pod_with_encrypt_volume (
87+ self , mock_create_pod , mock_echo , mock_confirm , mock_prompt
88+ ): # pylint: disable=too-many-arguments,line-too-long
89+ """
90+ Test create_new_pod with --encrypt-volume option
91+ """
92+ # Mock values
93+ mock_confirm .return_value = True # for the quick_launch option
94+ mock_prompt .return_value = "RunPod-CLI-Pod-Encrypted"
95+ mock_create_pod .return_value = {"id" : "encrypted_pod_id" }
96+
97+ runner = CliRunner ()
98+ result = runner .invoke (runpod_cli , ["pod" , "create" , "--encrypt-volume" ])
99+
100+ # Assertions
101+ assert result .exit_code == 0 , result .exception
102+ mock_prompt .assert_called_once_with ("Enter pod name" , default = "RunPod-CLI-Pod" )
103+ mock_echo .assert_called_with ("Pod encrypted_pod_id has been created." )
104+ mock_create_pod .assert_called_with (
105+ "RunPod-CLI-Pod-Encrypted" ,
106+ "runpod/base:0.0.0" ,
107+ "NVIDIA GeForce RTX 3090" ,
108+ gpu_count = 1 ,
109+ support_public_ip = True ,
110+ ports = "22/tcp" ,
111+ encrypt_volume = True , # This is the key assertion
112+ )
113+
114+ @patch ("runpod.cli.groups.pod.commands.click.prompt" )
115+ @patch ("runpod.cli.groups.pod.commands.click.confirm" )
116+ @patch ("runpod.cli.groups.pod.commands.click.echo" )
117+ @patch ("runpod.cli.groups.pod.commands.create_pod" )
118+ def test_create_new_pod_with_no_encrypt_volume (
119+ self , mock_create_pod , mock_echo , mock_confirm , mock_prompt
120+ ): # pylint: disable=too-many-arguments,line-too-long
121+ """
122+ Test create_new_pod with --no-encrypt-volume option
123+ """
124+ # Mock values
125+ mock_confirm .return_value = True # for the quick_launch option
126+ mock_prompt .return_value = "RunPod-CLI-Pod-No-Encryption"
127+ mock_create_pod .return_value = {"id" : "no_encryption_pod_id" }
128+
129+ runner = CliRunner ()
130+ result = runner .invoke (runpod_cli , ["pod" , "create" , "--no-encrypt-volume" ])
131+
132+ # Assertions
133+ assert result .exit_code == 0 , result .exception
134+ mock_prompt .assert_called_once_with ("Enter pod name" , default = "RunPod-CLI-Pod" )
135+ mock_echo .assert_called_with ("Pod no_encryption_pod_id has been created." )
136+ mock_create_pod .assert_called_with (
137+ "RunPod-CLI-Pod-No-Encryption" ,
138+ "runpod/base:0.0.0" ,
139+ "NVIDIA GeForce RTX 3090" ,
140+ gpu_count = 1 ,
141+ support_public_ip = True ,
142+ ports = "22/tcp" ,
143+ encrypt_volume = False , # This is the key assertion
144+ )
145+
146+ @patch ("runpod.cli.groups.pod.commands.click.prompt" )
147+ @patch ("runpod.cli.groups.pod.commands.click.confirm" )
148+ @patch ("runpod.cli.groups.pod.commands.click.echo" )
149+ @patch ("runpod.cli.groups.pod.commands.create_pod" )
150+ def test_create_new_pod_default_encrypt_volume (
151+ self , mock_create_pod , mock_echo , mock_confirm , mock_prompt
152+ ): # pylint: disable=too-many-arguments,line-too-long
153+ """
154+ Test create_new_pod with default encrypt_volume (should be False)
155+ """
156+ # Mock values
157+ mock_confirm .return_value = True # for the quick_launch option
158+ mock_prompt .return_value = "RunPod-CLI-Pod-Default"
159+ mock_create_pod .return_value = {"id" : "default_pod_id" }
160+
161+ runner = CliRunner ()
162+ result = runner .invoke (runpod_cli , ["pod" , "create" ])
163+
164+ # Assertions
165+ assert result .exit_code == 0 , result .exception
166+ mock_prompt .assert_called_once_with ("Enter pod name" , default = "RunPod-CLI-Pod" )
167+ mock_echo .assert_called_with ("Pod default_pod_id has been created." )
168+ mock_create_pod .assert_called_with (
169+ "RunPod-CLI-Pod-Default" ,
170+ "runpod/base:0.0.0" ,
171+ "NVIDIA GeForce RTX 3090" ,
172+ gpu_count = 1 ,
173+ support_public_ip = True ,
174+ ports = "22/tcp" ,
175+ encrypt_volume = False , # Default should be False
176+ )
177+
81178 @patch ("runpod.cli.groups.pod.commands.click.echo" )
82179 @patch ("runpod.cli.groups.pod.commands.ssh_cmd.SSHConnection" )
83180 def test_connect_to_pod (self , mock_ssh_connection , mock_echo ):
0 commit comments