88 ExtendedAction
99from gaiaflow .cli .commands .minikube import app as prod_app
1010from gaiaflow .cli .commands .minikube import load_imports
11+ from gaiaflow .managers .helpers import DockerHandlerMode
12+
1113
1214class TestGaiaflowProdCLI (unittest .TestCase ):
1315 def setUp (self ):
@@ -32,15 +34,11 @@ def test_start_command(self, mock_load_imports):
3234
3335 result = self .runner .invoke (prod_app , [
3436 "start" ,
35- "--path" , str (self .test_project_path ),
3637 "--force-new"
3738 ])
3839
3940 self .assertEqual (result .exit_code , 0 )
4041
41- self .mock_imports .create_gaiaflow_context_path .assert_called_once_with (
42- self .test_project_path
43- )
4442 self .mock_imports .gaiaflow_path_exists_in_state .assert_called_once_with (
4543 self .test_gaiaflow_path , True
4644 )
@@ -59,7 +57,6 @@ def test_start_command_exits_when_project_not_exists(self, mock_load_imports):
5957
6058 result = self .runner .invoke (prod_app , [
6159 "start" ,
62- "--path" , str (self .test_project_path )
6360 ])
6461
6562 self .assertEqual (result .exit_code , 0 )
@@ -73,7 +70,6 @@ def test_stop_command(self, mock_load_imports):
7370
7471 result = self .runner .invoke (prod_app , [
7572 "stop" ,
76- "--path" , str (self .test_project_path )
7773 ])
7874
7975 self .assertEqual (result .exit_code , 0 )
@@ -90,7 +86,6 @@ def test_restart_command(self, mock_load_imports):
9086
9187 result = self .runner .invoke (prod_app , [
9288 "restart" ,
93- "--path" , str (self .test_project_path ),
9489 "--force-new"
9590 ])
9691
@@ -100,6 +95,7 @@ def test_restart_command(self, mock_load_imports):
10095 gaiaflow_path = self .test_gaiaflow_path ,
10196 user_project_path = self .test_project_path ,
10297 action = BaseAction .RESTART ,
98+ force_new = True
10399 )
104100
105101 @patch ('gaiaflow.cli.commands.minikube.load_imports' )
@@ -108,7 +104,6 @@ def test_dockerize_command(self, mock_load_imports):
108104
109105 result = self .runner .invoke (prod_app , [
110106 "dockerize" ,
111- "--path" , str (self .test_project_path ),
112107 "--image-name" , "my-custom-image"
113108 ])
114109
@@ -118,8 +113,42 @@ def test_dockerize_command(self, mock_load_imports):
118113 gaiaflow_path = self .test_gaiaflow_path ,
119114 user_project_path = self .test_project_path ,
120115 action = ExtendedAction .DOCKERIZE ,
121- local = False ,
122- image_name = "my-custom-image"
116+ docker_handler_mode = DockerHandlerMode .MINIKUBE ,
117+ image_name = "my-custom-image" , dockerfile_path = None
118+ )
119+
120+ @patch ("gaiaflow.cli.commands.minikube.load_imports" )
121+ def test_list_images_command (self , mock_load_imports ):
122+ mock_load_imports .return_value = self .mock_imports
123+
124+ result = self .runner .invoke (
125+ prod_app , ["list-images" ]
126+ )
127+
128+ self .assertEqual (result .exit_code , 0 )
129+
130+ self .mock_imports .MinikubeManager .run .assert_called_once_with (
131+ gaiaflow_path = self .test_gaiaflow_path ,
132+ user_project_path = self .test_project_path ,
133+ action = ExtendedAction .LIST_IMAGES ,
134+ docker_handler_mode = DockerHandlerMode .MINIKUBE ,
135+ )
136+
137+ @patch ("gaiaflow.cli.commands.minikube.load_imports" )
138+ def test_remove_image_command (self , mock_load_imports ):
139+ mock_load_imports .return_value = self .mock_imports
140+
141+ result = self .runner .invoke (prod_app , ["remove-image" , "--image-name" ,
142+ "my-custom-image" ])
143+
144+ self .assertEqual (result .exit_code , 0 )
145+
146+ self .mock_imports .MinikubeManager .run .assert_called_once_with (
147+ gaiaflow_path = self .test_gaiaflow_path ,
148+ user_project_path = self .test_project_path ,
149+ action = ExtendedAction .REMOVE_IMAGE ,
150+ docker_handler_mode = DockerHandlerMode .MINIKUBE ,
151+ image_name = "my-custom-image" ,
123152 )
124153
125154 @patch ('gaiaflow.cli.commands.minikube.load_imports' )
@@ -128,7 +157,6 @@ def test_dockerize_command_with_default_image_name(self, mock_load_imports):
128157
129158 result = self .runner .invoke (prod_app , [
130159 "dockerize" ,
131- "--path" , str (self .test_project_path )
132160 ])
133161
134162 self .assertEqual (result .exit_code , 0 )
@@ -143,7 +171,6 @@ def test_create_config_command(self, mock_load_imports):
143171
144172 result = self .runner .invoke (prod_app , [
145173 "create-config" ,
146- "--path" , str (self .test_project_path )
147174 ])
148175
149176 self .assertEqual (result .exit_code , 0 )
@@ -160,7 +187,6 @@ def test_create_secret_command(self, mock_load_imports):
160187
161188 result = self .runner .invoke (prod_app , [
162189 "create-secret" ,
163- "--path" , str (self .test_project_path ),
164190 "--name" , "my-secret" ,
165191 "--data" , "key1=value1" ,
166192 "--data" , "key2=value2"
@@ -186,7 +212,6 @@ def test_cleanup_command(self, mock_load_imports):
186212
187213 result = self .runner .invoke (prod_app , [
188214 "cleanup" ,
189- "--path" , str (self .test_project_path )
190215 ])
191216
192217 self .assertEqual (result .exit_code , 0 )
@@ -203,14 +228,13 @@ def test_all_commands_handle_missing_project_gracefully(self, mock_load_imports)
203228 self .mock_imports .gaiaflow_path_exists_in_state .return_value = False
204229
205230 commands_and_args = [
206- ["start" , "--path" , str (self .test_project_path )],
207- ["stop" , "--path" , str (self .test_project_path )],
208- ["restart" , "--path" , str (self .test_project_path )],
209- ["dockerize" , "--path" , str (self .test_project_path )],
210- ["create-config" , "--path" , str (self .test_project_path )],
211- ["create-secret" , "--path" , str (self .test_project_path ),
212- "--name" , "test" , "--data" , "key=value" ],
213- ["cleanup" , "--path" , str (self .test_project_path )],
231+ ["start" ],
232+ ["stop" ],
233+ ["restart" ],
234+ ["dockerize" ],
235+ ["create-config" ],
236+ ["create-secret" , "--name" , "test" , "--data" , "key=value" ],
237+ ["cleanup" ],
214238 ]
215239
216240 for command_args in commands_and_args :
@@ -244,7 +268,6 @@ def test_action_objects_comparison(self, mock_load_imports):
244268
245269 result = self .runner .invoke (prod_app , [
246270 "start" ,
247- "--path" , str (self .test_project_path )
248271 ])
249272
250273 self .assertEqual (result .exit_code , 0 )
0 commit comments