diff --git a/opentech/apply/categories/tests.py b/opentech/apply/categories/tests.py deleted file mode 100644 index a79ca8be565f44aacce95bad20c1ee34d175ed20..0000000000000000000000000000000000000000 --- a/opentech/apply/categories/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.test import TestCase - -# Create your tests here. diff --git a/opentech/apply/categories/tests/__init__.py b/opentech/apply/categories/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/opentech/apply/categories/tests/factories.py b/opentech/apply/categories/tests/factories.py new file mode 100644 index 0000000000000000000000000000000000000000..f1bba28f7c152d4b20a1b8c5d3d743e6934054f0 --- /dev/null +++ b/opentech/apply/categories/tests/factories.py @@ -0,0 +1,11 @@ +import factory + +from ..models import Category + + +class CategoryFactory(factory.DjangoModelFactory): + class Meta: + model = Category + + name = factory.Faker('word') + help_text = factory.Faker('sentence') diff --git a/opentech/apply/categories/tests/test_blocks.py b/opentech/apply/categories/tests/test_blocks.py new file mode 100644 index 0000000000000000000000000000000000000000..19c3aff8d4d1c593de5662bd0ea7d9f821f569e0 --- /dev/null +++ b/opentech/apply/categories/tests/test_blocks.py @@ -0,0 +1,25 @@ +from django.test import TestCase + +from opentech.apply.categories.blocks import CategoryQuestionBlock + +from .factories import CategoryFactory + + +class TestCategoryQuestionBlock(TestCase): + @classmethod + def setUp(self): + self.category = CategoryFactory() + self.block = CategoryQuestionBlock() + + def test_field_and_help_default(self): + block = self.block.to_python({ + 'field_label': '', + 'help_text': '', + 'category': self.category.id, + 'multi': False, + }) + + field = self.block.get_field(block) + + self.assertEqual(self.category.name, field.label) + self.assertEqual(self.category.help_text, field.help_text)