コード例 #1
0
ファイル: test_main.py プロジェクト: SaintDako/boxley
def test_Push_All():
    """
    `Push_All` is tested similarly to `Push`.

    NOTE: removes all files from ~/.boxley except for `boxley.conf` and
    `paths.json`. Removes all paths from `paths.json`.

    Tests:
        - putting two files in `paths.json` and groups 'pushalltestA' and
          'pushalltestB'
    """
    boxley_dir, ACCESS_TOKEN = boxley._Get_Pull_Settings()
    client = dropbox.client.DropboxClient(ACCESS_TOKEN)
    cwd = os.getcwd()
    with open(os.path.join(boxley_dir, "paths.json"), "w") as PATHSCONF:
        PATHSCONF.write("{}\n")

    all_files = os.listdir(boxley_dir)
    all_files.remove("boxley.conf")
    all_files.remove("paths.json")
    for f in all_files:
        os.remove(os.path.join(boxley_dir, f))

    content1, content2 = "I see a\n", "silly face!\n"
    content3, content4 = "I use my hair\n", "to express myself!\n"
    content5, content6 = "I see a hat\n", "I see a cat!\n"
    push_helper_1(1, 2, content1, content2, None, None, False, cwd)
    push_helper_1(3, 4, content3, content4, None, "pushalltestA", False, cwd)
    push_helper_1(5, 6, content5, content6, None, "pushalltestB", False, cwd)

    boxley.Push_All(False, True, False)
    push_helper_2("paths.json", boxley_dir, client)
    push_helper_2("group-pushalltestA.json", boxley_dir, client)
    push_helper_2("group-pushalltestB.json", boxley_dir, client)
コード例 #2
0
ファイル: test_main.py プロジェクト: SaintDako/boxley
def test_Pull_All():
    """
    `Pull_All` is tested similarly to `Pull`.

    NOTE: this test removes all files in ~/.boxley except for `boxley.conf` and
    `paths.json`.

    Tests:
        - add two files to `paths.json` and two files to a group "pullalltest"
    """
    home = os.path.expanduser("~")
    boxley_dir, ACCESS_TOKEN = boxley._Get_Pull_Settings()
    client = dropbox.client.DropboxClient(ACCESS_TOKEN)
    cwd = os.getcwd()
    cwd_without_home = cwd.replace(home, "")[1:]

    content1, content2 = "my groceries\n", "eggs\nbacon\n"
    content3, content4 = "iceberg lettuce\npeppers\n", "chocolate milk\n"
    new_content1, new_content2 = "games I play\n", "saints row 3\ndino d-day\n"
    new_content3, new_content4 = "battleblock theater\n", "freaking meatbags\n\n"

    all_files = os.listdir(boxley_dir)
    all_files.remove("boxley.conf")
    all_files.remove("paths.json")
    for f in all_files:
        os.remove(os.path.join(boxley_dir, f))

    paths1 = pull_helper(1, 2, content1, content2, new_content1, new_content2, None, None, 
                         False, cwd, cwd_without_home, client)
    paths2 = pull_helper(3, 4, content3, content4, new_content3, new_content4, None, "pullalltest", 
                         False, cwd, cwd_without_home, client)

    boxley.Pull_All(False)
    check_file_content(paths1, [content1, content2])
    check_file_content(paths2, [content3, content4])
コード例 #3
0
ファイル: test_main.py プロジェクト: SaintDako/boxley
def test_Pull():
    """
    `Pull` is tested by manually putting a file on Dropbox, using `Add` to add
    the file to a json file, changing the local copy of the file, pulling the
    file from Dropbox, and then verifying that it is identical to what it was
    before the local changes were made.

    Tests:
        - adding two files to `paths.json`
        - adding two files to a group "pulltest"
    """
    home = os.path.expanduser("~")
    boxley_dir, ACCESS_TOKEN = boxley._Get_Pull_Settings()
    client = dropbox.client.DropboxClient(ACCESS_TOKEN)
    cwd = os.getcwd()
    cwd_without_home = cwd.replace(home, "")[1:]  # remove leading /

    # individual files
    content1, content2 = "hello\nhello\ngoodbye!", "just-some-garbage"
    new_content1, new_content2 = "some random new garbage\n", "POOP: People Order Our Patties\n"
    paths = pull_helper(1, 2, content1, content2, new_content1, new_content2, None, None,
                        False, cwd, cwd_without_home, client)

    boxley.Pull(paths, None, False)
    check_file_content(paths, [content1, content2])

    # files that are in a group
    content3, content4 = "I'M IN a group!!", "as\n\nam\n\ni\n"
    new_content3, new_content4 = "ugh.\n", "Mr. Robot is awesome.\n" 
    paths = pull_helper(3, 4, content3, content4, new_content3, new_content4, None, "pulltest",
                        False, cwd, cwd_without_home, client)

    boxley.Pull(paths, "pulltest", False)
    check_file_content(paths, [content3, content4])
コード例 #4
0
ファイル: test_main.py プロジェクト: SaintDako/boxley
def test_Pull_Group():
    """
    `Pull_Group` is tested similarly to `Pull`.

    Tests:
        - pulling a single group "pullgrouptest_A"
        - pulling multiple groups "pullgrouptest_B", "pullgrouptest_C"
    """
    home = os.path.expanduser("~")
    boxley_dir, ACCESS_TOKEN = boxley._Get_Pull_Settings()
    client = dropbox.client.DropboxClient(ACCESS_TOKEN)
    cwd = os.getcwd()
    cwd_without_home = cwd.replace(home, "")[1:]  # remove leading /

    # individual files
    content1, content2 = "group1file1", "groupunfiledeux"
    new_content1, new_content2 = "i dunno man\n", "out of ideas\n"
    paths = pull_helper(1, 2, content1, content2, new_content1, new_content2, None,
                        "pullgrouptest_A", False, cwd, cwd_without_home, client)

    boxley.Pull_Group(["pullgrouptest_A"], False)
    check_file_content(paths, [content1, content2])

    # files that are in a group
    content3, content4 = "groupBfileAAA", "groupBfileBBB"
    content5, content6 = "zippo", "nada!"
    new_content3, new_content4 = "idea: artists\n", "sirensceol\n"
    new_content5, new_content6 = "gibbz\n", "free the skies\n"
    paths1 = pull_helper(3, 4, content3, content4, new_content3, new_content4, None,
                         "pullgrouptest_B", False, cwd, cwd_without_home, client)
    paths2 = pull_helper(5, 6, content5, content6, new_content5, new_content6, None,
                         "pullgrouptest_C", False, cwd, cwd_without_home, client)

    boxley.Pull_Group(["pullgrouptest_B", "pullgrouptest_C"], False)
    check_file_content(paths1, [content3, content4])
    check_file_content(paths2, [content5, content6])