Ejemplo n.º 1
0
    def test_sha1(self):
        """
        Should also trigger a warn
        duplicates containes photos from album1
        """
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("album1")
        # load 2 album with same photo under different name
        tu.load_photoset("duplicates")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        # no duplicate
        assert tu.count_db_albums() == 2, "two albums not created"
        assert tu.count_fs_photos() == 2, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 2, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 2, "there are duplicate photos in thumb"
Ejemplo n.º 2
0
    def test_bad_taketime(self):
        # load "bad taketime"  album name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("invalid_takedate")
        launch_date = datetime.datetime.now()
        time.sleep(1)
        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 1, "two albums created"
        assert tu.count_fs_photos() == 1, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 1, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 1, "there are duplicate photos in thumb"
        creation_date = tu.get_album_creation_date("invalid_takedate")
        creation_date = datetime.datetime.fromtimestamp(creation_date)
        assert creation_date > launch_date, "creation date should be now"
Ejemplo n.º 3
0
    def test_sha1(self):
        """
        Should also trigger a warn
        duplicates containes photos from album1
        """
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("album1")
        # load 2 album with same photo under different name
        tu.load_photoset("duplicates")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        # no duplicate
        assert tu.count_db_albums() == 2, "two albums not created"
        assert tu.count_fs_photos() == 2, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 2, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 2, "there are duplicate photos in thumb"
Ejemplo n.º 4
0
    def test_subdir(self):
        tu = TestUtils()
        # copy directory to tmptest
        tu.load_photoset("album2")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v', '-d'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        # assert Number of album / photos in database
        expected_albums = 3
        expected_photos = 4
        assert (tu.count_db_albums() == expected_albums), "there should be {} albums in db".format(
            expected_albums)
        assert (tu.count_db_photos() == expected_photos), "there should be {} photos in db".format(
            expected_photos)
        # assert Number of photo / thumbnail on filesystem
        assert tu.count_fs_thumb() == expected_photos
        assert tu.count_fs_photos() == expected_photos
Ejemplo n.º 5
0
    def test_bad_taketime(self):
        # load "bad taketime"  album name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("invalid_takedate")
        launch_date = datetime.datetime.now()
        time.sleep(1)
        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 1, "two albums created"
        assert tu.count_fs_photos() == 1, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 1, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 1, "there are duplicate photos in thumb"
        creation_date = tu.get_album_creation_date("invalid_takedate")
        creation_date = datetime.datetime.fromtimestamp(creation_date)
        assert creation_date > launch_date, "creation date should be now"
Ejemplo n.º 6
0
    def test_subdir(self):
        tu = TestUtils()
        # copy directory to tmptest
        tu.load_photoset("album2")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v', '-d'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        # assert Number of album / photos in database
        expected_albums = 3
        expected_photos = 4
        assert (tu.count_db_albums() == expected_albums
                ), "there should be {} albums in db".format(expected_albums)
        assert (tu.count_db_photos() == expected_photos
                ), "there should be {} photos in db".format(expected_photos)
        # assert Number of photo / thumbnail on filesystem
        assert tu.count_fs_thumb() == expected_photos
        assert tu.count_fs_photos() == expected_photos
Ejemplo n.º 7
0
    def test_visually_check_logs(self):
        # load "bad taketime"  album name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("invalid_takedate")
        tu.load_photoset("album2")
        tu.load_photoset("album3")
        tu.load_photoset("corrupted_file")
        tu.load_photoset("duplicates")
        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 7, "too much albums created"
        assert tu.count_fs_photos() == 10, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 10, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 10, "there are duplicate photos in thumb"
Ejemplo n.º 8
0
    def test_visually_check_logs(self):
        # load "bad taketime"  album name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("invalid_takedate")
        tu.load_photoset("album2")
        tu.load_photoset("album3")
        tu.load_photoset("corrupted_file")
        tu.load_photoset("duplicates")
        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 7, "too much albums created"
        assert tu.count_fs_photos() == 10, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 10, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 10, "there are duplicate photos in thumb"
Ejemplo n.º 9
0
    def check_grand_total(self, expected_albums, expected_photos):

        tu = TestUtils()
        assert (tu.count_db_albums() == expected_albums
                ), "there should be {} albums in db".format(expected_albums)
        assert (tu.count_db_photos() == expected_photos
                ), "there should be {} photos in db".format(expected_photos)
        # assert Number of photo / thumbnail on filesystem
        # assert Number of photo / thumbnail on filesystem
        assert tu.count_fs_thumb() == expected_photos
        assert tu.count_fs_photos() == expected_photos
Ejemplo n.º 10
0
    def check_grand_total(self, expected_albums, expected_photos):

        tu = TestUtils()
        assert (tu.count_db_albums() == expected_albums), "there should be {} albums in db".format(
            expected_albums)
        assert (tu.count_db_photos() == expected_photos), "there should be {} photos in db".format(
            expected_photos)
        # assert Number of photo / thumbnail on filesystem
        # assert Number of photo / thumbnail on filesystem
        assert tu.count_fs_thumb() == expected_photos
        assert tu.count_fs_photos() == expected_photos
Ejemplo n.º 11
0
    def test_quotes_in_album_name(self):
        # load "bad taketime"  album name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("with'\"quotes")

        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 1, "too much albums created"
        assert tu.count_fs_photos() == 1, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 1, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 1, "there are duplicate photos in thumb"
Ejemplo n.º 12
0
    def test_quotes_in_album_name(self):
        # load "bad taketime"  album name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("with'\"quotes")

        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 1, "too much albums created"
        assert tu.count_fs_photos() == 1, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 1, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 1, "there are duplicate photos in thumb"
Ejemplo n.º 13
0
    def test_launch_with_wo_clirunner_w_sync_py(self):
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("album3")
        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        cmd = 'python -m lycheesync.sync {} {} {} -v'.format(src, lych, conf)
        logger.info(cmd)
        retval = -1
        retval = subprocess.call(cmd, shell=True)
        # no crash
        assert (retval == 0), "process result is ok"

        assert tu.count_db_albums() == 1, "too much albums created"
        assert tu.count_fs_photos() == 4, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 4, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 4, "there are duplicate photos in thumb"
Ejemplo n.º 14
0
    def test_launch_with_wo_clirunner_w_sync_py(self):
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("album3")
        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        cmd = 'python -m lycheesync.sync {} {} {} -v'.format(src, lych, conf)
        logger.info(cmd)
        retval = -1
        retval = subprocess.call(cmd, shell=True)
        # no crash
        assert (retval == 0), "process result is ok"

        assert tu.count_db_albums() == 1, "too much albums created"
        assert tu.count_fs_photos() == 4, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 4, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 4, "there are duplicate photos in thumb"
Ejemplo n.º 15
0
    def test_duplicate(self):
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # copy directory to tmptest
        tu.load_photoset("album2")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        cmd = 'python main.py {} {} {} -v'.format(src, lych, conf)
        logger.info(cmd)
        retval = -1
        retval = subprocess.call(cmd, shell=True)
        # no crash
        assert (retval == 0), "process result is ok"

        # re-run
        cmd = 'python main.py {} {} {} -v'.format(src, lych, conf)
        logger.info(cmd)
        retval = -1
        retval = subprocess.call(cmd, shell=True)
        # no crash
        assert (retval == 0), "process result is ok"

        # assert Number of album / photos in database
        expected_albums = 3
        expected_photos = 4
        assert (tu.count_db_albums() == expected_albums
                ), "there should be {} albums in db".format(expected_albums)
        assert (tu.count_db_photos() == expected_photos
                ), "there should be {} photos in db".format(expected_photos)
        # assert Number of photo / thumbnail on filesystem
        # assert Number of photo / thumbnail on filesystem
        assert tu.count_fs_thumb() == expected_photos
        assert tu.count_fs_photos() == expected_photos
Ejemplo n.º 16
0
    def test_duplicate(self):
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # copy directory to tmptest
        tu.load_photoset("album2")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        cmd = 'python main.py {} {} {} -v'.format(src, lych, conf)
        logger.info(cmd)
        retval = -1
        retval = subprocess.call(cmd, shell=True)
        # no crash
        assert (retval == 0), "process result is ok"

        # re-run
        cmd = 'python main.py {} {} {} -v'.format(src, lych, conf)
        logger.info(cmd)
        retval = -1
        retval = subprocess.call(cmd, shell=True)
        # no crash
        assert (retval == 0), "process result is ok"

        # assert Number of album / photos in database
        expected_albums = 3
        expected_photos = 4
        assert (tu.count_db_albums() == expected_albums), "there should be {} albums in db".format(
            expected_albums)
        assert (tu.count_db_photos() == expected_photos), "there should be {} photos in db".format(
            expected_photos)
        # assert Number of photo / thumbnail on filesystem
        # assert Number of photo / thumbnail on filesystem
        assert tu.count_fs_thumb() == expected_photos
        assert tu.count_fs_photos() == expected_photos
Ejemplo n.º 17
0
    def test_album_keep_original_case(self):
        # load 1 album with a mixed case name and spaces
        # name in db is equal to directory name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("album1", "AlBum_One")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 1, "two albums created"
        assert tu.count_fs_photos() == 1, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 1, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 1, "there are duplicate photos in thumb"
        assert tu.get_album_id("AlBum_One"), 'there is no album with this name'
Ejemplo n.º 18
0
    def test_album_keep_original_case(self):
        # load 1 album with a mixed case name and spaces
        # name in db is equal to directory name
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load 1 album with same photo under different name
        tu.load_photoset("album1", "AlBum_One")

        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']

        # run
        runner = CliRunner()
        result = runner.invoke(main, [src, lych, conf, '-v'])
        # no crash
        assert result.exit_code == 0, "process result is ok"

        assert tu.count_db_albums() == 1, "two albums created"
        assert tu.count_fs_photos() == 1, "there are duplicate photos in fs"
        assert tu.count_db_photos() == 1, "there are duplicate photos in db"
        assert tu.count_fs_thumb() == 1, "there are duplicate photos in thumb"
        assert tu.get_album_id("AlBum_One"), 'there is no album with this name'