diff --git a/cdhweb/blog/templates/blog/base.html b/cdhweb/blog/templates/blog/base.html deleted file mode 100644 index 4a68e90d..00000000 --- a/cdhweb/blog/templates/blog/base.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends 'base.html' %} -{# base template for blog pages with rss/atom header links for autodiscovery #} - -{% block extra-head %} - - -{% endblock %} - - -{% block content-footer %} -
-{% endblock %} \ No newline at end of file diff --git a/cdhweb/blog/templates/blog/blogpost_archive.html b/cdhweb/blog/templates/blog/blogpost_archive.html deleted file mode 100644 index 09950461..00000000 --- a/cdhweb/blog/templates/blog/blogpost_archive.html +++ /dev/null @@ -1,35 +0,0 @@ -{% extends 'blog/base.html' %} -{% load humanize %} - -{% block page-title %}{{ page_title }}{% endblock %} - -{% block main %} -We're making a big digital humanities announcement.
" - ), - ) - blog_link_page.add_child(instance=post) - blog_link_page.save() - post.first_published_at = pubdate - post.last_published_at = pubdate - post.save() - return post - - -def make_project_feature(blog_link_page, grad_pm): - """Create a sponsored project feature by a grad PM published in 2018.""" - pubdate = timezone.datetime(2018, 5, 19, 17, 31, tzinfo=EST).astimezone(tz.utc) - post = BlogPost( - title="Making progress on the Cool Project", - body=to_streamfield_safe( - "the Cool Digital Project is getting cooler every day
" - ), - ) - blog_link_page.add_child(instance=post) - blog_link_page.save() - post.first_published_at = pubdate - post.last_published_at = pubdate - post.save() - Author.objects.create(person=grad_pm, post=post) - return post - - -def make_article(blog_link_page, staffer, postdoc): - """Create article by staff member and postdoc from 2019; updated in 2020""" - in_2019 = timezone.datetime(2019, 3, 4, 8, 25, tzinfo=EST).astimezone(tz.utc) - in_2020 = timezone.datetime(2020, 1, 15, 20, 12, tzinfo=EST).astimezone(tz.utc) - post = BlogPost( - short_title="We wrote an article together for the CDH website", - title="We wrote an article together, and it got published on the CDH website", - body=to_streamfield_safe( - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
" - ), - ) - blog_link_page.add_child(instance=post) - blog_link_page.save() - post.first_published_at = in_2019 - post.last_published_at = in_2020 - post.save() - Author.objects.create(person=staffer, post=post) - Author.objects.create(person=postdoc, post=post) - return post - - -def make_blog_posts(blog_link_page, grad_pm, staffer, postdoc): - """Create a variety of blog posts.""" - return { - "announcement": make_announcement(blog_link_page), - "project_feature": make_project_feature(blog_link_page, grad_pm), - "article": make_article(blog_link_page, staffer, postdoc), - } - - -@pytest.fixture -def blog_link_page(db, homepage): - return make_blog_link_page(homepage) - - -@pytest.fixture -def announcement(db, blog_link_page): - return make_announcement(blog_link_page) - - -@pytest.fixture -def project_feature(db, blog_link_page, grad_pm): - return make_project_feature(blog_link_page, grad_pm) - - -@pytest.fixture -def article(db, blog_link_page, staffer, postdoc): - return make_article(blog_link_page, staffer, postdoc) - - -@pytest.fixture -def blog_posts(db, announcement, project_feature, article): - return { - "announcement": announcement, - "project_feature": project_feature, - "article": article, - } diff --git a/cdhweb/blog/tests/test_blog_meta_template.py b/cdhweb/blog/tests/test_blog_meta_template.py deleted file mode 100644 index 6634a78c..00000000 --- a/cdhweb/blog/tests/test_blog_meta_template.py +++ /dev/null @@ -1,176 +0,0 @@ -""" -Simple tests for the templates/snippets/blog_meta.html template. -Tests COinS metadata for Zotero integration. -This pytest needs to be run inside the docker container: -run 'docker-compose exec application python -m pytest cdhweb/blog/tests/test_blog_meta_template.py -v' -""" - -from django.template import Context, Template -from django.test import TestCase, RequestFactory -from django.contrib.auth.models import User -from datetime import datetime - - -class MockPage: - """Simple mock blog page object.""" - def __init__(self): - self.title = "Test CDH Blog Post" - self.seo_title = None - self.first_published_at = datetime(2025, 6, 26) - self.owner = User(username="testuser", first_name="Test", last_name="User") - - class authors: - @staticmethod - def exists(): - return False - - @staticmethod - def all(): - return [] - - -class MockPageWithAuthors: - """Mock blog page with authors.""" - def __init__(self): - self.title = "Multi Author Post" - self.seo_title = None - self.first_published_at = datetime(2025, 6, 26) - self.owner = User(username="testuser") - - class authors: - @staticmethod - def exists(): - return True - - @staticmethod - def all(): - class MockAuthor: - def __init__(self, name): - self.person = type('Person', (), {'__str__': lambda self: name})() - return [MockAuthor("Author One"), MockAuthor("Author Two")] - - -class MockPageWithSeoTitle: - """Mock blog page with SEO title.""" - def __init__(self): - self.title = "Regular Title" - self.seo_title = "SEO Optimized Title" - self.first_published_at = datetime(2025, 6, 26) - self.owner = User(username="testuser") - - class authors: - @staticmethod - def exists(): - return False - - @staticmethod - def all(): - return [] - - -class TestBlogMetaTemplate(TestCase): - """Very simple tests for blog_meta.html template.""" - - def setUp(self): - self.factory = RequestFactory() - self.template_content = """ - {% load wagtailcore_tags %} - {% include 'snippets/blog_meta.html' %} - """ - - def render_template(self, page): - """Helper to render the template.""" - request = self.factory.get("/test/") - # Mock build_absolute_uri method with proper signature - def mock_build_absolute_uri(location=None): - return "https://example.com/test/" - request.build_absolute_uri = mock_build_absolute_uri - - template = Template(self.template_content) - context = Context({'page': page, 'request': request}) - return template.render(context) - - def test_coins_span_present(self): - """Test that COinS span element is present.""" - page = MockPage() - rendered = self.render_template(page) - self.assertIn('A Big Announcement!', - html=True, - ) - - def test_body(self, client, announcement): - """blog post detail page should include post body""" - response = client.get(announcement.get_url()) - assertContains( - response, - "We're making a big digital humanities announcement.
", - html=True, - ) - - def test_authors(self, site, client, article, staffer_profile): - """blog post detail page should list author names and link to profiles""" - response = client.get(article.get_url()) - # list names for both authors - assertContains( - response, 'Staffer', html=True - ) - assertContains( - response, 'Postdoc', html=True - ) - # profile URL for staffer - assertContains(response, staffer_profile.get_url()) - - def test_pubdate(self, client, article): - """blog post detail page should list post publication date""" - response = client.get(article.get_url()) - assertContains( - response, 'March 4, 2019', html=True - ) - - def test_next_prev(self, client, blog_posts): - """blog post detail page should have next/prev post links""" - announcement = blog_posts["announcement"] - feature = blog_posts["project_feature"] - article = blog_posts["article"] - response = client.get(article.get_url()) - assertContains( - response, - '%s' % (feature.get_url(), feature.title), - html=True, - ) - assertContains( - response, - '%s' - % (announcement.get_url(), announcement.title), - html=True, - ) - - def test_head_meta(self, client, article, staffer_profile): - """blog post detail page should have meta tags in head""" - response = client.get(article.get_url()) - # first published in 2019; in GMT - assertContains( - response, - '' - % article.first_published_at.isoformat(), - html=True, - ) - # most recently published/modified in 2020; in GMT - assertContains( - response, - '' - % article.last_published_at.isoformat(), - html=True, - ) - # profile URL for staffer (postdoc doesn't have profile) - assertContains( - response, - '' % staffer_profile.get_url(), - html=True, - ) diff --git a/cdhweb/blog/tests/test_views.py b/cdhweb/blog/tests/test_views.py deleted file mode 100644 index 2ffc76ea..00000000 --- a/cdhweb/blog/tests/test_views.py +++ /dev/null @@ -1,62 +0,0 @@ -from datetime import date, timezone - -import pytest -from django.urls import reverse -from pytest_django.asserts import assertContains - -from cdhweb.blog.tests.conftest import announcement - - -class TestRssBlogPostFeed: - def test_titles(self, client, blog_posts): - """rss feed should list post titles""" - response = client.get(reverse("rss")) - for _, post in blog_posts.items(): - assertContains(response, "