Skip to content
Snippets Groups Projects
Commit 81086706 authored by James Vasile's avatar James Vasile
Browse files

Enable feeds at legacy location

 * Put them at the location our old site had them at so we can continue
   to serve existing subscribers.

 * Add some testing code to fire off a server as needed

 * Make feeds optional in pelicanconf
parents 2986865b 9dbaaeb7
No related branches found
No related tags found
No related merge requests found
...@@ -2,3 +2,4 @@ pytest ...@@ -2,3 +2,4 @@ pytest
psutil psutil
bs4 bs4
pytest-xprocess pytest-xprocess
feedparser
...@@ -25,11 +25,18 @@ def pelican_server(xprocess): ...@@ -25,11 +25,18 @@ def pelican_server(xprocess):
# command to start process # command to start process
args = ['serve'] args = ['serve']
# ensure process is running and return its logfile def already_running() -> bool:
logfile = xprocess.ensure("pelican_server", Starter) # Check if server already running
for pid in psutil.pids():
p = psutil.Process(pid)
if p.name() == "pelican" and p.cmdline()[-1] == "PELICAN_BINSERVE=true":
return True
if not already_running():
# ensure process is running and return its logfile
logfile = xprocess.ensure("pelican_server", Starter)
conn = PORT yield PORT
yield conn
# clean up whole process tree afterwards # clean up whole process tree afterwards
xprocess.getinfo("pelican_server").terminate() xprocess.getinfo("pelican_server").terminate()
......
from bs4 import BeautifulSoup as Soup
import os
import subprocess
import sys
import pytest
import psutil
import requests
# Import feedparser, but ignore its deprecation warning. Feedparser depends on
# cgi, which will be removed in Python 3.13. The feedparser project is aware of
# the issue (see https://github.com/kurtmckee/feedparser/issues/330) and will
# address it, so we can probably ignore it for now.
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import feedparser
# Read common test config
sys.path.append(os.curdir)
from .conftest import *
import website
from website import pelicanconf
def test_rss_feed_available(pelican_server):
"""Test that our RSS feed lives where the old one lived and that you can
download it with and without the trailing slash."""
# Don't run our feed tests if feeds aren't enabled
if not pelicanconf.FEEDS_ENABLED:
return
feed_file = os.path.join(OUTPUT_PATH, "feed")
assert os.path.exists(feed_file)
raw_feed_with_slash = fetch("feed/")
print(raw_feed_with_slash)
feed = feedparser.parse(raw_feed_with_slash)
assert feed.bozo == 0
assert feed.feed.title == pelicanconf.SITENAME
assert feed.feed.description == pelicanconf.SITESUBTITLE
feed_with_slash = feed
raw_feed_no_slash = fetch("feed")
print(raw_feed_no_slash)
assert raw_feed_no_slash == raw_feed_with_slash
feed = feedparser.parse(raw_feed_no_slash)
assert feed.bozo == 0
assert feed.feed.title == pelicanconf.SITENAME
assert feed.feed.description == pelicanconf.SITESUBTITLE
# what is feed.feed.link supposed to be? Should we test it for something?
FEED_DOMAIN = 'https://blog.opentechstrategies.com'
FEED_ALL_RSS = 'feed'
AUTHOR_FEED_RSS = 'feeds/{slug}.author.rss'
CATEGORY_FEED_RSS = 'feeds/{slug}.rss'
TAG_FEED_RSS = 'feeds/{slug}.tag.rss'
FEED_ALL_ATOM = 'feeds/all.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
AUTHOR_FEED_ATOM = 'feeds/{slug}.author.atom.xml'
TAG_FEED_ATOM = 'feeds/{slug}.tag.atom.xml'
import os
import sys
sys.path.append(os.curdir)
AUTHOR = 'The OTS Team' AUTHOR = 'The OTS Team'
SITENAME = 'Open Tech Strategies | Blog' SITENAME = 'Open Tech Strategies | Blog'
SITESUBTITLE = 'Maximum return from your open source investments.' SITESUBTITLE = 'Maximum return from your open source investments.'
...@@ -10,16 +14,23 @@ TIMEZONE = 'America/New_York' ...@@ -10,16 +14,23 @@ TIMEZONE = 'America/New_York'
DEFAULT_LANG = 'en' DEFAULT_LANG = 'en'
# We don't want feeds while we're testing FEEDS_ENABLED = True
FEED_DOMAIN = None if FEEDS_ENABLED == True:
AUTHOR_FEED_ATOM = None if __name__ == "pelicanconf":
AUTHOR_FEED_RSS = None from feedconf import *
FEED_ALL_ATOM = None else:
FEED_ALL_RSS = None from .feedconf import *
TAG_FEED_ATOM = None else:
TAG_FEED_RSS = None # We don't want feeds while we're testing
CATEGORY_FEED_ATOM = None FEED_DOMAIN = None
CATEGORY_FEED_RSS = None AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
FEED_ALL_ATOM = None
FEED_ALL_RSS = None
TAG_FEED_ATOM = None
TAG_FEED_RSS = None
CATEGORY_FEED_ATOM = None
CATEGORY_FEED_RSS = None
TRANSLATION_FEED_ATOM = None # we only post in english and no translations TRANSLATION_FEED_ATOM = None # we only post in english and no translations
......
...@@ -10,15 +10,7 @@ from pelicanconf import * ...@@ -10,15 +10,7 @@ from pelicanconf import *
SITEURL = 'https://blog.opentechstrategies.com' SITEURL = 'https://blog.opentechstrategies.com'
RELATIVE_URLS = False RELATIVE_URLS = False
FEED_DOMAIN = 'https://blog.opentechstrategies.com' from feedconf import *
AUTHOR_FEED_ATOM = 'feeds/{slug}.author.atom.xml'
AUTHOR_FEED_RSS = 'feeds/{slug}.author.rss'
FEED_ALL_ATOM = 'feeds/all.atom.xml'
FEED_ALL_RSS = 'feeds/all.rss'
TAG_FEED_ATOM = 'feeds/{slug}.tag.atom.xml'
TAG_FEED_RSS = 'feeds/{slug}.tag.rss'
CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
CATEGORY_FEED_RSS = 'feeds/{slug}.rss'
SITEURL = 'https://blog.opentechstrategies.com' SITEURL = 'https://blog.opentechstrategies.com'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment