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"
def test_album_date(self): # album date should be equal to date/time original tu = TestUtils() assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean" # load album x and y tu.load_photoset("real_date") 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.album_exists_in_db("real_date") # read album date for album1 album1_date = tu.get_album_creation_date('real_date') real_date = datetime.datetime.fromtimestamp(album1_date) theorical_date = datetime.datetime(2011, 11, 11, 11, 11, 11) assert ( real_date == theorical_date), "album date is 2011/11/11 11:11:11"
def test_album_date(self): # album date should be equal to date/time original tu = TestUtils() assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean" # load album x and y tu.load_photoset("real_date") 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.album_exists_in_db("real_date") # read album date for album1 album1_date = tu.get_album_creation_date('real_date') real_date = datetime.datetime.fromtimestamp(album1_date) theorical_date = datetime.datetime(2011, 11, 11, 11, 11, 11) assert (real_date == theorical_date), "album date is 2011/11/11 11:11:11"
def test_dash_r(self): try: tu = TestUtils() assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean" # load album x and y tu.load_photoset("album1") tu.load_photoset("album3") # launch lycheesync src = tu.conf['testphotopath'] lych = tu.conf['lycheepath'] conf = tu.conf['conf'] # run cmd = 'python main.py {} {} {} -r -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.album_exists_in_db("album1") # read album date for album1 album1_date = tu.get_album_creation_date('album1') # read album date for album3 album3_date = tu.get_album_creation_date('album3') # empty tmp pictures folder tu.delete_dir_content(src) tu.dump_table('lychee_albums') # sleep 1 s to make time album signature different time.sleep(2) # load album3 tu.load_photoset("album3") # run cmd = 'python main.py {} {} {} -r -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" album1_date_2 = tu.get_album_creation_date('album1') album3_date_2 = tu.get_album_creation_date('album3') tu.dump_table('lychee_albums') # y date < time assert album1_date == album1_date_2, 'album 1 is untouched' assert tu.check_album_size('album1') == 1 # x date > time assert album3_date < album3_date_2, 'album 3 has been modified' assert tu.check_album_size('album3') == 4 expected_albums = 2 expected_photos = 5 self.check_grand_total(expected_albums, expected_photos) except AssertionError: raise except Exception as e: logger.exception(e) assert False