示例#1
0
    def test_base(self):
        value = datetime.now()
        field = DateTimeField()

        value_to_db = field.to_db(value)
        value_to_python = field.to_python(value_to_db)

        self.assertIsInstance(value_to_db, str)
        self.assertIsInstance(value_to_python, datetime)
        self.assertEqual(value_to_python, value)
示例#2
0
    def test_base(self):
        value = datetime.now()
        field = DateTimeField()

        value_to_db = field.to_db(value)
        value_to_python = field.to_python(value_to_db)

        self.assertIsInstance(value_to_db, str)
        self.assertIsInstance(value_to_python, datetime)
        self.assertEqual(value_to_python, value)
示例#3
0
    def test_fail_on_invalid_type(self):
        value = {}
        field = DateTimeField()

        with self.assertRaises(ValidationError):
            field.validate(value)
示例#4
0
    def test_fail_on_invalid_type(self):
        value = {}
        field = DateTimeField()

        with self.assertRaises(ValidationError):
            field.validate(value)