Beispiel #1
0
 def test_parse_str_to_str(self):
     col = DateTimeUTCCol('alpha')
     # default
     self.assertEquals(None, col.default_value)
     # parse_str
     d = datetime.datetime(2006,5,30,17,02,13)
     self.assertEquals(d, col.parse_str("2006-05-30T17:02:13Z"))
     self.assertEquals(None, col.parse_str(''))
     # to_str
     self.assertEquals("2006-05-30T17:02:13Z", col.to_str(d))
     self.assertEquals('', col.to_str(None))
Beispiel #2
0
 def test_parse_str_to_str(self):
     col = DateCol('alpha')
     # default
     self.assertEquals(None, col.default_value)
     # parse_str
     d = datetime.date(2006,5,30)
     self.assertEquals(d, col.parse_str("2006-05-30"))
     self.assertEquals(None, col.parse_str(''))
     # to_str
     self.assertEquals("2006-05-30", col.py_to_db(d))
     self.assertEquals('', col.to_str(None))
Beispiel #3
0
 def test_parse_str(self):
     col = AutoIdCol('alpha')
     self.assertEquals(2, col.parse_str('2'))
     try:
         col.parse_str('')
     except ValueError, e:
         self.assert_(
                 str(e) in [
                         "invalid literal for int(): ",
                         "invalid literal for int() with base 10: ''",
                     ]
             )