Skip to content

Commit

Permalink
fixtures: crée toujours la catégorie mère d'une sous-categorie
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemilink authored and artragis committed Aug 21, 2021
1 parent 935ceab commit 3e658da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion zds/tutorialv2/tests/tests_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_list_categories(self):
context_categories = list(resp.context_data["categories"])
self.assertEqual(context_categories[0].contents_count, 10)
self.assertEqual(context_categories[0].subcategories, [subcategory_1, subcategory_2])
self.assertEqual(context_categories, [category_1])
self.assertIn(category_1, context_categories)

def test_private_lists(self):
tutorial = PublishedContentFactory(author_list=[self.user_author])
Expand Down
8 changes: 5 additions & 3 deletions zds/utils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ def _generate(cls, create, attrs):

subcategory = super()._generate(create, attrs)

if category is not None:
relation = CategorySubCategory(category=category, subcategory=subcategory)
relation.save()
if category is None:
category = CategoryFactory()

relation = CategorySubCategory(category=category, subcategory=subcategory)
relation.save()

return subcategory

Expand Down

0 comments on commit 3e658da

Please sign in to comment.