Skip to content

Commit

Permalink
#85 use request with htmx details attribute in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ephes committed Mar 26, 2023
1 parent b8911c1 commit 5a898a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tests/blog_index_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ def test_post_in_blog_noindex_flag(self, client, post):
content = r.content.decode("utf-8")
assert '<meta name="robots" content="noindex">' in content

def test_blog_template_base_dir_overwrites_site_setting(self):
def test_blog_template_base_dir_overwrites_site_setting(self, simple_request):
blog = Blog(template_base_dir="plain")
chosen_base_dir = "foobar"
blog.template_base_dir = chosen_base_dir
template = blog.get_template(None)
template = blog.get_template(simple_request)
assert chosen_base_dir in template

def test_post_in_blog_inherits_template_base_dir(self, post):
Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.test.client import RequestFactory
from django.utils import timezone
from django_comments import get_model as get_comments_model
from django_htmx.middleware import HtmxDetails
from rest_framework.test import APIClient
from wagtail.images.models import Image
from wagtail.models import Site
Expand Down Expand Up @@ -588,6 +589,13 @@ def request_factory():
return RequestFactory()


@pytest.fixture
def simple_request(request_factory):
request = request_factory.get("/")
request.htmx = HtmxDetails(request)
return request


@pytest.fixture()
def comments_enabled():
previous = appsettings.CAST_COMMENTS_ENABLED
Expand Down
11 changes: 0 additions & 11 deletions tests/pagination_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@
from django.core.paginator import Paginator
from django.http import QueryDict
from django.shortcuts import render
from django.test import RequestFactory

from cast.models import Blog


@pytest.fixture
def request_factory():
return RequestFactory()


@pytest.fixture
def simple_request(request_factory):
return request_factory.get("/")


def test_pagination_template_is_not_paginated(simple_request):
r = render(simple_request, "pagination.html", {})
html = r.content.decode("utf-8").strip()
Expand Down

0 comments on commit 5a898a5

Please sign in to comment.