@@ -126,6 +126,7 @@ def create_backend_fleet(
126126 gpu_count_max : int = 0 ,
127127 instances : Optional [List [Instance ]] = None ,
128128 status : FleetStatus = FleetStatus .ACTIVE ,
129+ project_name : str = "test-project" ,
129130) -> Fleet :
130131 nodes = FleetNodesSpec (min = nodes_min , target = nodes_min , max = nodes_max )
131132
@@ -154,7 +155,7 @@ def create_backend_fleet(
154155 return Fleet (
155156 id = uuid4 (),
156157 name = name ,
157- project_name = "test-project" ,
158+ project_name = project_name ,
158159 spec = spec ,
159160 created_at = datetime (2023 , 1 , 2 , 3 , 4 , 5 , tzinfo = timezone .utc ),
160161 status = status ,
@@ -222,7 +223,7 @@ def test_backend_fleet_without_verbose(self):
222223 instances = [instance ],
223224 )
224225
225- table = get_fleets_table ([fleet ], verbose = False )
226+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = False )
226227 cells = get_table_cells (table )
227228
228229 assert len (cells ) == 2 # 1 fleet row + 1 instance row
@@ -262,7 +263,7 @@ def test_backend_fleet_with_verbose(self):
262263 instances = [instance ],
263264 )
264265
265- table = get_fleets_table ([fleet ], verbose = True )
266+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = True )
266267 cells = get_table_cells (table )
267268
268269 assert len (cells ) == 2
@@ -310,7 +311,7 @@ def test_ssh_fleet_without_verbose(self):
310311 instances = [instance1 , instance2 ],
311312 )
312313
313- table = get_fleets_table ([fleet ], verbose = False )
314+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = False )
314315 cells = get_table_cells (table )
315316
316317 assert len (cells ) == 3 # 1 fleet row + 2 instance rows
@@ -345,7 +346,7 @@ def test_ssh_fleet_with_verbose(self):
345346 instances = [instance ],
346347 )
347348
348- table = get_fleets_table ([fleet ], verbose = True )
349+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = True )
349350 cells = get_table_cells (table )
350351
351352 assert len (cells ) == 2
@@ -395,7 +396,9 @@ def test_mixed_fleets(self):
395396 instances = [ssh_instance ],
396397 )
397398
398- table = get_fleets_table ([backend_fleet , ssh_fleet ], verbose = False )
399+ table = get_fleets_table (
400+ [backend_fleet , ssh_fleet ], current_project = "test-project" , verbose = False
401+ )
399402 cells = get_table_cells (table )
400403
401404 assert len (cells ) == 4 # 2 fleet rows + 2 instance rows
@@ -433,7 +436,9 @@ def test_fleet_status_colors(self):
433436 name = "terminating" , status = FleetStatus .TERMINATING , instances = [terminating_instance ]
434437 )
435438
436- table = get_fleets_table ([active_fleet , terminating_fleet ], verbose = False )
439+ table = get_fleets_table (
440+ [active_fleet , terminating_fleet ], current_project = "test-project" , verbose = False
441+ )
437442
438443 active_style = get_table_cell_style (table , "STATUS" , 0 )
439444 assert active_style == "bold white"
@@ -451,7 +456,7 @@ def test_instance_status_colors(self):
451456 instances = [idle_instance , busy_instance ],
452457 )
453458
454- table = get_fleets_table ([fleet ], verbose = False )
459+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = False )
455460
456461 idle_style = get_table_cell_style (table , "STATUS" , 1 )
457462 assert idle_style == "bold sea_green3"
@@ -462,7 +467,7 @@ def test_instance_status_colors(self):
462467 def test_empty_fleet (self ):
463468 fleet = create_backend_fleet (name = "empty-fleet" , instances = [])
464469
465- table = get_fleets_table ([fleet ], verbose = False )
470+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = False )
466471 cells = get_table_cells (table )
467472
468473 assert len (cells ) == 1
@@ -474,7 +479,7 @@ def test_fleet_with_max_price(self):
474479 max_price = 5.0 ,
475480 )
476481
477- table = get_fleets_table ([fleet ], verbose = False )
482+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = False )
478483 cells = get_table_cells (table )
479484
480485 assert cells [0 ]["PRICE" ] == "$0..$5"
@@ -485,7 +490,7 @@ def test_fleet_with_multiple_backends(self):
485490 backends = [BackendType .AWS , BackendType .GCP , BackendType .AZURE ],
486491 )
487492
488- table = get_fleets_table ([fleet ], verbose = False )
493+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = False )
489494 cells = get_table_cells (table )
490495
491496 assert cells [0 ]["BACKEND" ] == "aws, gcp, azure"
@@ -496,7 +501,24 @@ def test_fleet_with_any_backend(self):
496501 backends = None ,
497502 )
498503
499- table = get_fleets_table ([fleet ], verbose = False )
504+ table = get_fleets_table ([fleet ], current_project = "test-project" , verbose = False )
500505 cells = get_table_cells (table )
501506
502507 assert cells [0 ]["BACKEND" ] == "*"
508+
509+ def test_with_imported_fleet (self ):
510+ current_project_fleet = create_backend_fleet (
511+ name = "current-fleet" , project_name = "current-project"
512+ )
513+ other_project_fleet = create_backend_fleet (
514+ name = "other-fleet" , project_name = "other-project"
515+ )
516+ table = get_fleets_table (
517+ [current_project_fleet , other_project_fleet ],
518+ verbose = False ,
519+ current_project = "current-project" ,
520+ )
521+ cells = get_table_cells (table )
522+ assert len (cells ) == 2
523+ assert cells [0 ]["NAME" ] == "current-fleet"
524+ assert cells [1 ]["NAME" ] == "other-project/other-fleet"
0 commit comments