Exemplo n.º 1
0
def parse_command_line(cli_input=None):
    parser = argparse.ArgumentParser()
    parser.add_argument("command", help="command to execute",
                        type=str)
    parser.add_argument("box_id", help="id of box object to use",
                        type=int)
    parser.add_argument('-d', "--directory", help="directory for outputs",
                        type=str, action='store')
    args = None
    if cli_input is not None:
        args = parser.parse_args(cli_input)
    else:
        args = parser.parse_args()

    command_handled = False

    client = BoxAuthenticator().box_client

    if args.command == 'enable_shared_link':
        folder = BoxFolder(client, args.box_id)
        folder.enable_shared_link(recursive=True)
        command_handled = True

    if args.command == 'enable_folder_upload_email':
        folder = BoxFolder(client, args.box_id)
        folder.enable_folder_upload_email(recursive=True)
        command_handled = True

    if args.command == 'folder_upload_email_address_report':
        folder = BoxFolder(client, args.box_id)
        folder.folder_upload_email_address_report()
        command_handled = True

    if args.command == 'folder_access_stats_report':
        folder = BoxFolder(client, args.box_id)
        folder.folder_access_stats_report()
        command_handled = True

    if args.command == 'complete_report':
        folder = BoxFolder(client, args.box_id)
        if args.directory is not None:
            if re.search('^\d+$', args.directory):
                folder.complete_report(box_folder=int(args.directory))
            else:
                folder.complete_report(rep_dir=args.directory)
        else:
            folder.complete_report()
        command_handled = True

    assert command_handled, "Command not recognized " + args.command
Exemplo n.º 2
0
def nested_folder(monkeypatch, mocked_folder):
    monkeypatch.setattr(BoxFolder, 'set_box_item', MagicMock())
    fold1 = BoxFolder()
    fold1.enable_folder_upload_email = MagicMock()

    monkeypatch.setattr(BoxFolder, 'items', [fold1])
    bf = mocked_folder
    return bf