Beispiel #1
0
 def testIntervalOut(self):
     self.cursor.execute(
         "SELECT '1 month 16 days 12 hours 32 minutes 64 seconds'"
         "::interval")
     retval = self.cursor.fetchall()
     expected_value = types.Interval(
         microseconds=(12 * 60 * 60 * 1000 * 1000) +
         (32 * 60 * 1000 * 1000) + (64 * 1000 * 1000),
         days=16,
         months=1)
     self.assertEqual(retval[0][0], expected_value)
Beispiel #2
0
 def testBinaryOutputMethods(self):
     methods = (
         ("float8send", 22.2),
         ("timestamp_send", datetime.datetime(2001, 2, 3, 4, 5, 6, 789)),
         ("byteasend", dbapi.Binary("\x01\x02")),
         ("interval_send", types.Interval(1234567, 123, 123)),
     )
     for method_out, value in methods:
         self.cursor.execute("SELECT %s(%%s) as f1" % method_out, (value, ))
         retval = self.cursor.fetchall()
         self.assert_(retval[0][0] == getattr(types, method_out)(
             value, integer_datetimes=db.conn.c._integer_datetimes))
Beispiel #3
0
 def testIntervalOut(self):
     self.cursor.execute(
         "SELECT '1 month 16 days 12 hours 32 minutes 64 seconds'::interval"
     )
     retval = self.cursor.fetchall()
     expected_value = types.Interval(
         microseconds=(12 * 60 * 60 * 1000 * 1000) +
         (32 * 60 * 1000 * 1000) + (64 * 1000 * 1000),
         days=16,
         months=1)
     self.assert_(retval[0][0] == expected_value,
                  "retrieved value match failed")
Beispiel #4
0
 def testBinaryOutputMethods(self):
     methods = (
         ("float8send", 22.2),
         ("timestamp_send", datetime.datetime(2001, 2, 3, 4, 5, 6, 789)),
         ("byteasend", dbapi.Binary(b("\x01\x02"))),
         ("interval_send", types.Interval(1234567, 123, 123)),
     )
     for method_out, value in methods:
         self.cursor.execute("SELECT %s(%%s) as f1" % method_out, (value, ))
         retval = self.cursor.fetchall()
         self.assertEqual(retval[0][0],
                          self.db.make_params((value, ))[0][2](value))
Beispiel #5
0
 def testIntervalRoundtrip(self):
     v = types.Interval(microseconds=123456789, days=2, months=24)
     self.cursor.execute("SELECT %s as f1", (v, ))
     retval = self.cursor.fetchall()
     self.assert_(retval[0][0] == v, "retrieved value match failed")
Beispiel #6
0
 def testIntervalRoundtrip(self):
     v = types.Interval(microseconds=123456789, days=2, months=24)
     self.cursor.execute("SELECT %s as f1", (v, ))
     retval = self.cursor.fetchall()
     self.assertEqual(retval[0][0], v)