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

Python tests.copy_test_to_media函数代码示例

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

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



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

示例1: test_thumbnail_generation

 def test_thumbnail_generation(self):
     """
     Test that a thumbnail is created and resized.
     """
     try:
         from PIL import Image
     except ImportError:
         return
     image_name = "image.jpg"
     size = (24, 24)
     copy_test_to_media("mezzanine.core", image_name)
     thumb_name = os.path.join(settings.THUMBNAILS_DIR_NAME,
                               "thumbs-%s" % image_name,
                               image_name.replace(".", "-%sx%s." % size))
     thumb_path = os.path.join(settings.MEDIA_ROOT, thumb_name)
     thumb_image = thumbnail(image_name, *size)
     self.assertEqual(os.path.normpath(thumb_image.lstrip("/")), thumb_name)
     self.assertNotEqual(os.path.getsize(thumb_path), 0)
     thumb = Image.open(thumb_path)
     self.assertEqual(thumb.size, size)
     # Clean up.
     del thumb
     os.remove(os.path.join(settings.MEDIA_ROOT, image_name))
     os.remove(os.path.join(thumb_path))
     rmtree(os.path.join(os.path.dirname(thumb_path)))
开发者ID:DamavandiKamali,项目名称:mezzanine,代码行数:25,代码来源:tests.py


示例2: create_product

def create_product(app, created_models, verbosity, interactive, **kwargs):
    if Product in created_models:
        call_command("loaddata", "cartridge_required.json")
        if interactive:
            confirm = raw_input("\nWould you like to install an initial "
                                "demo product and sale? (yes/no): ")
            while True:
                if confirm == "yes":
                    break
                elif confirm == "no":
                    return
                confirm = raw_input("Please enter either 'yes' or 'no': ")
        # This is a hack. Ideally to split fixtures between optional
        # and required, we'd use the same approach Mezzanine does,
        # within a ``createdb`` management command. Ideally to do this,
        # we'd subclass Mezzanine's createdb command and shadow it,
        # but to do that, the cartridge.shop app would need to appear
        # *after* mezzanine.core in the INSTALLED_APPS setting, but the
        # reverse is needed for template overriding (and probably other
        # bits) to work correctly.
        # SO........... we just cheat, and check sys.argv here. Namaste.
        elif "--nodata" in sys.argv:
            return
        if verbosity >= 1:
            print
            print "Creating demo product and sale ..."
            print
        call_command("loaddata", "cartridge_optional.json")
        copy_test_to_media("cartridge.shop", "product")
开发者ID:JamiePhillipsAMS,项目名称:cartridge,代码行数:29,代码来源:__init__.py


示例3: create_shop

 def create_shop(self):
     call_command("loaddata", "cartridge_required.json")
     install_optional = not self.no_data and self.confirm(
         "\nWould you like to install an initial "
         "demo product and sale? (yes/no): ")
     if install_optional:
         if self.verbosity >= 1:
             print("\nCreating demo product and sale ...\n")
         call_command("loaddata", "cartridge_optional.json")
         copy_test_to_media("cartridge.shop", "product")
开发者ID:MarkTseng,项目名称:mezzanine,代码行数:10,代码来源:createdb.py


示例4: install_optional_data

def install_optional_data(verbosity):
    call_command("loaddata", "mezzanine_optional.json")
    zip_name = "gallery.zip"
    copy_test_to_media("mezzanine.core", zip_name)
    gallery = Gallery.objects.get()
    gallery.zip_import = zip_name
    gallery.save()
    if verbosity >= 1:
        print
        print ("Creating demo content "
               "(About page, Blog, Contact form, Gallery) ...")
        print
开发者ID:Amisiti,项目名称:mezzanine,代码行数:12,代码来源:__init__.py


示例5: install_optional_data

def install_optional_data(verbosity):
    if verbosity >= 1:
        print
        print "Creating demo pages: About us, Contact form, Gallery ..."
        print
    from mezzanine.galleries.models import Gallery
    call_command("loaddata", "mezzanine_optional.json")
    zip_name = "gallery.zip"
    copy_test_to_media("mezzanine.core", zip_name)
    gallery = Gallery.objects.get()
    gallery.zip_import = zip_name
    gallery.save()
开发者ID:damianignacio,项目名称:mezzanine,代码行数:12,代码来源:__init__.py


示例6: test_gallery_import

 def test_gallery_import(self):
     """
     Test that a gallery creates images when given a zip file to
     import, and that descriptions are created.
     """
     zip_name = "gallery.zip"
     copy_test_to_media("mezzanine.core", zip_name)
     title = str(uuid4())
     gallery = Gallery.objects.create(title=title, zip_import=zip_name)
     images = list(gallery.images.all())
     self.assertTrue(images)
     self.assertTrue(all([image.description for image in images]))
     # Clean up.
     rmtree(unicode(os.path.join(settings.MEDIA_ROOT, GALLERIES_UPLOAD_DIR, title)))
开发者ID:nym,项目名称:mezzanine,代码行数:14,代码来源:tests.py


示例7: create_initial_product

def create_initial_product(app, created_models, verbosity, **kwargs):
    if Product in created_models:
        if kwargs.get("interactive"):
            confirm = raw_input("\nWould you like to install an initial "
                                "Category and Product? (yes/no): ")
            while True:
                if confirm == "yes":
                    break
                elif confirm == "no":
                    return
                confirm = raw_input("Please enter either 'yes' or 'no': ")
        if verbosity >= 1:
            print
            print "Creating initial Category and Product ..."
            print
        call_command("loaddata", "cartridge.json")
        copy_test_to_media("cartridge.shop", "product")
开发者ID:AkademieOlympia,项目名称:cartridge,代码行数:17,代码来源:__init__.py


示例8: create_pages

 def create_pages(self):
     call_command("loaddata", "mezzanine_required.json")
     install_optional = not self.no_data and self.confirm(
         "\nWould you like to install some initial "
         "demo pages?\nEg: About us, Contact form, "
         "Gallery. (yes/no): ")
     if install_optional:
         if self.verbosity >= 1:
             print("\nCreating demo pages: About us, Contact form, "
                     "Gallery ...\n")
         from mezzanine.galleries.models import Gallery
         call_command("loaddata", "mezzanine_optional.json")
         zip_name = "gallery.zip"
         copy_test_to_media("mezzanine.core", zip_name)
         gallery = Gallery.objects.get()
         gallery.zip_import = zip_name
         gallery.save()
开发者ID:MarkTseng,项目名称:mezzanine,代码行数:17,代码来源:createdb.py


示例9: create_pages

def create_pages(app, created_models, verbosity, interactive, **kwargs):
    required = set([Page, Form, Gallery])
    if settings.DEBUG and required.issubset(set(created_models)):
        if interactive:
            confirm = raw_input("\nWould you like to install some initial "
                                "content?\nEg: About page, Blog, Contact "
                                "form, Gallery. (yes/no): ")
            while True:
                if confirm == "yes":
                    break
                elif confirm == "no":
                    return
                confirm = raw_input("Please enter either 'yes' or 'no': ")
        if verbosity >= 1:
            print
            print ("Creating initial content "
                   "(About page, Blog, Contact form, Gallery) ...")
            print
        call_command("loaddata", "mezzanine.json")
        zip_name = "gallery.zip"
        copy_test_to_media("mezzanine.core", zip_name)
        gallery = Gallery.objects.get()
        gallery.zip_import = zip_name
        gallery.save()
开发者ID:DanHoerst,项目名称:mezzanine,代码行数:24,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tests.run_pep8_for_package函数代码示例发布时间:2022-05-27
下一篇:
Python sites.has_site_permission函数代码示例发布时间: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