Beispiel #1
0
    def test_from_json_raised_error(self):
        """
        We try to create a ``Formidable`` object with an invalid JSON.
        This will raise a ``ValidationError``.

        """
        with self.assertRaises(ValidationError) as context:
            Formidable.from_json({'json_invalid': True})

        self.assertEqual(len(context.exception.messages), 3)
        for message in context.exception.messages:
            self.assertEqual(message, 'This field is required.')
    def test_from_json_raised_error(self):
        """
        We try to create a ``Formidable`` object with an invalid JSON.
        This will raise a ``ValidationError``.

        """
        with self.assertRaises(ValidationError) as context:
            Formidable.from_json({'json_invalid': True})

        self.assertEqual(len(context.exception.messages), 3)
        for message in context.exception.messages:
            self.assertEqual(message, 'This field is required.')
Beispiel #3
0
    def test_from_json(self):
        """
        We try to build a ``Formidable`` object from a valid JSON.
        We should have an instance of ``Formidable``.

        """
        filepath = join(dirname(__file__),
                        '../fixtures/augmentation_heures.json')
        with open(filepath) as f:
            schema_definition = json.load(f)

        form = Formidable.from_json(schema_definition)

        self.assertTrue(isinstance(form, Formidable))
    def test_from_json(self):
        """
        We try to build a ``Formidable`` object from a valid JSON.
        We should have an instance of ``Formidable``.

        """
        filepath = os.path.join(os.path.dirname(__file__),
                                '../fixtures/augmentation_heures.json')
        with open(filepath) as f:
            schema_definition = json.load(f)

        form = Formidable.from_json(schema_definition)

        self.assertTrue(isinstance(form, Formidable))