def test_cli_list_users(self): for i in range(0, 3): args = self.parser.parse_args( [ 'users', 'create', '--username', f'user{i}', '--lastname', 'doe', '--firstname', 'jon', '--email', f'jdoe+{i}@gmail.com', '--role', 'Viewer', '--use-random-password', ] ) user_command.users_create(args) with redirect_stdout(io.StringIO()) as stdout: user_command.users_list(self.parser.parse_args(['users', 'list'])) stdout = stdout.getvalue() for i in range(0, 3): assert f'user{i}' in stdout
def test_cli_list_users(self): for i in range(0, 3): args = self.parser.parse_args([ 'users', 'create', '--username', 'user{}'.format(i), '--lastname', 'doe', '--firstname', 'jon', '--email', 'jdoe+{}@gmail.com'.format(i), '--role', 'Viewer', '--use_random_password' ]) user_command.users_create(args) with mock.patch('sys.stdout', new_callable=io.StringIO) as mock_stdout: user_command.users_list(self.parser.parse_args(['users', 'list'])) stdout = mock_stdout.getvalue() for i in range(0, 3): self.assertIn('user{}'.format(i), stdout)
def test_cli_list_users_with_args(self): user_command.users_list( self.parser.parse_args(['users', 'list', '--output', 'tsv']))