From 5f4566e5989c24e651bc6f1aecad0a9bcb22411f Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Wed, 31 May 2023 19:08:05 +0300 Subject: [PATCH] add tests for header fields drop --- .../converter/wordpress_markdown_test.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/tests/converter/wordpress_markdown_test.py b/app/tests/converter/wordpress_markdown_test.py index 8f751de..4e3d414 100644 --- a/app/tests/converter/wordpress_markdown_test.py +++ b/app/tests/converter/wordpress_markdown_test.py @@ -25,3 +25,25 @@ def test_fix_hugo_header_rewrite_author(author_rewrite, input_header, expected_h ) converter = WordpressMarkdownConverter(configurator) assert converter.fix_hugo_header(input_header) == expected_header + + +@pytest.mark.parametrize( + "header_fields_drop, input_header, expected_header", + [ + ([], {}, {"author": ""}), + (["a"], {"a": 1, "b": 2, "c": 3}, {"author": "", "b": 2, "c": 3}), + (["a", "b"], {"a": 1, "b": 2, "c": 3}, {"author": "", "c": 3}), + ([], {"a": 1, "b": 2, "c": 3}, {"author": "", "a": 1, "b": 2, "c": 3}), + ], +) +def test_fix_hugo_header_fields_drop(header_fields_drop, input_header, expected_header): + configurator = make_fake_configurator( + "wordpress_markdown_converter", + ConverterOptions( + author_rewrite="", + links_rewrite=[], + header_fields_drop=header_fields_drop, + ), + ) + converter = WordpressMarkdownConverter(configurator) + assert converter.fix_hugo_header(input_header) == expected_header