• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testutils.TestUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.testutils.TestUtils的典型用法代码示例。如果您正苦于以下问题:Python TestUtils类的具体用法?Python TestUtils怎么用?Python TestUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TestUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_sha1

    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"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:28,代码来源:test_main.py


示例2: test_bad_taketime

    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"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:26,代码来源:test_main.py


示例3: check_grand_total

    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
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:11,代码来源:test_main.py


示例4: test_subdir

    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
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:26,代码来源:test_main.py


示例5: test_dash_wo_s

    def test_dash_wo_s(self):
        # -s => no album reorder
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load a bunch of album
        tu.load_photoset("aaa")
        tu.load_photoset("mini")
        tu.load_photoset("zzzz")
        tu.load_photoset("album1")
        tu.load_photoset("album3")
        # 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"

        # get a_id, a_names
        list = tu.get_album_ids_titles()
        logger.info(list)
        # album name sorted

        # id sorted
        ids = sorted([x['id'] for x in list])
        titles = sorted([x['title'] for x in list])

        logger.info(ids)
        logger.info(titles)

        # combine
        ordered_list = zip(ids, titles)
        logger.info(ordered_list)
        # for each sorted
        well_sorted = True
        for x in ordered_list:
            logger.info(x)

            if (tu.get_album_id(x[1]) != x[0]):
                well_sorted = False

        assert (not well_sorted), "elements should not be sorted"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:45,代码来源:test_main.py


示例6: test_launch_every_test_with_cli_runner

 def test_launch_every_test_with_cli_runner(self):
     """ conf borg is shared between test and cli, this is potentially bad"""
     try:
         # load "bad taketime"  album name
         tu = TestUtils()
         tu.load_photoset("album3")
         # 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"
     except Exception as e:
         logger.exception(e)
         assert False
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:18,代码来源:test_main.py


示例7: test_album_date

    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"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:25,代码来源:test_main.py


示例8: test_shutter_speed

    def test_shutter_speed(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("rotation")
        # 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"

        photos = tu.get_photos(tu.get_album_id('rotation'))
        for p in photos:
            if p['title'] == 'P1010319.JPG':
                assert p['shutter'] == '1/60 s', "shutter {} not equal 1/60 s".format(p['shutter'])
                assert p['focal'] == '4.9 mm', "focal {} not equal 4.9 mm".format(p['focal'])
                assert p['iso'] == '100', "iso {} not equal 100".format(p['iso'])
                assert p['aperture'] == 'F3.3', "aperture {} not equal F3.3".format(p['aperture'])
            if p['title'] == 'P1010328.JPG':
                assert p['shutter'] == '1/30 s', "shutter {} not equal 1/30 s".format(p['shutter'])
                assert p['focal'] == '4.9 mm', "focal {} not equal 4.9 mm".format(p['focal'])
                assert p['iso'] == '400', "iso {} not equal 400".format(p['iso'])
                assert p['aperture'] == 'F3.3', "aperture {} not equal F3.3".format(p['aperture'])
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:28,代码来源:test_main.py


示例9: test_rotation

    def test_rotation(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("rotation")
        # 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"

        photos = tu.get_photos(tu.get_album_id('rotation'))
        for p in photos:
            # rotation tag is gone
            pfullpath = os.path.join(lych, "uploads", "big", p['url'])
            img = Image.open(pfullpath)
            assert "exif" in img.info, "Pas d'info exif"
            exif_dict = piexif.load(img.info["exif"])
            assert exif_dict["0th"][piexif.ImageIFD.Orientation] == 1, "Exif rotation should be 1"
            img.close()
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:26,代码来源:test_main.py


示例10: test_long_album

    def test_long_album(self):
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # get max_width column album name width
        maxwidth = tu.get_column_width("lychee_albums", "title")
        logger.info("album title length: " + str(maxwidth))
        # create long album name
        dest_alb_name = 'a' * (maxwidth + 10)
        assert len(dest_alb_name) == (maxwidth + 10)

        # copy album with name
        tu.load_photoset("album1", dest_alb_name)

        # 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"

        # there is a max_width album
        albums = tu.get_album_ids_titles()
        alb_real_name = albums.pop()["title"]
        assert len(alb_real_name) == maxwidth, "album len is not " + str(maxwidth)
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:28,代码来源:test_main.py


示例11: test_photoid_equal_timestamp

    def test_photoid_equal_timestamp(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']
        # normal mode
        before_launch = datetime.datetime.now()
        time.sleep(1.1)

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

        time.sleep(1.1)
        after_launch = datetime.datetime.now()
        photos = tu.get_photos(tu.get_album_id('album3'))
        for p in photos:
            logger.info(p)
            # substract 4 last characters
            ts = str(p['id'])[:-4]

            # timestamp to date
            dt = datetime.datetime.fromtimestamp(int(ts))
            logger.info(dt)
            assert after_launch > dt, "date from id not < date after launch"
            assert dt > before_launch, "date from id not > date before launch"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:32,代码来源:test_main.py


示例12: test_env_maker

 def test_env_maker(self):
     tu = TestUtils()
     # clean all
     upload_path = os.path.join(tu.conf['lycheepath'], '/uploads')
     if os.path.exists(upload_path):
         shutil.rmtree(upload_path)
     tu.drop_db()
     tu.make_fake_lychee_db()
     tu.make_fake_lychee_fs(tu.conf['lycheepath'])
     # file system exists
     assert os.path.exists(os.path.join(tu.conf['lycheepath'], 'uploads', 'big'))
     assert os.path.exists(os.path.join(tu.conf['lycheepath'], 'uploads', 'medium'))
     assert os.path.exists(os.path.join(tu.conf['lycheepath'], 'uploads', 'thumb'))
     # table exists
     assert tu.table_exists('lychee_albums')
     assert tu.table_exists('lychee_photos')
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:16,代码来源:test_main.py


示例13: test_dash_l

    def test_dash_l(self):
        # load album y
        tu = TestUtils()
        assert tu.is_env_clean(tu.conf['lycheepath']), "env not clean"
        # load album x and y
        tu.load_photoset("album1")
        # launch lycheesync
        src = tu.conf['testphotopath']
        lych = tu.conf['lycheepath']
        conf = tu.conf['conf']
        # -l => symbolic links instead of files

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

        # check if files are links
        dest = os.path.join(lych, "uploads", "big")
        not_dir = [x for x in os.listdir(dest) if not(os.path.isdir(x))]
        for f in not_dir:
            full_path = os.path.join(dest, f)
            assert os.path.islink(full_path), "this file {} is not a link".format(full_path)
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:24,代码来源:test_main.py


示例14: test_album_keep_original_case

    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'
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:24,代码来源:test_main.py


示例15: test_quotes_in_album_name

    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"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:21,代码来源:test_main.py


示例16: test_launch_with_wo_clirunner_w_sync_py

    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"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:22,代码来源:test_main.py


示例17: test_duplicate

    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
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:38,代码来源:test_main.py


示例18: test_empty_album

    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"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:21,代码来源:test_main.py


示例19: test_unicode

    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"
开发者ID:gandelman-a,项目名称:lycheesync,代码行数:21,代码来源:test_main.py


示例20: clean

def clean(request):
    """ will be run for each test function see pytest.ini """
    tu = TestUtils()
    if tu.db_exists():
        tu.clean_db()
    tu.clean_fs()
开发者ID:GustavePate,项目名称:lycheesync,代码行数:6,代码来源:conftest.py



注:本文中的tests.testutils.TestUtils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tools.assert_response函数代码示例发布时间:2022-05-27
下一篇:
Python server.Server类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap