本文整理汇总了Python中tests.testutils.TestUtils.get_album_creation_date方法的典型用法代码示例。如果您正苦于以下问题:Python TestUtils.get_album_creation_date方法的具体用法?Python TestUtils.get_album_creation_date怎么用?Python TestUtils.get_album_creation_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.testutils.TestUtils
的用法示例。
在下文中一共展示了TestUtils.get_album_creation_date方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad_taketime
# 需要导入模块: from tests.testutils import TestUtils [as 别名]
# 或者: from tests.testutils.TestUtils import get_album_creation_date [as 别名]
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"
示例2: test_album_date
# 需要导入模块: from tests.testutils import TestUtils [as 别名]
# 或者: from tests.testutils.TestUtils import get_album_creation_date [as 别名]
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"
示例3: test_dash_r
# 需要导入模块: from tests.testutils import TestUtils [as 别名]
# 或者: from tests.testutils.TestUtils import get_album_creation_date [as 别名]
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