diff options
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 50 | 
1 files changed, 49 insertions, 1 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 6a96ebdf4..40e50f42b 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -42,7 +42,7 @@ from ishtar_common.models import OrganizationType, Organization, ItemKey, \      Town, ImporterColumn, Person, Author, SourceType, AuthorType, \      DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, \      JsonDataSection, ImportTarget, FormaterType, CustomForm, ExcludedField, \ -    UserProfile, ProfileType, Area +    UserProfile, ProfileType, Area, CustomFormJsonField  from archaeological_files.models import File, FileType  from archaeological_context_records.models import Unit, ContextRecord @@ -1362,6 +1362,54 @@ class CustomFormTest(TestCase, OperationInitTest):          response = c.post(url, data)          self.assertEqual(response.status_code, 404) +    def test_json(self): +        operation = self.operations[0] +        operation.data = {"groundhog": {"number": 53444, +                                        "awake_state": u"réveillée", +                                        "with_feather": "Oui"}, +                          "frog_number": 32303} +        operation.save() + +        content_type = ContentType.objects.get_for_model(operation) +        field = JsonDataField.objects.create( +            name=u"État d'éveil", key='groundhog__awake_state', +            content_type=content_type, value_type='C') +        form = CustomForm.objects.create( +            name="Test", form="operation-010-general", available=True, +            apply_to_all=True) +        CustomFormJsonField.objects.create( +            custom_form=form, +            json_field=field, +            label="Le beau", +        ) + +        c = Client() +        c.login(username=self.username, password=self.password) + +        cls_wiz = OperationWizardModifTest +        url = reverse(cls_wiz.url_name) +        # first wizard step +        step = 'selec-operation_modification' +        cls_wiz.wizard_post(c, url, step, {'pk': self.operations[0].pk}) + +        step = 'general-operation_modification' +        data = { +            '{}{}-current_step'.format(cls_wiz.url_name, +                                       cls_wiz.wizard_name): [step], +        } +        response = c.post(url, data) +        self.assertIn( +            "Le beau", response.content, +            msg="json field not displayed on modification wizard" +        ) + +        cls_wiz.wizard_post(c, url, step, {'pk': self.operations[1].pk}) +        response = c.post(url, data) +        self.assertIn( +            "Le beau", response.content, +            msg="json field form: existing value should be presented in select" +        ) +  class OperationSearchTest(TestCase, OperationInitTest):      fixtures = FILE_FIXTURES | 
