@@ -57,10 +57,23 @@ def test_setup_command_line_disableDetective():
5757 with pytest .raises (SystemExit ):
5858 disableDetective .setup_command_line (['--master_account' , '12345' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' , '--input_file' , 'accounts.csv' ])
5959
60- # Non existent input file
60+ # Non existent input file and no delete_graph flag
6161 with pytest .raises (SystemExit ):
6262 disableDetective .setup_command_line (['--master_account' , '000000000001' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' , '--input_file' , 'accounts1.csv' ])
6363
64+ # Non existent input file with delete_graph flag provided
65+ with pytest .raises (SystemExit ):
66+ disableDetective .setup_command_line (['--master_account' , '000000000001' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' , '--input_file' , 'accounts1.csv' , '--delete_graph' ])
67+
68+ # No input file provided and no delete_graph flag
69+ with pytest .raises (SystemExit ):
70+ disableDetective .setup_command_line (['--master_account' , '000000000001' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' ])
71+
72+ # No input file provided but delete_graph is set
73+ args = disableDetective .setup_command_line (['--master_account' , '000000000001' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' , '--delete_graph' ])
74+ assert args .input_file == None
75+ assert args .delete_graph == True
76+
6477###
6578# The purpose of this test is to make sure we read accounts and emails correctly from the input .csv file in enableDetective.py
6679###
@@ -76,13 +89,25 @@ def test_read_accounts_csv_enableDetective():
7689# The purpose of this test is to make sure we read accounts and emails correctly from the input .csv file in disableDetective.py
7790###
7891def test_read_accounts_csv_disableDetective ():
92+ # a test case where an input file is provided, although some of the lines are not correct
7993 args = disableDetective .setup_command_line (['--master_account' , '555555555555' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' , '--input_file' , 'accounts.csv' ])
8094
8195 accounts_dict = disableDetective .read_accounts_csv (args .input_file )
8296
8397 assert len (accounts_dict .keys ()) == 6
8498 assert accounts_dict == {"123456789012" :"random@gmail.com" , "000012345678" :"email@gmail.com" , "555555555555" :"test5@gmail.com" , "111111111111" :"test1@gmail.com" , "222222222222" :"test2@gmail.com" , "333333333333" :"test3@gmail.com" }
8599
100+ # a test case where no input file is provided
101+ args = disableDetective .setup_command_line (['--master_account' , '555555555555' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' , '--delete_graph' ])
102+ assert args .input_file == None
103+ accounts_dict = disableDetective .read_accounts_csv (args .input_file )
104+ assert accounts_dict == {}
105+
106+ # a test case where an empty input file is provided, along with delete_graph. This is not an error, although clients should not run with this kind of input
107+ args = disableDetective .setup_command_line (['--master_account' , '555555555555' , '--assume_role' , 'detectiveAdmin' , '--disabled_regions' , 'us-east-1,us-east-2,us-west-2,ap-northeast-1,eu-west-1' , '--input_file' , 'accounts2.csv' , '--delete_graph' ])
108+ accounts_dict = disableDetective .read_accounts_csv (args .input_file )
109+ assert accounts_dict == {}
110+ assert args .delete_graph == True
86111
87112###
88113# The purpose of this test is to make sure we extract regions correctly in enableDetective.py
0 commit comments