From e04c73b604c9479bca8a8b48b4f887966fadf85c Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Fri, 28 Sep 2018 16:18:24 +0100 Subject: [PATCH] Update tests to be correct for the behaviour of blocks --- opentech/apply/categories/blocks.py | 2 +- opentech/apply/categories/tests/test_blocks.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/opentech/apply/categories/blocks.py b/opentech/apply/categories/blocks.py index b50ebba7e..02359dc54 100644 --- a/opentech/apply/categories/blocks.py +++ b/opentech/apply/categories/blocks.py @@ -77,7 +77,7 @@ class CategoryQuestionBlock(OptionalFormFieldBlock): def render(self, value, context): data = context['data'] category = value['category'] - if data != self.no_response(): + if data: context['data'] = category.options.filter(id__in=data).values_list('value', flat=True) return super().render(value, context) diff --git a/opentech/apply/categories/tests/test_blocks.py b/opentech/apply/categories/tests/test_blocks.py index 979b4df24..c43630801 100644 --- a/opentech/apply/categories/tests/test_blocks.py +++ b/opentech/apply/categories/tests/test_blocks.py @@ -54,7 +54,5 @@ class TestCategoryQuestionBlock(TestCase): ) def test_can_render_if_no_response(self): - context = self.block.get_context(None, {'data': None}) - self.assertEqual(context['data'], self.block.no_response()) - display = self.block.render({'category': self.category}, context) + display = self.block.render({'category': self.category}, {'data': None}) self.assertIn(self.block.no_response()[0], display) -- GitLab