Exemple #1
0
def test_do_commands(get_shell, pytestconfig, cmds, name, stubber, capsys):
# def test_do_commands(get_shell, pytestconfig, cmds, name, stubber):

    transcript_name = '{}.transcript'.format(name)
    cmds = ['mode sandbox'] + cmds

    # (out, err) = capfd.readouterr()

    shell = get_shell()
    if generate_transcripts:
        shell.history = History()
        for cmd in cmds:
            stmt = shell.statement_parser.parse(cmd)
            shell.history.append(stmt)
            print('Running: {}'.format(cmd))
        shell.runcmds_plus_hooks(['history -t {}'.format(transcript_name)])
        with open(transcript_name, 'r') as infile:
            print(infile.read())
        file_util.copy_file(transcript_name, os.path.join(pytestconfig.rootdir, 'tests','shell_transcripts', transcript_name))
    else:
        # if name == 'worker_approve_all':
            # pytest.set_trace()
        response = shell.runcmds_plus_hooks(cmds)
        captured = capsys.readouterr()
        # with capsys.disabled():
            # print(captured.out)
            # print(captured.err)
        assert not captured.err
Exemple #2
0
def do_commands(shell, cmds, name='yee'):
    shell.history = History()
    cmds = ['mode sandbox'] + cmds
    for cmd in cmds:
        # import pdb; pdb.set_trace()
        stmt = shell.statement_parser.parse(cmd)
        shell.history.append(stmt)
        print('Running: {}'.format(cmd))
    transcript_name = '{}.transcript'.format(name)
    shell.runcmds_plus_hooks(['history -t {}'.format(transcript_name)])
    with open(transcript_name, 'r') as infile:
        print(infile.read())
def test_do_commands(get_shell, pytestconfig, cmds, name, stubber, capsys):
    # def test_do_commands(get_shell, pytestconfig, cmds, name, stubber):

    transcript_name = '{}.transcript'.format(name)
    cmds = ['mode sandbox'] + cmds

    # (out, err) = capfd.readouterr()

    shell = get_shell()
    if generate_transcripts:
        shell.history = History()
        for cmd in cmds:
            stmt = shell.statement_parser.parse(cmd)
            shell.history.append(stmt)
            print('Running: {}'.format(cmd))
        shell.runcmds_plus_hooks(['history -t {}'.format(transcript_name)])
        with open(transcript_name, 'r') as infile:
            print(infile.read())
        file_util.copy_file(
            transcript_name,
            os.path.join(pytestconfig.rootdir, 'tests', 'shell_transcripts',
                         transcript_name))
    else:
        # if name == 'worker_approve_all':
        # pytest.set_trace()
        response = shell.runcmds_plus_hooks(cmds)
        captured = capsys.readouterr()
        # with capsys.disabled():
        # print(captured.out)
        # print(captured.err)
        assert not captured.err


# #########################
# all `do_` commands:
# #################
# [] def do_psiturk_status
# [] def do_debug
# [] def do_version
# [] def do_dev

# def do_config(self, arg):
#    """
#    Usage:
# []      config print
# []      config reload
# []      config help
#    """

# []     def do_status(self, _):
# []     def do_setup_example(self, _):
# []     def db_get_config(self):
# []     def db_use_local_file(
# []     def do_download_datafiles(self, _):
# []     def do_open(self, arg):
# []     def do_eof(self, arg):
# []     def do_exit(self, arg):
# []     def do_quit(self, _):
# []     def do_server(self, arg):
# []     def do_help(self, arg):
# []     def do_quit(self, _):
# []     def do_status(self, arg): # overloads do_status with AMT info
# [x]    def do_amt_balance(self, _):

# def do_db(self, arg):
#    """
#    Usage:
# []     db get_config
# []     db use_local_file [<filename>]
# []     db use_aws_instance [<instance_id>]
# []     db aws_list_regions
# []     db aws_get_region
# []     db aws_set_region [<region_name>]
# []     db aws_list_instances
# []     db aws_create_instance [<instance_id> <size> <username> <password>
# []                             <dbname>]
# []     db aws_delete_instance [<instance_id>]
# []     db help
#    """

# def do_mode(self, arg):
#    """
#    Usage: mode
# []           mode <which>
#    """

# def do_hit(self, arg):
#    """
#    Usage:
# []      hit create [<numWorkers> <reward> <duration>]
# []      hit extend <HITid> [(--assignments <number>)] [(--expiration <minutes>)]
# []      hit expire (--all | <HITid> ...)
# []      hit delete (--all | <HITid> ...)
# []      hit list [--active | --reviewable] [--all-studies]
# []      hit help
#    """

# def do_worker(self, arg):
#    """
#    Usage:
# []      worker approve (--all | --hit <hit_id> ... | <assignment_id> ...) [--all-studies] [--force]
# []      worker reject (--hit <hit_id> | <assignment_id> ...) [--all-studies]
# []      worker unreject (--hit <hit_id> | <assignment_id> ...) [--all-studies]
# []      worker bonus  (--amount <amount> | --auto) (--reason) (--all | --hit <hit_id> | <assignment_id> ...) [--override-bonused-status] [--all-studies]
# []      worker list [--submitted | --approved | --rejected] [(--hit <hit_id>)] [--all-studies]
# []      worker help

# def do_debug(self, arg):
#    """
#    Usage: debug [options]
#
#    -p, --print-only        just provides the URL, doesn't attempt to
#                            launch browser
#    """