예제 #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"
예제 #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"
예제 #3
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
예제 #4
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"
예제 #5
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"
예제 #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
예제 #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"
예제 #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"
예제 #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
예제 #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
예제 #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"
예제 #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"
예제 #13
0
    def test_empty_album(self):
        # load 1 empty album
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load unicode album name
        tu.load_photoset("empty_album")
        # 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 import
        assert tu.count_fs_photos() == 0, "there are photos are in fs"
        assert tu.count_db_photos() == 0, "there are photos are in db"
        assert not(tu.album_exists_in_db("empty_album")), "empty_album in db"
예제 #14
0
    def test_empty_album(self):
        # load 1 empty album
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load unicode album name
        tu.load_photoset("empty_album")
        # 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 import
        assert tu.count_fs_photos() == 0, "there are photos are in fs"
        assert tu.count_db_photos() == 0, "there are photos are in db"
        assert not (tu.album_exists_in_db("empty_album")), "empty_album in db"
예제 #15
0
    def test_unicode(self):
        # there is a unicode album
        # there is a unicode photo
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load unicode album name
        tu.load_photoset("FußÄ-Füße")
        # 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_fs_photos() == 2, "photos are missing in fs"
        assert tu.count_db_photos() == 2, "photos are missing in db"
        assert tu.album_exists_in_db("FußÄ-Füße"), "unicode album is not in db"
예제 #16
0
    def test_unicode(self):
        # there is a unicode album
        # there is a unicode photo
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load unicode album name
        tu.load_photoset("FußÄ-Füße")
        # 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_fs_photos() == 2, "photos are missing in fs"
        assert tu.count_db_photos() == 2, "photos are missing in db"
        assert tu.album_exists_in_db("FußÄ-Füße"), "unicode album is not in db"
예제 #17
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"
예제 #18
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"
예제 #19
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
예제 #20
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
예제 #21
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'
예제 #22
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'