@@ -95,7 +95,7 @@ def test_check_request_remove_account(self):
95
95
96
96
# use request_remove_account() to push the valid account onto
97
97
# the queue.
98
- rqr .request_remove_account (self .acc .id )
98
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
99
99
100
100
# assume request_remove_account() succeeded.
101
101
# check_request_remove_account() should return True.
@@ -120,7 +120,7 @@ def test_request_remove_account(self):
120
120
rqr = RemovalQueueRepo (t )
121
121
# use request_remove_account() to push the valid account onto
122
122
# the queue.
123
- rqr .request_remove_account (self .acc .id )
123
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
124
124
125
125
# assume check_request_remove_account() works correctly.
126
126
# verify account is now in the queue.
@@ -131,20 +131,21 @@ def test_request_remove_account_failure(self):
131
131
rqr = RemovalQueueRepo (t )
132
132
133
133
# remove a valid account twice
134
- rqr .request_remove_account (self .acc .id )
134
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
135
135
with self .assertRaises (RepoException ):
136
- rqr .request_remove_account (self .acc .id )
136
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
137
137
138
138
# remove a non-existant id.
139
139
with self .assertRaises (ForeignKeyViolation ):
140
- rqr .request_remove_account (RemovalQueueTests .bad_id )
140
+ rqr .request_remove_account (RemovalQueueTests .bad_id ,
141
+ 'delete reason' )
141
142
142
143
def test_cancel_request_remove_account (self ):
143
144
with Transaction () as t :
144
145
rqr = RemovalQueueRepo (t )
145
146
# use request_remove_account() to push the valid account onto
146
147
# the queue.
147
- rqr .request_remove_account (self .acc .id )
148
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
148
149
149
150
# assume check_request_remove_account() works correctly.
150
151
# verify account is now in the queue.
@@ -177,7 +178,7 @@ def test_cancel_request_remove_account_failure(self):
177
178
178
179
# use request_remove_account() to push the valid account onto
179
180
# the queue.
180
- rqr .request_remove_account (self .acc .id )
181
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
181
182
182
183
# cancel the request to delete the account twice.
183
184
rqr .cancel_request_remove_account (self .acc .id )
@@ -189,12 +190,13 @@ def test_update_queue_success(self):
189
190
rqr = RemovalQueueRepo (t )
190
191
191
192
# push the standard account onto the queue.
192
- rqr .request_remove_account (self .acc .id )
193
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
193
194
194
195
# update_queue should migrate the relevant information to the
195
196
# ag.account_removal_log table and delete the entry from the
196
197
# queue table.
197
- rqr .update_queue (self .acc .id , self .adm .email , 'deleted' )
198
+ rqr .update_queue (self .acc .id , self .adm .email , 'deleted' ,
199
+ 'delete reason' )
198
200
199
201
# confirm that the account id is no longer in the queue table.
200
202
self .assertFalse (rqr .check_request_remove_account (self .acc .id ))
@@ -205,16 +207,17 @@ def test_update_queue_success(self):
205
207
with Transaction () as t :
206
208
with t .cursor () as cur :
207
209
cur .execute ("SELECT account_id, admin_id, disposition, "
208
- "requested_on, reviewed_on FROM "
210
+ "requested_on, reviewed_on, delete_reason FROM "
209
211
"ag.account_removal_log" )
210
212
rows = cur .fetchall ()
211
213
self .assertEqual (len (rows ), 1 )
212
214
for account_id , admin_id , disposition , requested_on ,\
213
- reviewed_on in rows :
215
+ reviewed_on , delete_reason in rows :
214
216
# note this loop should only execute once.
215
217
self .assertEqual (account_id , self .acc .id )
216
218
self .assertEqual (admin_id , self .adm .id )
217
219
self .assertEqual (disposition , 'deleted' )
220
+ self .assertEqual (delete_reason , 'delete reason' )
218
221
now = datetime .datetime .now ().timestamp ()
219
222
# the requested_on time should be not far in the past.
220
223
# assume it is not NULL and is less than a minute ago.
@@ -227,23 +230,23 @@ def test_update_queue_failure(self):
227
230
rqr = RemovalQueueRepo (t )
228
231
229
232
with self .assertRaises (InvalidTextRepresentation ):
230
- rqr .update_queue ('XXXX' , self .adm .email , 'ignored' )
233
+ rqr .update_queue ('XXXX' , self .adm .email , 'ignored' , None )
231
234
232
235
with Transaction () as t :
233
236
rqr = RemovalQueueRepo (t )
234
237
235
238
# push the standard account onto the queue.
236
- rqr .request_remove_account (self .acc .id )
239
+ rqr .request_remove_account (self .acc .id , 'delete reason' )
237
240
238
241
# ensure that an Error is raised when an invalid admin
239
242
# email address is passed.
240
243
with self .assertRaises (RepoException ):
241
- rqr .update_queue (self .acc .id , 'XXXX' , 'ignored' )
244
+ rqr .update_queue (self .acc .id , 'XXXX' , 'ignored' , None )
242
245
243
246
# ensure that an Error is raised when disposition is None or
244
247
# emptry string.
245
248
with self .assertRaises (RepoException ):
246
- rqr .update_queue (self .acc .id , self .adm .email , None )
249
+ rqr .update_queue (self .acc .id , self .adm .email , None , None )
247
250
248
251
with self .assertRaises (RepoException ):
249
- rqr .update_queue (self .acc .id , self .adm .email , '' )
252
+ rqr .update_queue (self .acc .id , self .adm .email , '' , None )
0 commit comments