def test_clean(self):
        m = Blog(title='Horse', body='Horses are nice')

        with self.assertRaises(ValidationError) as e:
            m.full_clean()

        self.assertEquals(list(e.exception),
                          [('title_nl', ['This field cannot be null.'])])

        # With an added `title_nl`, it should validate.
        m.title_nl = 'Paard'
        m.full_clean()
    def test_clean(self):
        '''
        Blog has required_languages=('nl', ), so this should raise an error
        if `title_nl` is not set.
        '''
        m = Blog(title='Horse', body='Horses are nice')

        with self.assertRaises(ValidationError) as e:
            m.full_clean()

        self.assertEquals(
            {(field, tuple(errors)) for field, errors in e.exception},
            {
                ('title_nl', ('This field cannot be null.', )),
                ('body_nl', ('This field cannot be null.', ))
            }
        )

        # With an added `title_nl`, it should validate.
        m.title_nl = 'Paard'
        m.body_nl = 'foo'
        m.full_clean()
    def test_clean_required_languages_list(self):
        """
        Blog has required_languages=('nl', ), so this should raise an error
        if `title_nl` is not set.
        """
        m = Blog(title="Horse", body="Horses are nice")

        with self.assertRaises(ValidationError) as e:
            m.full_clean()

        self.assertEqual(
            {(field, tuple(errors))
             for field, errors in e.exception},
            {
                ("title_nl", ("This field cannot be null.", )),
                ("body_nl", ("This field cannot be null.", )),
            },
        )

        # With an added `title_nl`, it should validate.
        m.title_nl = "Paard"
        m.body_nl = "foo"
        m.full_clean()