• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tableau / tabcmd / 28975168808

08 Jul 2026 08:56PM UTC coverage: 84.135%. First build
28975168808

Pull #422

github

web-flow
Merge 12468e4f2 into 1a13fcf3d
Pull Request #422: fix: preserve CSV role/auth in createusers, fix case-sensitive validation

3 of 4 new or added lines in 2 files covered. (75.0%)

2397 of 2849 relevant lines covered (84.13%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.75
/tabcmd/commands/user/create_users_command.py
1
import tableauserverclient as TSC
1✔
2

3
from tabcmd.commands.auth.session import Session
1✔
4
from tabcmd.commands.constants import Errors
1✔
5
from tabcmd.execution.global_options import *
1✔
6
from tabcmd.execution.localize import _
1✔
7
from tabcmd.execution.logger_config import log
1✔
8
from .user_data import UserCommand
1✔
9

10

11
class CreateUsersCommand(UserCommand):
1✔
12
    """
13
    Command to add users to a site, based on information supplied in a comma-separated values (CSV) file.
14
    If the user is not already created on the server, the command creates the user before adding
15
    that user to the site
16
    """
17

18
    name: str = "createUsers"
1✔
19
    description: str = _("createusers.short_description")
1✔
20

21
    @staticmethod
1✔
22
    def define_args(create_users_parser):
1✔
23
        args_group = create_users_parser.add_argument_group(title=CreateUsersCommand.name)
1✔
24
        UserCommand.set_role_arg(args_group)
1✔
25
        set_users_file_positional(args_group)
1✔
26
        set_completeness_options(args_group)
1✔
27
        UserCommand.set_auth_arg(args_group)
1✔
28

29
    @classmethod
1✔
30
    def run_command(cls, args):
1✔
31
        logger = log(cls.__name__, args.logging_level)
1✔
32
        logger.debug(_("tabcmd.launching"))
1✔
33
        session = Session()
1✔
34
        server = session.create_session(args, logger)
1✔
35
        number_of_users_listed = 0
1✔
36
        number_of_users_added = 0
1✔
37
        number_of_errors = 0
1✔
38

39
        ## TODO
40
        # If the server has only one site (the default site), the user is created and added to the site.
41
        # If the server has multiple sites, the user is created but is not added to any site.
42
        # To add users to a site, use createsiteusers.
43
        if args.site_name:
1✔
44
            creation_site = args.site_name
×
45
        else:
46
            creation_site = "current site"
1✔
47

48
        UserCommand.validate_file_for_import(args.filename, logger, detailed=True, strict=args.require_all_valid)
1✔
49

50
        logger.info(_("createusers.status").format(args.filename.name))
1✔
51
        user_obj_list = UserCommand.get_users_from_file(args.filename, logger)
1✔
52
        logger.info(_("session.monitorjob.percent_complete").format(0))
1✔
53
        error_list = []
1✔
54
        for user_obj in user_obj_list:
1✔
55
            try:
1✔
56
                number_of_users_listed += 1
1✔
57
                if args.role:
1✔
58
                    user_obj.site_role = args.role
×
59
                if args.auth_type:
×
60
                    user_obj.auth_setting = args.auth_type
×
NEW
61
                server.users.add(user_obj)
×
62
                logger.info(_("common.output.succeeded").format(user_obj.name))
×
63
                number_of_users_added += 1
×
64
            except Exception as e:
1✔
65
                if Errors.is_resource_conflict(e) and args.continue_if_exists:
1✔
66
                    logger.info(_("tabcmd.errors.user_already_exists").format(user_obj.name))
×
67
                    continue
×
68

69
                number_of_errors += 1
1✔
70
                error_list.append(e)
1✔
71
                logger.debug(e)
1✔
72
        logger.info(_("session.monitorjob.percent_complete").format(100))
1✔
73
        logger.info(_("importcsvsummary.line.processed").format(number_of_users_listed))
1✔
74
        logger.info(_("importcsvsummary.line.skipped").format(number_of_errors))
1✔
75
        logger.info(_("importcsvsummary.users.added.count").format(number_of_users_added))
1✔
76
        if number_of_errors > 0:
1✔
77
            logger.info(_("importcsvsummary.error.details"))
1✔
78
        for exception in error_list:
1✔
79
            Errors.check_common_error_codes_and_explain(logger, exception)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc