Пример #1
0
def test_Push_Group():
    """
    `Push_Group` is tested similarly to `Push`.

    NOTE: removes the files `group-pushgrouptestA.json`,
    `group-pushgrouptestB.json`, `group-pushgrouptestC.json` if they exist.

    Tests:
        - pushing a single group 'pushgrouptestA'
        - pushing multiple groups, 'pushgrouptestB', 'pushgrouptestC'

    Each group has two files in it.
    """
    boxley_dir, ACCESS_TOKEN = boxley._Get_Push_Settings()[:2]
    client = dropbox.client.DropboxClient(ACCESS_TOKEN)
    cwd = os.getcwd()
    remove_files(["group-pushgrouptestA.json", "group-pushgrouptestB.json",
                  "group-pushgrouptestC.json"], boxley_dir)

    # TEST: two files in one group
    content1, content2 = "It's time to think\n", "creatively!\n"
    push_helper_1(1, 2, content1, content2, None, "pushgrouptestA", False, cwd)
    boxley.Push_Group(["pushgrouptestA"], False, True, False)
    push_helper_2("group-pushgrouptestA.json", boxley_dir, client)

    # TEST: two groups with two files each
    content3, content4 = "It's just a\n", "boring old orange!\n"
    content5, content6 = "Maybe to you\n", "but not to me!\n"
    push_helper_1(3, 4, content3, content4, None, "pushgrouptestB", False, cwd)
    push_helper_1(5, 6, content5, content6, None, "pushgrouptestC", False, cwd)
    boxley.Push_Group(["pushgrouptestB", "pushgrouptestC"], False, True, False)
    push_helper_2("group-pushgrouptestB.json", boxley_dir, client)
    push_helper_2("group-pushgrouptestC.json", boxley_dir, client)
Пример #2
0
def test_Push():
    """
    `Push` is tested by creating a local file, adding it to a json file (via
    `Add`), pushing the file, then manually pulling the file and comparing it.

    NOTE: this test removes all paths in `paths.json`, and removes the file
    `group-pushtest.json` (if it exists).

    Tests:
        - adding two files to `paths.json`
        - adding two files to a group 'pushtest'
    """
    boxley_dir, ACCESS_TOKEN = boxley._Get_Push_Settings()[:2]
    client = dropbox.client.DropboxClient(ACCESS_TOKEN)
    cwd = os.getcwd()
    with open(os.path.join(boxley_dir, "paths.json"), "w") as PATHSCONF:
        PATHSCONF.write("{}\n")
    remove_files(["group-pushtest.json"], boxley_dir)

    # TEST: regular files
    content1, content2 = "I am tired\n", "of being creative.\n"
    local_paths = push_helper_1(1, 2, content1, content2, None, None, False, cwd)
    boxley.Push(local_paths, False, None, True, False)
    push_helper_2("paths.json", boxley_dir, client)

    # TEST: files in a group
    content3, content4 = "Green is not\n", "a creative colour.\n"
    local_paths = push_helper_1(3, 4, content3, content4, None, "pushtest", False, cwd)
    boxley.Push(local_paths, False, "pushtest", True, False)
    push_helper_2("group-pushtest.json", boxley_dir, client)