diff --git a/scripts/new_article.py b/scripts/new_article.py index 14365af..aace8d6 100644 --- a/scripts/new_article.py +++ b/scripts/new_article.py @@ -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) diff --git a/scripts/test_new_article.py b/scripts/test_new_article.py index baae7fa..dbef86d 100644 --- a/scripts/test_new_article.py +++ b/scripts/test_new_article.py @@ -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"]) diff --git a/scripts/test_resources/Article-2.md b/scripts/test_resources/Article-2.md new file mode 100644 index 0000000..10ccdf0 --- /dev/null +++ b/scripts/test_resources/Article-2.md @@ -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 +--- \ No newline at end of file