コード例 #1
0
ファイル: test_fields.py プロジェクト: kamail05/Auto_Git
    def test_text_field_invalid_data(self):
        """Setting TextField data to something to a number should raise InvalidField"""

        testfield = TextField('Title')

        try:
            testfield.validate(6)
            self.fail('Setting TextField data to a number should raise InvalidField')
        except InvalidField:
            pass
コード例 #2
0
ファイル: test_fields.py プロジェクト: kamail05/Auto_Git
    def test_text_field(self):
        """Should be able to initialize charfield and set data"""

        testfield = TextField('Title')

        data = 'This is a longer sentence than the one further up\nthis file'

        try:
            testfield.validate(data)
        except InvalidField:
            self.fail('Field data is valid, exception should not have been thrown')

        self.assertEqual(testfield.to_json(data), 'This is a longer sentence than the one further up\nthis file')
        self.assertEqual(testfield.prepare_data(data), 'This is a longer sentence than the one further up\nthis file')