Skip to content

Commit

Permalink
add test for no title available in xml item
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmoreton committed Jan 3, 2022
1 parent 10e4c17 commit 6bc2b29
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion wagtail_wordpress_import/test/tests/test_wordpress_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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=[
{
Expand Down

0 comments on commit 6bc2b29

Please sign in to comment.