Skip to content

Commit

Permalink
Merge pull request #151 from torchbox/fix/148-category-is-integer
Browse files Browse the repository at this point in the history
Category names that are numbers
  • Loading branch information
nickmoreton authored Jan 27, 2022
2 parents 3fa1b52 + 04fae66 commit 415d6dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions wagtail_wordpress_import/importers/wordpress.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ def get_page(self, link, page):
def connect_page_categories(self, page, category_model, item):
if "category" in item.keys():
categories = [
category
str(category)
for category in item["category"]
if category and len(category) > category_name_min_length()
if category and len(str(category)) > category_name_min_length()
]

page_categories = []
Expand Down
1 change: 1 addition & 0 deletions wagtail_wordpress_import/test/fixtures/raw_xml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Nihil hic munitissimus habendi senatus locus, nihil horum?.&lt;/blockquote&gt;</
<category domain="category" nicename="blogging">Blogging</category>
<category domain="category" nicename="life">Life</category>
<category domain="category" nicename="a">A</category>
<category domain="category" nicename="2016">2016</category>
<category domain="" nicename="an-empty-category-should-not-be-imported-or-linked"></category>
<wp:postmeta>
<wp:meta_key>_wp_attachment_image_alt</wp:meta_key>
Expand Down
5 changes: 3 additions & 2 deletions wagtail_wordpress_import/test/tests/test_wordpress_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ def setUp(self):

def test_category_snippets_are_saved(self):
snippets = Category.objects.all()
self.assertEqual(len(snippets), 4)
self.assertEqual(len(snippets), 5)

def test_page_one_has_categories(self):
page_one = self.imported_pages.get(title="Item one title")
categories = page_one.specific.categories.all()
self.assertEqual(2, categories.count())
self.assertEqual(3, categories.count())
self.assertEqual(categories[0].name, "Blogging")
self.assertEqual(categories[1].name, "Life")
self.assertEqual(categories[2].name, "2016")

def test_page_two_has_categories(self):
page_two = self.imported_pages.get(title="Item two title")
Expand Down

0 comments on commit 415d6dc

Please sign in to comment.