예제 #1
0
파일: tests.py 프로젝트: bshomar/phockup
def test_handle_exists_rename():
    with tempfile.TemporaryDirectory("phockup") as dir_name:
        output_dir = os.path.join(dir_name, "unknown")

        os.makedirs(output_dir)
        shutil.copy2("test_files/input/in_exif.jpg", os.path.join(output_dir, "in_other.log"))

        handle_file("test_files/input/in_other.log", dir_name, "%Y/%m/%d", False)
        assert os.path.isfile(os.path.join(dir_name, "unknown/in_other-2.log"))
예제 #2
0
파일: tests.py 프로젝트: bshomar/phockup
def test_handle_exists_same(capsys):
    with tempfile.TemporaryDirectory("phockup") as dir_name:
        output_dir = os.path.join(dir_name, "unknown")

        os.makedirs(output_dir)
        shutil.copy2("test_files/input/in_other.log", output_dir)

        handle_file("test_files/input/in_other.log", dir_name, "%Y/%m/%d", False)
        assert 'skipped, duplicated file' in capsys.readouterr()[0]
예제 #3
0
파일: tests.py 프로젝트: bshomar/phockup
def test_handle_move():
    with tempfile.TemporaryDirectory("phockup") as dir_name:
        open(os.path.join(dir_name, "in_move.txt"), "w").close()
        open(os.path.join(dir_name, "in_move.txt.xmp"), "w").close()

        handle_file(os.path.join(dir_name, "in_move.txt"), dir_name, "%Y/%m/%d", True)

        assert not os.path.isfile(os.path.join(dir_name, "in_move.txt"))
        assert not os.path.isfile(os.path.join(dir_name, "in_move.txt.xmp"))

        assert os.path.isfile(os.path.join(dir_name, "unknown/in_move.txt"))
        assert os.path.isfile(os.path.join(dir_name, "unknown/in_move.txt.xmp"))
예제 #4
0
파일: tests.py 프로젝트: bshomar/phockup
def test_handle_skip_xmp():
    # Assume no errors == skip XMP file
    handle_file("skip.xmp", "", "", False)
예제 #5
0
파일: tests.py 프로젝트: bshomar/phockup
def test_handle_other():
    with tempfile.TemporaryDirectory("phockup") as dir_name:
        handle_file("test_files/input/in_other.log", dir_name, "%Y/%m/%d", False)
        assert os.path.isfile(os.path.join(dir_name, "unknown/in_other.log"))
예제 #6
0
파일: tests.py 프로젝트: bshomar/phockup
def test_handle_image_xmp_noext():
    with tempfile.TemporaryDirectory("phockup") as dir_name:
        handle_file("test_files/input/in_xmp_noext.jpg", dir_name, "%Y/%m/%d", False)
        assert os.path.isfile(os.path.join(dir_name, "2017/01/01/20170101-010101.jpg"))
        assert os.path.isfile(os.path.join(dir_name, "2017/01/01/20170101-010101.xmp"))
예제 #7
0
파일: tests.py 프로젝트: bshomar/phockup
def test_handle_file_filename_date():
    with tempfile.TemporaryDirectory("phockup") as dir_name:
        handle_file("test_files/input/in_date_20170101_010101.jpg", dir_name, "%Y/%m/%d", False)
        assert os.path.isfile(os.path.join(dir_name, "2017/01/01/20170101-010101.jpg"))