@@ -206,7 +206,113 @@ def test_trust_list_no_options(self):
206206 # containing the data to be listed.
207207 columns , data = self .cmd .take_action (parsed_args )
208208
209- self .trusts_mock .list .assert_called_with ()
209+ self .trusts_mock .list .assert_called_with (
210+ trustor_user = None ,
211+ trustee_user = None ,
212+ )
213+
214+ collist = ('ID' , 'Expires At' , 'Impersonation' , 'Project ID' ,
215+ 'Trustee User ID' , 'Trustor User ID' )
216+ self .assertEqual (collist , columns )
217+ datalist = ((
218+ identity_fakes .trust_id ,
219+ identity_fakes .trust_expires ,
220+ identity_fakes .trust_impersonation ,
221+ identity_fakes .project_id ,
222+ identity_fakes .user_id ,
223+ identity_fakes .user_id
224+ ), )
225+ self .assertEqual (datalist , tuple (data ))
226+
227+ def test_trust_list_auth_user (self ):
228+ auth_ref = self .app .client_manager .auth_ref = mock .Mock ()
229+ auth_ref .user_id .return_value = identity_fakes .user_id
230+
231+ arglist = ['--auth-user' ]
232+ verifylist = [
233+ ('trustor' , None ),
234+ ('trustee' , None ),
235+ ('authuser' , True ),
236+ ]
237+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
238+
239+ # In base command class Lister in cliff, abstract method take_action()
240+ # returns a tuple containing the column names and an iterable
241+ # containing the data to be listed.
242+ columns , data = self .cmd .take_action (parsed_args )
243+
244+ self .trusts_mock .list .assert_any_call (
245+ trustor_user = self .users_mock .get ()
246+ )
247+ self .trusts_mock .list .assert_any_call (
248+ trustee_user = self .users_mock .get ()
249+ )
250+
251+ collist = ('ID' , 'Expires At' , 'Impersonation' , 'Project ID' ,
252+ 'Trustee User ID' , 'Trustor User ID' )
253+ self .assertEqual (collist , columns )
254+ datalist = ((
255+ identity_fakes .trust_id ,
256+ identity_fakes .trust_expires ,
257+ identity_fakes .trust_impersonation ,
258+ identity_fakes .project_id ,
259+ identity_fakes .user_id ,
260+ identity_fakes .user_id
261+ ), )
262+ self .assertEqual (datalist , tuple (data ))
263+
264+ def test_trust_list_trustee (self ):
265+ arglist = ['--trustee' , identity_fakes .user_name ]
266+ verifylist = [
267+ ('trustor' , None ),
268+ ('trustee' , identity_fakes .user_name ),
269+ ('authuser' , False ),
270+ ]
271+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
272+
273+ # In base command class Lister in cliff, abstract method take_action()
274+ # returns a tuple containing the column names and an iterable
275+ # containing the data to be listed.
276+ columns , data = self .cmd .take_action (parsed_args )
277+
278+ print (self .trusts_mock .list .call_args_list )
279+ self .trusts_mock .list .assert_any_call (
280+ trustee_user = self .users_mock .get (),
281+ trustor_user = None ,
282+ )
283+
284+ collist = ('ID' , 'Expires At' , 'Impersonation' , 'Project ID' ,
285+ 'Trustee User ID' , 'Trustor User ID' )
286+ self .assertEqual (collist , columns )
287+ datalist = ((
288+ identity_fakes .trust_id ,
289+ identity_fakes .trust_expires ,
290+ identity_fakes .trust_impersonation ,
291+ identity_fakes .project_id ,
292+ identity_fakes .user_id ,
293+ identity_fakes .user_id
294+ ), )
295+ self .assertEqual (datalist , tuple (data ))
296+
297+ def test_trust_list_trustor (self ):
298+ arglist = ['--trustor' , identity_fakes .user_name ]
299+ verifylist = [
300+ ('trustee' , None ),
301+ ('trustor' , identity_fakes .user_name ),
302+ ('authuser' , False ),
303+ ]
304+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
305+
306+ # In base command class Lister in cliff, abstract method take_action()
307+ # returns a tuple containing the column names and an iterable
308+ # containing the data to be listed.
309+ columns , data = self .cmd .take_action (parsed_args )
310+
311+ print (self .trusts_mock .list .call_args_list )
312+ self .trusts_mock .list .assert_any_call (
313+ trustor_user = self .users_mock .get (),
314+ trustee_user = None ,
315+ )
210316
211317 collist = ('ID' , 'Expires At' , 'Impersonation' , 'Project ID' ,
212318 'Trustee User ID' , 'Trustor User ID' )
0 commit comments