fixed boolean defaults
This commit is contained in:
@@ -442,6 +442,7 @@ class Boolean(Column):
|
|||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
""" Always returns a Python boolean. """
|
""" Always returns a Python boolean. """
|
||||||
|
value = super(Boolean, self).validate(value)
|
||||||
return bool(value)
|
return bool(value)
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
|
|||||||
@@ -78,6 +78,24 @@ class TestDatetime(BaseCassEngTestCase):
|
|||||||
assert dts[0][0] is None
|
assert dts[0][0] is None
|
||||||
|
|
||||||
|
|
||||||
|
class TestBoolDefault(BaseCassEngTestCase):
|
||||||
|
class BoolDefaultValueTest(Model):
|
||||||
|
test_id = Integer(primary_key=True)
|
||||||
|
stuff = Boolean(default=True)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(TestBoolDefault, cls).setUpClass()
|
||||||
|
sync_table(cls.BoolDefaultValueTest)
|
||||||
|
|
||||||
|
def test_default_is_set(self):
|
||||||
|
tmp = self.BoolDefaultValueTest.create(test_id=1)
|
||||||
|
self.assertEqual(True, tmp.stuff)
|
||||||
|
tmp2 = self.BoolDefaultValueTest.get(test_id=1)
|
||||||
|
self.assertEqual(True, tmp2.stuff)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestVarInt(BaseCassEngTestCase):
|
class TestVarInt(BaseCassEngTestCase):
|
||||||
class VarIntTest(Model):
|
class VarIntTest(Model):
|
||||||
test_id = Integer(primary_key=True)
|
test_id = Integer(primary_key=True)
|
||||||
@@ -86,12 +104,12 @@ class TestVarInt(BaseCassEngTestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestVarInt, cls).setUpClass()
|
super(TestVarInt, cls).setUpClass()
|
||||||
create_table(cls.VarIntTest)
|
sync_table(cls.VarIntTest)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
super(TestVarInt, cls).tearDownClass()
|
super(TestVarInt, cls).tearDownClass()
|
||||||
delete_table(cls.VarIntTest)
|
sync_table(cls.VarIntTest)
|
||||||
|
|
||||||
def test_varint_io(self):
|
def test_varint_io(self):
|
||||||
long_int = sys.maxint + 1
|
long_int = sys.maxint + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user