From 05b1eca6475f870f3c6892d80d5c907b047ccdd0 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 26 Nov 2020 11:31:33 +0100 Subject: [PATCH] Update tests --- articles/tests/conftest.py | 1 + articles/tests/test_articles.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/articles/tests/conftest.py b/articles/tests/conftest.py index 908e95a..c1448f6 100644 --- a/articles/tests/conftest.py +++ b/articles/tests/conftest.py @@ -33,4 +33,5 @@ def published_page(author: User) -> Page: published_at=timezone.now(), slug="some-page-slug", content="## some page markdown\n\n[a page link](https://page.com)", + position=2, ) diff --git a/articles/tests/test_articles.py b/articles/tests/test_articles.py index 847821f..155a098 100644 --- a/articles/tests/test_articles.py +++ b/articles/tests/test_articles.py @@ -15,23 +15,26 @@ def test_can_access_list( content = res.content.decode("utf-8") for art in [published_article, published_page]: assert art.title in content - assert published_article.get_abstract() in content + assert published_article.get_abstract() not in content assert published_page.get_formatted_content() not in content @pytest.mark.django_db -def test_abstract_shown_on_list(client: Client, author: User): +def test_only_title_shown_on_list(client: Client, author: User): + title = "This is a very long title mouahahaha" abstract = "Some abstract" after = "Some content after abstract" baker.make( Article, + title=title, status=Article.PUBLISHED, author=author, content=f"{abstract}\n\n{after}", ) # type: Article res = client.get(reverse("articles-list")) content = res.content.decode("utf-8") - assert abstract in content + assert title in content + assert abstract not in content assert after not in content