Esempio n. 1
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
def nested_folder(monkeypatch, mocked_folder):
    monkeypatch.setattr(BoxFolder, 'set_box_item', MagicMock())
    fold1 = BoxFolder()
    fold1.enable_shared_link = MagicMock()
    fold1.shared_link = 'link'

    monkeypatch.setattr(BoxFolder, 'items', [fold1])
    bf = mocked_folder
    return bf
Esempio n. 3
0
def nested_folder_with_various_stats(monkeypatch):
    monkeypatch.setattr(BoxFolder, 'set_box_item', MagicMock())
    monkeypatch.setattr(BoxFile, 'set_box_item', MagicMock())
    monkeypatch.setattr(BoxItem, 'has_shared_link', True)

    fold1 = BoxFolder()
    fold1.id = 42
    fold1._download_count = 1
    fold1._preview_count = 2
    fold1.description = 'A folder with stuff in it'
    setattr(fold1, 'name', 'fold1')
    fold2 = BoxFolder(parent=fold1)
    fold2._download_count = 2
    fold2._preview_count = 3
    setattr(fold2, 'name', 'fold2')
    file1 = BoxFile(parent=fold2)
    file1._download_count = 5
    file1._preview_count = 6
    file1._name = 'file1'
    setattr(file1, 'name', 'file1')
    fold1._items = [fold2]
    fold2._items = [file1]
    return fold1
Esempio n. 4
0
def nested_file(monkeypatch):
    monkeypatch.setattr(BoxFolder, 'set_box_item', MagicMock())
    monkeypatch.setattr(BoxFile, 'set_box_item', MagicMock())

    fold1 = BoxFolder()
    fold1.name = 'fold1'
    fold2 = BoxFolder(parent=fold1)
    fold2.name = 'fold2'
    file1 = BoxFile(parent=fold2)
    file1.name = 'file1'
    fold1._items = [fold2]
    fold2._items = [file1]
    return file1
Esempio n. 5
0
def nested_folder_with_emails(monkeypatch):
    monkeypatch.setattr(BoxFolder, 'set_box_item', MagicMock())

    fold1 = BoxFolder()
    fold1._folder_upload_email_address = 'email1'
    setattr(fold1, 'name', 'fold1')
    fold2 = BoxFolder(parent=fold1)
    fold2._folder_upload_email_address = 'email2'
    setattr(fold2, 'name', 'fold2')

    fold1._items = [fold2]
    fold2._items = list()
    return fold1
def mocked_folder(monkeypatch):
    monkeypatch.setattr(BoxFolder, 'set_box_item', MagicMock())
    bf = BoxFolder(None, None)
    bf.shared_link = 'link'
    bf._box_item = MagicMock()
    return bf
Esempio n. 7
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