From 232e68c6020445d868da2a04e49e202ef593795a Mon Sep 17 00:00:00 2001 From: ctmbl Date: Sun, 5 May 2024 18:41:20 +0200 Subject: [PATCH 1/3] Add a regression test --- scripts/test_new_article.py | 20 ++++++++++++++++++++ scripts/test_resources/Article-2.md | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/test_resources/Article-2.md diff --git a/scripts/test_new_article.py b/scripts/test_new_article.py index baae7fa..b6788c6 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-05T12:00:00+02:00', + 'lastUpdate': '2024-05-05T12: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 From 859ead15299ff1ae3a4c1dfff57a4efcbbd1041d Mon Sep 17 00:00:00 2001 From: ctmbl Date: Sun, 5 May 2024 18:45:27 +0200 Subject: [PATCH 2/3] Fix lastly introduced regression test expected date formatting --- scripts/test_new_article.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/test_new_article.py b/scripts/test_new_article.py index b6788c6..dbef86d 100644 --- a/scripts/test_new_article.py +++ b/scripts/test_new_article.py @@ -50,8 +50,8 @@ def test_new_article_file_upper_case(mock_requests_post): json={ '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', + '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, From 82fc53917a02a8d6be40e22d3b7f0c27092df9d0 Mon Sep 17 00:00:00 2001 From: ctmbl Date: Sun, 5 May 2024 18:49:09 +0200 Subject: [PATCH 3/3] Fix script --- scripts/new_article.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)