Update tests

This commit is contained in:
Gabriel Augendre 2020-11-26 11:31:33 +01:00
parent 4f354c0014
commit 05b1eca647
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
2 changed files with 7 additions and 3 deletions

View file

@ -33,4 +33,5 @@ def published_page(author: User) -> Page:
published_at=timezone.now(), published_at=timezone.now(),
slug="some-page-slug", slug="some-page-slug",
content="## some page markdown\n\n[a page link](https://page.com)", content="## some page markdown\n\n[a page link](https://page.com)",
position=2,
) )

View file

@ -15,23 +15,26 @@ def test_can_access_list(
content = res.content.decode("utf-8") content = res.content.decode("utf-8")
for art in [published_article, published_page]: for art in [published_article, published_page]:
assert art.title in content 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 assert published_page.get_formatted_content() not in content
@pytest.mark.django_db @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" abstract = "Some abstract"
after = "Some content after abstract" after = "Some content after abstract"
baker.make( baker.make(
Article, Article,
title=title,
status=Article.PUBLISHED, status=Article.PUBLISHED,
author=author, author=author,
content=f"{abstract}\n<!--more-->\n{after}", content=f"{abstract}\n<!--more-->\n{after}",
) # type: Article ) # type: Article
res = client.get(reverse("articles-list")) res = client.get(reverse("articles-list"))
content = res.content.decode("utf-8") content = res.content.decode("utf-8")
assert abstract in content assert title in content
assert abstract not in content
assert after not in content assert after not in content