@@ -57,10 +57,23 @@ def test_setup_command_line_disableDetective():
57
57
with pytest .raises (SystemExit ):
58
58
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' ])
59
59
60
- # Non existent input file
60
+ # Non existent input file and no delete_graph flag
61
61
with pytest .raises (SystemExit ):
62
62
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' ])
63
63
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
+
64
77
###
65
78
# The purpose of this test is to make sure we read accounts and emails correctly from the input .csv file in enableDetective.py
66
79
###
@@ -76,13 +89,25 @@ def test_read_accounts_csv_enableDetective():
76
89
# The purpose of this test is to make sure we read accounts and emails correctly from the input .csv file in disableDetective.py
77
90
###
78
91
def test_read_accounts_csv_disableDetective ():
92
+ # a test case where an input file is provided, although some of the lines are not correct
79
93
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' ])
80
94
81
95
accounts_dict = disableDetective .read_accounts_csv (args .input_file )
82
96
83
97
assert len (accounts_dict .keys ()) == 6
84
98
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" }
85
99
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
86
111
87
112
###
88
113
# The purpose of this test is to make sure we extract regions correctly in enableDetective.py
0 commit comments