Skip to content

Commit

Permalink
updated tests to account for changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfmiranda committed Jun 14, 2024
1 parent 909b45f commit be309d5
Showing 1 changed file with 196 additions and 24 deletions.
220 changes: 196 additions & 24 deletions network-api/networkapi/reports/tests/test_block_type_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def test_view(self):
block["content_types"],
)

# Two pages have crated ImageBlocks
# Each ImageBlock has a ImageChooserBlock and a CharBlock
# These should be in alphabetical order since they all have the same count
# Two pages have created AnnotatedImageBlocks
block = object_list[1]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.annotated_image_block.AnnotatedImageBlock"
Expand All @@ -74,6 +72,7 @@ def test_view(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# RadioSelectBlock is used in AnnotatedImageBlock
block = object_list[2]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.annotated_image_block.RadioSelectBlock"
Expand All @@ -83,6 +82,7 @@ def test_view(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# LinkBlockWithoutLabel is used in AnnotatedImageBlock
block = object_list[3]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.link_block.LinkWithoutLabelBlock"
Expand All @@ -92,37 +92,77 @@ def test_view(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# BooleanBlock is used in LinkBlockWithoutLabel
block = object_list[4]
self.assertEqual(block["block"], "wagtail.images.blocks.ImageChooserBlock")
self.assertEqual(block["block"], "wagtail.blocks.field_block.BooleanBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# FInally, we have the AirTableBlock, use only in one page
# This one is made of a URLBlock and a IntegerBlock
# CharBlock is used in LinkBlockWithoutLabel
block = object_list[5]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.airtable_block.AirTableBlock"
)
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Custom")
self.assertTrue(block["is_custom_block"])
self.assertListEqual([primary_page.content_type], block["content_types"])
self.assertEqual(block["block"], "wagtail.blocks.field_block.CharBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# ChoiceBlock is used in LinkBlockWithoutLabel
block = object_list[6]
self.assertEqual(block["block"], "wagtail.blocks.field_block.IntegerBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["block"], "wagtail.blocks.field_block.ChoiceBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type], block["content_types"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# EmailBlock is used in LinkBlockWithoutLabel
block = object_list[7]
self.assertEqual(block["block"], "wagtail.blocks.field_block.EmailBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# PageChooserBlock is used in LinkBlockWithoutLabel
block = object_list[8]
self.assertEqual(block["block"], "wagtail.blocks.field_block.PageChooserBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# URLBlock is used in LinkBlockWithoutLabel
block = object_list[9]
self.assertEqual(block["block"], "wagtail.blocks.field_block.URLBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type], block["content_types"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# ListBlock is used to wrap LinkBlockWithoutLabel in AnnotatedImageBlock
block = object_list[10]
self.assertEqual(block["block"], "wagtail.blocks.list_block.ListBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# DocumentChooserBlock is used in LinkBlockWithoutLabel
block = object_list[11]
self.assertEqual(block["block"], "wagtail.documents.blocks.DocumentChooserBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

# ImageChooserBlock is used in AnnotatedImageBlock
block = object_list[12]
self.assertEqual(block["block"], "wagtail.images.blocks.ImageChooserBlock")
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

def test_page_unpublished(self):
"""Tests that the queryset is updated when a page is unpublished"""
Expand Down Expand Up @@ -156,9 +196,8 @@ def test_page_unpublished(self):
block["content_types"],
)

# Two pages have crated ImageBlocks
# Each ImageBlock has a ImageChooserBlock and a CharBlock
# These should be in alphabetical order since they all have the same count
# The remaining blocks should only appear on the campaign page
# The campaign page is using an AnnotatedImageBlock
block = object_list[1]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.annotated_image_block.AnnotatedImageBlock"
Expand All @@ -168,6 +207,7 @@ def test_page_unpublished(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# RadioSelectBlock is used in AnnotatedImageBlock
block = object_list[2]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.annotated_image_block.RadioSelectBlock"
Expand All @@ -177,6 +217,7 @@ def test_page_unpublished(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# LinkBlockWithoutLabel is used in AnnotatedImageBlock
block = object_list[3]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.link_block.LinkWithoutLabelBlock"
Expand All @@ -186,7 +227,72 @@ def test_page_unpublished(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# BooleanBlock is used in LinkBlockWithoutLabel
block = object_list[4]
self.assertEqual(block["block"], "wagtail.blocks.field_block.BooleanBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# CharBlock is used in LinkBlockWithoutLabel
block = object_list[5]
self.assertEqual(block["block"], "wagtail.blocks.field_block.CharBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# ChoiceBlock is used in LinkBlockWithoutLabel
block = object_list[6]
self.assertEqual(block["block"], "wagtail.blocks.field_block.ChoiceBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# EmailBlock is used in LinkBlockWithoutLabel
block = object_list[7]
self.assertEqual(block["block"], "wagtail.blocks.field_block.EmailBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# PageChooserBlock is used in LinkBlockWithoutLabel
block = object_list[8]
self.assertEqual(block["block"], "wagtail.blocks.field_block.PageChooserBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# URLBlock is used in LinkBlockWithoutLabel
block = object_list[9]
self.assertEqual(block["block"], "wagtail.blocks.field_block.URLBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# ListBlock is used to wrap LinkBlockWithoutLabel in AnnotatedImageBlock
block = object_list[10]
self.assertEqual(block["block"], "wagtail.blocks.list_block.ListBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# DocumentChooserBlock is used in LinkBlockWithoutLabel
block = object_list[11]
self.assertEqual(block["block"], "wagtail.documents.blocks.DocumentChooserBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# ImageChooserBlock is used in AnnotatedImageBlock
block = object_list[12]
self.assertEqual(block["block"], "wagtail.images.blocks.ImageChooserBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
Expand Down Expand Up @@ -228,9 +334,8 @@ def test_page_deleted(self):
block["content_types"],
)

# Two pages have crated ImageBlocks
# Each ImageBlock has a ImageChooserBlock and a LinkWithoutLabelBlock
# These should be in alphabetical order since they all have the same count
# The remaining blocks should only appear on the campaign page
# The campaign page is using an AnnotatedImageBlock
block = object_list[1]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.annotated_image_block.AnnotatedImageBlock"
Expand All @@ -240,6 +345,7 @@ def test_page_deleted(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# RadioSelectBlock is used in AnnotatedImageBlock
block = object_list[2]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.annotated_image_block.RadioSelectBlock"
Expand All @@ -249,6 +355,7 @@ def test_page_deleted(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# LinkBlockWithoutLabel is used in AnnotatedImageBlock
block = object_list[3]
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.link_block.LinkWithoutLabelBlock"
Expand All @@ -258,7 +365,72 @@ def test_page_deleted(self):
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# BooleanBlock is used in LinkBlockWithoutLabel
block = object_list[4]
self.assertEqual(block["block"], "wagtail.blocks.field_block.BooleanBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# CharBlock is used in LinkBlockWithoutLabel
block = object_list[5]
self.assertEqual(block["block"], "wagtail.blocks.field_block.CharBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# ChoiceBlock is used in LinkBlockWithoutLabel
block = object_list[6]
self.assertEqual(block["block"], "wagtail.blocks.field_block.ChoiceBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# EmailBlock is used in LinkBlockWithoutLabel
block = object_list[7]
self.assertEqual(block["block"], "wagtail.blocks.field_block.EmailBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# PageChooserBlock is used in LinkBlockWithoutLabel
block = object_list[8]
self.assertEqual(block["block"], "wagtail.blocks.field_block.PageChooserBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# URLBlock is used in LinkBlockWithoutLabel
block = object_list[9]
self.assertEqual(block["block"], "wagtail.blocks.field_block.URLBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# ListBlock is used to wrap LinkBlockWithoutLabel in AnnotatedImageBlock
block = object_list[10]
self.assertEqual(block["block"], "wagtail.blocks.list_block.ListBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# DocumentChooserBlock is used in LinkBlockWithoutLabel
block = object_list[11]
self.assertEqual(block["block"], "wagtail.documents.blocks.DocumentChooserBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

# ImageChooserBlock is used in AnnotatedImageBlock
block = object_list[12]
self.assertEqual(block["block"], "wagtail.images.blocks.ImageChooserBlock")
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
Expand Down

0 comments on commit be309d5

Please sign in to comment.