@@ -439,7 +439,7 @@ def test_cli_bulk_deactivate_JSON_file_input(httpserver_auth: HTTPServer, runner
439439def test_cli_bulk_activate_retries_with_agent_ids_not_found_removed (
440440 httpserver_auth : HTTPServer , runner
441441):
442- input_lines = " \n " . join (( "agent_id" , "1234" , "5678" , "2345" , "9876" ) )
442+ input_lines = ( "agent_id" , "1234" , "5678" , "2345" , "9876" )
443443
444444 httpserver_auth .expect_request (
445445 uri = "/v1/agents/activate" ,
@@ -453,21 +453,25 @@ def test_cli_bulk_activate_retries_with_agent_ids_not_found_removed(
453453 httpserver_auth .expect_request (
454454 uri = "/v1/agents/activate" , method = "POST" , json = {"agentIds" : ["2345" , "1234" ]}
455455 ).respond_with_data (status = 204 )
456-
457- result = runner .invoke (
458- incydr , ["agents" , "bulk-activate" , "--format" , "csv" , "-" ], input = input_lines
459- )
460- assert (
461- "404 Error processing batch of 4 agent activations, agent_ids not found: ['5678', '9876']"
462- in result .output
463- )
464- assert "Activating agents..." in result .output
456+ with runner .isolated_filesystem ():
457+ with open ("tmpfile" , "w" ) as tmpfile :
458+ for line in input_lines :
459+ tmpfile .write (line )
460+ tmpfile .write ("\n " )
461+ result = runner .invoke (
462+ incydr , ["agents" , "bulk-activate" , "--format" , "csv" , "tmpfile" ]
463+ )
464+ assert (
465+ "404 Error processing batch of 4 agent activations, agent_ids not found: ['5678', '9876']"
466+ in result .output
467+ )
468+ assert "Activating agents..." in result .output
465469
466470
467471def test_cli_bulk_activate_retries_ids_individually_when_unknown_error_occurs (
468472 httpserver_auth : HTTPServer , runner
469473):
470- input_lines = " \n " . join (( "agent_id" , "1234" , "5678" , "2345" , "9876" ) )
474+ input_lines = ( "agent_id" , "1234" , "5678" , "2345" , "9876" )
471475
472476 httpserver_auth .expect_request (
473477 uri = "/v1/agents/activate" ,
@@ -487,21 +491,28 @@ def test_cli_bulk_activate_retries_ids_individually_when_unknown_error_occurs(
487491 uri = "/v1/agents/activate" , method = "POST" , json = {"agentIds" : ["9876" ]}
488492 ).respond_with_data (status = 204 )
489493
490- result = runner .invoke (
491- incydr , ["agents" , "bulk-activate" , "--format" , "csv" , "-" ], input = input_lines
492- )
493- assert "Unknown error processing batch of 4 agent activations" in result .output
494- assert "Trying agent activation for this batch individually" in result .output
495- assert "Activating agents..." in result .output
496- assert (
497- "Failed to process activation for 5678: Unknown Server Error" in result .output
498- )
494+ with runner .isolated_filesystem ():
495+ with open ("tmpfile" , "w" ) as tmpfile :
496+ for line in input_lines :
497+ tmpfile .write (line )
498+ tmpfile .write ("\n " )
499+
500+ result = runner .invoke (
501+ incydr , ["agents" , "bulk-activate" , "--format" , "csv" , "tmpfile" ]
502+ )
503+ assert "Unknown error processing batch of 4 agent activations" in result .output
504+ assert "Trying agent activation for this batch individually" in result .output
505+ assert "Activating agents..." in result .output
506+ assert (
507+ "Failed to process activation for 5678: Unknown Server Error"
508+ in result .output
509+ )
499510
500511
501512def test_cli_bulk_deactivate_retries_with_agent_ids_not_found_removed (
502513 httpserver_auth : HTTPServer , runner
503514):
504- input_lines = " \n " . join (( "agent_id" , "1234" , "5678" , "2345" , "9876" ) )
515+ input_lines = ( "agent_id" , "1234" , "5678" , "2345" , "9876" )
505516
506517 httpserver_auth .expect_request (
507518 uri = "/v1/agents/deactivate" ,
@@ -515,21 +526,26 @@ def test_cli_bulk_deactivate_retries_with_agent_ids_not_found_removed(
515526 httpserver_auth .expect_request (
516527 uri = "/v1/agents/deactivate" , method = "POST" , json = {"agentIds" : ["2345" , "1234" ]}
517528 ).respond_with_data (status = 204 )
529+ with runner .isolated_filesystem ():
530+ with open ("tmpfile" , "w" ) as tmpfile :
531+ for line in input_lines :
532+ tmpfile .write (line )
533+ tmpfile .write ("\n " )
518534
519- result = runner .invoke (
520- incydr , ["agents" , "bulk-deactivate" , "--format" , "csv" , "-" ], input = input_lines
521- )
522- assert (
523- "404 Error processing batch of 4 agent deactivations, agent_ids not found: ['5678', '9876']"
524- in result .output
525- )
526- assert "Deactivating agents..." in result .output
535+ result = runner .invoke (
536+ incydr , ["agents" , "bulk-deactivate" , "--format" , "csv" , "tmpfile" ]
537+ )
538+ assert (
539+ "404 Error processing batch of 4 agent deactivations, agent_ids not found: ['5678', '9876']"
540+ in result .output
541+ )
542+ assert "Deactivating agents..." in result .output
527543
528544
529545def test_cli_bulk_deactivate_retries_ids_individually_when_unknown_error_occurs (
530546 httpserver_auth : HTTPServer , runner
531547):
532- input_lines = " \n " . join (( "agent_id" , "1234" , "5678" , "2345" , "9876" ) )
548+ input_lines = ( "agent_id" , "1234" , "5678" , "2345" , "9876" )
533549
534550 httpserver_auth .expect_request (
535551 uri = "/v1/agents/deactivate" ,
@@ -548,13 +564,21 @@ def test_cli_bulk_deactivate_retries_ids_individually_when_unknown_error_occurs(
548564 httpserver_auth .expect_request (
549565 uri = "/v1/agents/deactivate" , method = "POST" , json = {"agentIds" : ["9876" ]}
550566 ).respond_with_data (status = 204 )
567+ with runner .isolated_filesystem ():
568+ with open ("tmpfile" , "w" ) as tmpfile :
569+ for line in input_lines :
570+ tmpfile .write (line )
571+ tmpfile .write ("\n " )
551572
552- result = runner .invoke (
553- incydr , ["agents" , "bulk-deactivate" , "--format" , "csv" , "-" ], input = input_lines
554- )
555- assert "Unknown error processing batch of 4 agent deactivations" in result .output
556- assert "Trying agent deactivation for this batch individually" in result .output
557- assert "Deactivating agents..." in result .output
558- assert (
559- "Failed to process deactivation for 5678: Unknown Server Error" in result .output
560- )
573+ result = runner .invoke (
574+ incydr , ["agents" , "bulk-deactivate" , "--format" , "csv" , "tmpfile" ]
575+ )
576+ assert (
577+ "Unknown error processing batch of 4 agent deactivations" in result .output
578+ )
579+ assert "Trying agent deactivation for this batch individually" in result .output
580+ assert "Deactivating agents..." in result .output
581+ assert (
582+ "Failed to process deactivation for 5678: Unknown Server Error"
583+ in result .output
584+ )
0 commit comments