Esempio n. 1
0
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"))
Esempio n. 2
0
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]
Esempio n. 3
0
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"))
Esempio n. 4
0
def test_handle_skip_xmp():
    # Assume no errors == skip XMP file
    handle_file("skip.xmp", "", "", False)
Esempio n. 5
0
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"))
Esempio n. 6
0
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"))
Esempio n. 7
0
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"))