django cms的测试工具

djangocms-testing的Python项目详细描述


djangocms测试

一组简化django cms插件和页面测试的实用程序

用法

测试所有插件

import os

from .base import BaseTestCase

from filer.models import Image
from djangocms_testing.integrity import CMSPluginIntegrity


class DSMPluginIntegrityTestCase(BaseTestCase, CMSPluginIntegrity):

    plugin_exclude_list = [
        'SomePluginsToExclude',
        'AnotherPluginToExclude',
    ]

    def setUp(self):
        self.homepage = self.create_page('Homepage')

        # Create any data that may be necessary for the plugins

        # Example: Creating an image
        photo_path = os.path.join(os.path.dirname(__file__), 'files', 'sample_image.jpg')
        self.test_image = Image.objects.create(file=photo_path)

        # Update the plugin list
        self.plugin_list = [
            ('CategoryPlugin', {'title': 'Top Category'}),
            ('BannerPlugin', {'icon': self.test_image, 'link': self.homepage}),
            ('LinkToPagePlugin', {'page': self.homepage}),
        ]

加载页面

有一个管理命令允许您从 山药描述。

页面描述如下:

---
# Required page data
title: Regression Test Page
slug: regression-test-page
template: generic_page      # (generic_page is provided. You can use other templates by overriding _get_template)

# Optional page data        # Default value
publish: no                 # no    (yes | no)
language: en                # en    (en | es)
apphook: null               # null  (string)
apphook_namespace: null     # null  (string)
soft_root: no               # no    (yes | no)

# Placeholder variables
#
# Provided:
# $loremispum   1 paragraph of lorem ipsum text.
#
# You can add other variables by overriding _generate_sample_data
# $image        JPEG image
# $svg          SVG Tiger iimage

# Placeholders vary per template but its no problem to define them all
# in advance, and later just switch the template type:
#
# generic_page > content

placeholders:
  content:

    - CategoryPlugin:
        title: Category 1
        subplugins:

          - QuestionPlugin:
              question: >
                This is a question
              author: Author, 21
              subplugins:

                - AnswerPlugin:
                    body: >
                      This is the text's body

创建页面:manage.py page simple_test.yaml

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaMaven没有识别junit测试   正则表达式替换Java中字符串中的所有“(“and”)”   文件移动到另一台计算机时出现java错误“实例化servlet类”   服务器上的java服务   Spring数据JPA上的java嵌套@Transactional注释行为   eclipse中的Java Tomcat项目   java在Tomcat上部署web应用程序   如何解决“java.lang.IllegalStateException:ArrayAdapter要求资源ID为TextView”错误?   java在条形码上方添加文本,并使用烧烤更改字体大小   java与php基准测试   java使用正则表达式提取特定模式   java扫描器。findInLine()大量泄漏内存   java HTTP:差异请求属性和POST参数   返回空指针的Java方法?   java验证密码不包含名称中的3个以上连续字符   Java中带泛型的静态多态性   java在Android中获得最后一个已知位置   java为什么Groovy的Map比Array更具可伸缩性?   编码如何在Java中生成八进制字符串?   java Hibernate:使用单例会话写入日志(无刷新)