Skip to content
Snippets Groups Projects
Commit 0cf8c0d2 authored by sandeepsajan0's avatar sandeepsajan0
Browse files

Update tests to add send notice as required field in determination forms

parent 08481e81
No related branches found
No related tags found
No related merge requests found
# Generated by Django 3.2.15 on 2022-09-14 12:33
from django.db import migrations
import wagtail.blocks
import wagtail.blocks.static_block
import wagtail.fields
class Migration(migrations.Migration):
dependencies = [
('determinations', '0013_auto_20220722_0844'),
]
operations = [
migrations.AlterField(
model_name='determination',
name='form_fields',
field=wagtail.fields.StreamField([('rich_text', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.TextBlock(label='Default value', required=False)), ('word_limit', wagtail.blocks.IntegerBlock(default=1000, label='Word limit'))], group='Fields')), ('markdown_text', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.TextBlock(label='Default value', required=False)), ('word_limit', wagtail.blocks.IntegerBlock(default=1000, label='Word limit'))], group='Fields')), ('char', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('format', wagtail.blocks.ChoiceBlock(choices=[('email', 'Email'), ('url', 'URL')], label='Format', required=False)), ('default_value', wagtail.blocks.CharBlock(label='Default value', required=False))], group='Fields')), ('text', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.TextBlock(label='Default value', required=False)), ('word_limit', wagtail.blocks.IntegerBlock(default=1000, label='Word limit'))], group='Fields')), ('text_markup', wagtail.blocks.RichTextBlock(group='Fields', label='Section text/header')), ('checkbox', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.BooleanBlock(required=False))], group='Fields')), ('dropdown', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('choices', wagtail.blocks.ListBlock(wagtail.blocks.CharBlock(label='Choice')))], group='Fields')), ('determination', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('info', wagtail.blocks.static_block.StaticBlock())], group=' Required')), ('message', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('info', wagtail.blocks.static_block.StaticBlock())], group=' Required')), ('send_notice', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('default_value', wagtail.blocks.BooleanBlock(required=True)), ('info', wagtail.blocks.static_block.StaticBlock())], group=' Required'))], default=[], use_json_field=True),
),
migrations.AlterField(
model_name='determinationform',
name='form_fields',
field=wagtail.fields.StreamField([('rich_text', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.TextBlock(label='Default value', required=False)), ('word_limit', wagtail.blocks.IntegerBlock(default=1000, label='Word limit'))], group='Fields')), ('markdown_text', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.TextBlock(label='Default value', required=False)), ('word_limit', wagtail.blocks.IntegerBlock(default=1000, label='Word limit'))], group='Fields')), ('char', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('format', wagtail.blocks.ChoiceBlock(choices=[('email', 'Email'), ('url', 'URL')], label='Format', required=False)), ('default_value', wagtail.blocks.CharBlock(label='Default value', required=False))], group='Fields')), ('text', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.TextBlock(label='Default value', required=False)), ('word_limit', wagtail.blocks.IntegerBlock(default=1000, label='Word limit'))], group='Fields')), ('text_markup', wagtail.blocks.RichTextBlock(group='Fields', label='Section text/header')), ('checkbox', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('default_value', wagtail.blocks.BooleanBlock(required=False))], group='Fields')), ('dropdown', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('required', wagtail.blocks.BooleanBlock(label='Required', required=False)), ('choices', wagtail.blocks.ListBlock(wagtail.blocks.CharBlock(label='Choice')))], group='Fields')), ('determination', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('info', wagtail.blocks.static_block.StaticBlock())], group=' Required')), ('message', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('info', wagtail.blocks.static_block.StaticBlock())], group=' Required')), ('send_notice', wagtail.blocks.StructBlock([('field_label', wagtail.blocks.CharBlock(label='Label')), ('help_text', wagtail.blocks.TextBlock(label='Help text', required=False)), ('help_link', wagtail.blocks.URLBlock(label='Help link', required=False)), ('default_value', wagtail.blocks.BooleanBlock(required=True)), ('info', wagtail.blocks.static_block.StaticBlock())], group=' Required'))], default=[], use_json_field=True),
),
]
...@@ -16,6 +16,11 @@ class TestCreateDeterminationFormView(TestCase): ...@@ -16,6 +16,11 @@ class TestCreateDeterminationFormView(TestCase):
'field_label': factory.Faker('sentence').evaluate(None, None, {'locale': None}), 'field_label': factory.Faker('sentence').evaluate(None, None, {'locale': None}),
'help_text': factory.Faker('sentence').evaluate(None, None, {'locale': None}) 'help_text': factory.Faker('sentence').evaluate(None, None, {'locale': None})
} }
cls.send_notice_data = {
'field_label': factory.Faker('sentence').evaluate(None, None, {'locale': None}),
'help_text': factory.Faker('sentence').evaluate(None, None, {'locale': None}),
'default_value': True,
}
cls.name = factory.Faker('name').evaluate(None, None, {'locale': None}) cls.name = factory.Faker('name').evaluate(None, None, {'locale': None})
def create_page(self, data): def create_page(self, data):
...@@ -30,6 +35,7 @@ class TestCreateDeterminationFormView(TestCase): ...@@ -30,6 +35,7 @@ class TestCreateDeterminationFormView(TestCase):
{ {
'determination': self.label_help_text_data, 'determination': self.label_help_text_data,
'message': self.label_help_text_data, 'message': self.label_help_text_data,
'send_notice': self.send_notice_data,
} }
) )
data.update(form_field_data) data.update(form_field_data)
...@@ -45,6 +51,7 @@ class TestCreateDeterminationFormView(TestCase): ...@@ -45,6 +51,7 @@ class TestCreateDeterminationFormView(TestCase):
form_field_data = create_form_fields_data( form_field_data = create_form_fields_data(
{ {
'message': self.label_help_text_data, 'message': self.label_help_text_data,
'send_notice': self.send_notice_data,
} }
) )
data.update(form_field_data) data.update(form_field_data)
...@@ -60,6 +67,7 @@ class TestCreateDeterminationFormView(TestCase): ...@@ -60,6 +67,7 @@ class TestCreateDeterminationFormView(TestCase):
form_field_data = create_form_fields_data( form_field_data = create_form_fields_data(
{ {
'determination': self.label_help_text_data, 'determination': self.label_help_text_data,
'send_notice': self.send_notice_data,
} }
) )
data.update(form_field_data) data.update(form_field_data)
...@@ -70,12 +78,29 @@ class TestCreateDeterminationFormView(TestCase): ...@@ -70,12 +78,29 @@ class TestCreateDeterminationFormView(TestCase):
self.assertEqual(expected_message, str(message.message).strip()) self.assertEqual(expected_message, str(message.message).strip())
self.assertEqual(DeterminationForm.objects.count(), 0) self.assertEqual(DeterminationForm.objects.count(), 0)
def test_send_notice_block_required(self):
data = {'name': [self.name]}
form_field_data = create_form_fields_data(
{
'determination': self.label_help_text_data,
'message': self.label_help_text_data,
}
)
data.update(form_field_data)
response = self.create_page(data=data)
expected_message = 'You are missing the following required fields: Send Notice'
for message in get_messages(response.context['request']):
self.assertEqual(expected_message, str(message.message).strip())
self.assertEqual(DeterminationForm.objects.count(), 0)
def test_field_label_required(self): def test_field_label_required(self):
data = {'name': [self.name]} data = {'name': [self.name]}
form_field_data = create_form_fields_data( form_field_data = create_form_fields_data(
{ {
'determination': {}, 'determination': {},
'message': {}, 'message': {},
'send_notice': self.send_notice_data,
} }
) )
data.update(form_field_data) data.update(form_field_data)
...@@ -92,6 +117,7 @@ class TestCreateDeterminationFormView(TestCase): ...@@ -92,6 +117,7 @@ class TestCreateDeterminationFormView(TestCase):
{ {
'determination': self.label_help_text_data, 'determination': self.label_help_text_data,
'message': self.label_help_text_data, 'message': self.label_help_text_data,
'send_notice': self.send_notice_data,
} }
) )
data.update(form_field_data) data.update(form_field_data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment