test_article.py 1.52 KB
Newer Older
Patrick Kimber's avatar
Patrick Kimber committed
1
# -*- encoding: utf-8 -*-
2
import pytest
Patrick Kimber's avatar
Patrick Kimber committed
3

4 5
from block.tests.factories import SectionFactory
from block.tests.helper import check_content, check_field_list
6
from compose.tests.factories import ArticleFactory
Patrick Kimber's avatar
Patrick Kimber committed
7 8


9 10 11 12
@pytest.mark.django_db
def test_content_methods():
    c = ArticleFactory()
    check_content(c)
13 14 15 16 17 18 19 20 21 22 23 24 25


@pytest.mark.django_db
def test_article_empty_field_list(client):
    check_field_list(
        client=client,
        factory=ArticleFactory,
        section=SectionFactory(
            block_app="compose",
            block_model="Article",
            create_url_name="compose.article.create",
            field_list="",
        ),
Patrick Kimber's avatar
Patrick Kimber committed
26
        expected_fields=["title", "description", "article_type", "image_size"],
27 28 29 30 31 32 33 34 35 36 37 38 39 40
    )


@pytest.mark.django_db
def test_article_field_list(client):
    check_field_list(
        client=client,
        factory=ArticleFactory,
        section=SectionFactory(
            block_app="compose",
            block_model="Article",
            create_url_name="compose.article.create",
            field_list="title description",
        ),
Patrick Kimber's avatar
Patrick Kimber committed
41
        expected_fields=["title", "description"],
42 43 44 45 46 47 48 49 50 51 52 53 54 55
    )


@pytest.mark.django_db
def test_article_field_list_add_slug(client):
    check_field_list(
        client=client,
        factory=ArticleFactory,
        section=SectionFactory(
            block_app="compose",
            block_model="Article",
            create_url_name="compose.article.create",
            field_list="slug title description",
        ),
Patrick Kimber's avatar
Patrick Kimber committed
56
        expected_fields=["slug", "title", "description"],
57
    )