Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new_article.py script to handle file name containing an Upper Case letter #59

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/new_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def main(files_paths):
file_name = basename[:-3] # get rid of the `.md`

## Add URL info:
data["url"] = f"https://iscsc.fr/posts/{file_name}"
data["url"] = f"https://iscsc.fr/posts/{file_name.lower()}" # filename generated by HUGO will be lowercase
# so must be the URL

## Finally send Data
req = requests.post("http://iscsc.fr:8001/new-blog", json=data)
Expand Down
20 changes: 20 additions & 0 deletions scripts/test_new_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ def test_new_article_file(mock_requests_post):
}
)


def test_new_article_file_upper_case(mock_requests_post):
# Add an article with an Upper case --> URL should be lower case
new_article.main(["test_resources/Article-2.md"])

mock_requests_post.assert_called_once_with(
'http://iscsc.fr:8001/new-blog',
json={
'title': 'article title',
'summary': 'article name contains an upper case letter',
'date': '2024-05-05 12:00:00+02:00',
'lastUpdate': '2024-05-05 12:00:00+02:00',
'tags': "['some', 'tags']",
'author': 'ctmbl',
'draft': False,
'url': 'https://iscsc.fr/posts/article-2'
}
)


def test_new_leaf_bundle_article(mock_requests_post):
new_article.main(["test_resources/leaf_bundle/index.md"])

Expand Down
9 changes: 9 additions & 0 deletions scripts/test_resources/Article-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "article title"
summary: "article name contains an upper case letter"
date: 2024-05-05T12:00:00+02:00
lastUpdate: 2024-05-05T12:00:00+02:00
tags: ["some","tags"]
author: ctmbl
draft: false
---
Loading