def test_get_mapped_data_no_display(self):
     try:
         key = 'tests.test_forms.CharField'
         registry.register(CharField)
         fm = FormModel.objects.create(name='Form', submit_url='/form/')
         FormFieldModel.objects.create(
             parent_form=fm,
             label='Label 1',
             field_type='dynamic_forms.formfields.SingleLineTextField',
             position=1)
         FormFieldModel.objects.create(parent_form=fm,
                                       label='Label 2',
                                       field_type=key,
                                       position=2)
         data = {
             'label-1': 'Value 1',
             'label-2': 'NOT SHOWN!',
         }
         form = FormModelForm(model=fm, data=data)
         self.assertTrue(form.is_valid())
         self.assertEqual(form.get_mapped_data(),
                          OrderedDict([
                              (
                                  'Label 1',
                                  'Value 1',
                              ),
                          ]))
     finally:
         registry.unregister(key)
 def test_get_mapped_data_no_display(self):
     try:
         key = "tests.test_forms.CharField"
         registry.register(CharField)
         fm = FormModel.objects.create(name="Form", submit_url="/form/")
         FormFieldModel.objects.create(
             parent_form=fm, label="Label 1", field_type="dynamic_forms.formfields.SingleLineTextField", position=1
         )
         FormFieldModel.objects.create(parent_form=fm, label="Label 2", field_type=key, position=2)
         data = {"label-1": "Value 1", "label-2": "NOT SHOWN!"}
         form = FormModelForm(model=fm, data=data)
         self.assertTrue(form.is_valid())
         self.assertEqual(form.get_mapped_data(), OrderedDict([("Label 1", "Value 1")]))
     finally:
         registry.unregister(key)
 def test_get_mapped_data_no_display(self):
     try:
         key = 'tests.test_forms.CharField'
         registry.register(CharField)
         fm = FormModel.objects.create(name='Form', submit_url='/form/')
         FormFieldModel.objects.create(parent_form=fm, label='Label 1',
             field_type='dynamic_forms.formfields.SingleLineTextField',
             position=1)
         FormFieldModel.objects.create(parent_form=fm, label='Label 2',
             field_type=key, position=2)
         data = {
             'label-1': 'Value 1',
             'label-2': 'NOT SHOWN!',
         }
         form = FormModelForm(model=fm, data=data)
         self.assertTrue(form.is_valid())
         self.assertEqual(form.get_mapped_data(), OrderedDict([
             ('Label 1', 'Value 1',),
         ]))
     finally:
         registry.unregister(key)
    def test_unregister(self):
        key = 'tests.test_formfields.CharField'
        registry.register(CharField)
        registry.unregister(key)

        self.assertIsNone(registry.get(key))
 def test_register(self):
     registry.register(CharField)
     cls = registry.get('tests.test_formfields.CharField')
     self.assertEqual(cls, CharField)
     self.assertEqual(cls.get_display_label(), 'Char')
    def test_unregister(self):
        key = 'tests.test_formfields.CharField'
        registry.register(CharField)
        registry.unregister(key)

        self.assertIsNone(registry.get(key))
 def test_register(self):
     registry.register(CharField)
     cls = registry.get('tests.test_formfields.CharField')
     self.assertEqual(cls, CharField)
     self.assertEqual(cls.get_display_label(), 'Char')