From 6bc2b29c1c70734e5243b065a3fa29db56128c8b Mon Sep 17 00:00:00 2001 From: Nick Moreton Date: Mon, 3 Jan 2022 16:55:06 +0000 Subject: [PATCH] add test for no title available in xml item --- .../test/tests/test_wordpress_item.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wagtail_wordpress_import/test/tests/test_wordpress_item.py b/wagtail_wordpress_import/test/tests/test_wordpress_item.py index f72b2840..41b722c9 100644 --- a/wagtail_wordpress_import/test/tests/test_wordpress_item.py +++ b/wagtail_wordpress_import/test/tests/test_wordpress_item.py @@ -55,6 +55,15 @@ def setUp(self): "wp:post_type": "post", "link": "", } + self.no_title = { + "wp:post_name": "no-title", + "wp:post_date_gmt": "2017-03-12 17:53:57", + "wp:post_modified_gmt": "2018-12-04 11:49:24", + "content:encoded": body_html, + "wp:post_id": "1000", + "wp:post_type": "post", + "link": "http://www.example.com", + } def test_all_fields_with_good_data(self): wordpress_item = WordpressItem(self.good_node, self.logger) @@ -106,6 +115,12 @@ def test_cleaned_fields(self): self.assertIsInstance(latest_revision_created_at, datetime) self.assertEqual(wp_link, "") + def test_no_title_faked(self): + wordpress_item = WordpressItem(self.no_title, self.logger) + title = wordpress_item.cleaned_data["title"] + + self.assertTrue(title.startswith("no-title-available")) + @override_settings( WAGTAIL_WORDPRESS_IMPORTER_SOURCE_DOMAIN="http://localhost:8000", @@ -458,7 +473,6 @@ def test_custom_provided_prefilter_with_options(self): self.assertEqual(output[0], "foo bar baz") self.assertEqual(output[1], {"foo": "bar"}) - @override_settings( WAGTAIL_WORDPRESS_IMPORT_PREFILTERS=[ {