Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ots-blog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
ots-blog
Commits
5ed71dfd
Commit
5ed71dfd
authored
1 year ago
by
James Vasile
Browse files
Options
Downloads
Patches
Plain Diff
Add rss feed test
parent
81f7a1f3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
requirements-dev.txt
+1
-0
1 addition, 0 deletions
requirements-dev.txt
tests/t_feeds.py
+54
-0
54 additions, 0 deletions
tests/t_feeds.py
with
55 additions
and
0 deletions
requirements-dev.txt
+
1
−
0
View file @
5ed71dfd
...
...
@@ -2,3 +2,4 @@ pytest
psutil
bs4
pytest-xprocess
feedparser
This diff is collapsed.
Click to expand it.
tests/t_feeds.py
0 → 100644
+
54
−
0
View file @
5ed71dfd
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?
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment