def test_datetimes(self):

        r = Date(datetime.datetime(2014, 2, 2, 12, 12,
                                   12)) > datetime.datetime(
                                       2014, 2, 2, 12, 12, 13)

        self.assertEqual(r.type(), Bool)
        self.assertEqual(r.as_sql(), '1391343132 > 1391343133')
    def test_date(self):
        self.assertRaises(TypeError, Date, 2)
        self.assertRaises(TypeError, Date, 'sql injection')

        try:
            Date(datetime.date(2013, 2, 2))
        except TypeError:
            self.fail("Date() raised TypeError on date.")

        try:
            Date(datetime.datetime.utcnow())
        except TypeError:
            self.fail("Date() raised TypeError on datetime.")
    def test_dates(self):

        date = datetime.date(2014, 2, 2)

        db_value = int(Date(date).as_sql())
        self.assertEqual(Date.to_python(db_value), date)
 def test_wrong_type(self):
     self.assertRaises(TypeError, Date.__lt__,
                       Date(datetime.datetime(2014, 2, 2)), And)
    def test_dates(self):

        r = Date(datetime.date(2014, 2, 2)) > datetime.date(2014, 3, 2)

        self.assertEqual(r.type(), Bool)
        self.assertEqual(r.as_sql(), '1391299200 > 1393718400')
示例#6
0
    def test_datetimes(self):

        r = Date(datetime.datetime(2014, 2, 2, 12, 12, 12)) > datetime.datetime(2014, 2, 2, 12, 12, 13)

        self.assertEqual(r.type(), Bool)
        self.assertEqual(r.as_sql(), '1391343132 > 1391343133')
示例#7
0
    def test_dates(self):

        r = Date(datetime.date(2014, 2, 2)) > datetime.date(2014, 3, 2)

        self.assertEqual(r.type(), Bool)
        self.assertEqual(r.as_sql(), '1391299200 > 1393718400')