mirror of
https://github.com/pelican-plugins/share-post.git
synced 2025-10-15 17:08:54 +02:00
* feat: Add title to bluesky * Add release file * Format to make the linter happy --------- Co-authored-by: Daniel Lemos <xspager+dlemos@gmail.com>
68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
import os
|
|
|
|
from pelican.generators import ArticlesGenerator
|
|
from pelican.tests.support import get_context, get_settings
|
|
|
|
from . import share_post
|
|
|
|
|
|
def test_share_post(tmp_folder):
|
|
base_path = os.path.dirname(os.path.abspath(__file__))
|
|
test_data_path = os.path.join(base_path, "test_data")
|
|
|
|
share_post.register()
|
|
|
|
settings = get_settings()
|
|
context = get_context(settings)
|
|
|
|
generator = ArticlesGenerator(
|
|
context=context,
|
|
settings=settings,
|
|
path=test_data_path,
|
|
theme=settings["THEME"],
|
|
output_path=tmp_folder,
|
|
)
|
|
generator.generate_context()
|
|
|
|
share_post.run_plugin([generator])
|
|
|
|
share_links = generator.articles[0].share_post
|
|
|
|
assert (
|
|
share_links["diaspora"]
|
|
== "https://sharetodiaspora.github.io/?title=Test%20post&url=/test-post.html"
|
|
)
|
|
|
|
assert share_links["twitter"] == (
|
|
"https://twitter.com/intent/tweet?text=Test%20post"
|
|
"&url=/test-post.html&hashtags=foo,bar,foobar"
|
|
)
|
|
|
|
assert (
|
|
share_links["facebook"]
|
|
== "https://www.facebook.com/sharer/sharer.php?u=/test-post.html"
|
|
)
|
|
assert share_links["linkedin"] == (
|
|
"https://www.linkedin.com/shareArticle?"
|
|
"mini=true&url=/test-post.html&title=Test%20post&"
|
|
"summary=I%20have%20a%20lot%20to%20test&source=/test-post.html"
|
|
)
|
|
|
|
assert (
|
|
share_links["hacker-news"]
|
|
== "https://news.ycombinator.com/submitlink?t=Test%20post&u=/test-post.html"
|
|
)
|
|
|
|
assert (
|
|
share_links["email"] == "mailto:?subject=Test%20post&body=/test-post.html"
|
|
)
|
|
|
|
assert (
|
|
share_links["reddit"]
|
|
== "https://www.reddit.com/submit?url=/test-post.html&title=Test%20post"
|
|
)
|
|
|
|
assert (
|
|
share_links["bluesky"]
|
|
== "https://bsky.app/intent/compose?text=Test%20post%20/test-post.html"
|
|
)
|