commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7710 - in trunk/gnue-common: doc/technotes src/datasources/drive


From: johannes
Subject: [gnue] r7710 - in trunk/gnue-common: doc/technotes src/datasources/drivers/sql/sqlite tests tests/drivers
Date: Fri, 8 Jul 2005 03:25:17 -0500 (CDT)

Author: johannes
Date: 2005-07-08 03:25:16 -0500 (Fri, 08 Jul 2005)
New Revision: 7710

Added:
   trunk/gnue-common/tests/drivers/
   trunk/gnue-common/tests/drivers/checkem.py
   trunk/gnue-common/tests/drivers/drivers.gsd
   trunk/gnue-common/tests/drivers/drvcheck.gfd
Modified:
   trunk/gnue-common/doc/technotes/00016.txt
   trunk/gnue-common/src/datasources/drivers/sql/sqlite/Behavior.py
   trunk/gnue-common/src/datasources/drivers/sql/sqlite/__init__.py
   trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite2drv.py
   trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlitedrv.py
Log:
Added a simple testsuite for drivers


Modified: trunk/gnue-common/doc/technotes/00016.txt
===================================================================
--- trunk/gnue-common/doc/technotes/00016.txt   2005-07-08 08:12:18 UTC (rev 
7709)
+++ trunk/gnue-common/doc/technotes/00016.txt   2005-07-08 08:25:16 UTC (rev 
7710)
@@ -4,8 +4,8 @@
 Revised: 2005-07-02
 
 
-This technote describes how backend driver map to 'our' datatypes, how they
-treat dates and times.
+This technote describes how backend drivers map to 'our' datatypes and how they
+treat dates, times and strings.
 
 
 I) Mapping and handling of datatypes by databases
@@ -99,6 +99,7 @@
 time        mx.DateTimeDelta     No        No
 datetime    mx.DateTime          No        No
 boolean     int
+string      str
 
 
 pygresql:
@@ -110,6 +111,7 @@
 time        string               No        2 digits [*2]
 datetime    string               No        2 digits [*1]
 boolean     bool
+string      str
 
 [*1] Make sure the decimal separator is set to "." (locale), otherwise writing
      dates, times or datetimes fails with an exception
@@ -127,6 +129,7 @@
 time        mx.DateTimeDelta     2 digits  2 digits [*1]
 datetime    mx.DateTime          2 digits  2 digits [*1]
 boolean     pgBoolean
+string      str
 
 [*1] Make sure the decimal separator is set to "." (locale), otherwise writing
      dates, times or datetimes fails with an exception
@@ -140,6 +143,7 @@
 time        datetime.time        No        0000
 datetime    datetime.datetime    No        0000
 boolean     int
+string      str
 
 
 MySQLdb:
@@ -151,6 +155,7 @@
 time        datetime.timedelta   No        No
 datetime    datetime.datetime    No        No
 boolean     int
+string      unicode
 
 
 sapdb:
@@ -162,6 +167,7 @@
 time        datetime.timedelta   No        No
 datetime    datetime.datetime    6 digits  000000
 boolean     bool
+string      str
 
 
 sqlite2 (SQLite 2):
@@ -173,6 +179,7 @@
 time        mx.DateTimeDelta     2 digits  2 digits truncated
 datetime    mx.DateTime          No        2 digits truncated
 boolean     int
+string      str
 
 
 sqlite3 (SQLite 3):
@@ -184,3 +191,4 @@
 time        datetime.time        6 digits  6 digits
 datetime    datetime.datetime    6 digits  6 digits
 boolean     int
+string      unicode


Property changes on: 
trunk/gnue-common/src/datasources/drivers/sql/sqlite/Behavior.py
___________________________________________________________________
Name: svn:keyword
   + Id


Property changes on: 
trunk/gnue-common/src/datasources/drivers/sql/sqlite/__init__.py
___________________________________________________________________
Name: svn:keyword
   + Id

Modified: trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite2drv.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite2drv.py        
2005-07-08 08:12:18 UTC (rev 7709)
+++ trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite2drv.py        
2005-07-08 08:25:16 UTC (rev 7710)
@@ -19,7 +19,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# $Id: $
+# $Id$
 
 """
 Database driver plugin for SQLite3 backends using the pysqlite2 DBSIG2 module.


Property changes on: 
trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite2drv.py
___________________________________________________________________
Name: svn:keywords
   + Id


Property changes on: 
trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlitedrv.py
___________________________________________________________________
Name: svn:keyword
   + Id


Property changes on: trunk/gnue-common/tests/drivers
___________________________________________________________________
Name: svn:ignore
   + *.pyc


Added: trunk/gnue-common/tests/drivers/checkem.py
===================================================================
--- trunk/gnue-common/tests/drivers/checkem.py  2005-07-08 08:12:18 UTC (rev 
7709)
+++ trunk/gnue-common/tests/drivers/checkem.py  2005-07-08 08:25:16 UTC (rev 
7710)
@@ -0,0 +1,100 @@
+# GNUe Common Library - Test Suite - Database drivers
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+import datetime
+import MySQLdb
+
+from gnue.common.apps.GClientApp import GClientApp
+
+class BackendCheck (GClientApp):
+
+  def __init__ (self, connections = None):
+
+    self.addCommandOption ('connection', 'c', argument='connectionname',
+        default = "gnue",
+        help = _("Use the connection <connectionname> for creating the 
schema"))
+
+    GClientApp.__init__ (self, connections, 'common', {})
+
+  # ---------------------------------------------------------------------------
+  #
+  # ---------------------------------------------------------------------------
+
+  def run (self):
+
+    cname     = self.OPTIONS ['connection']
+    self.conn = self.connections.getConnection (cname, True)
+
+    cursor = self.conn.makecursor ('SELECT * from drvCheck')
+
+    print "Description:"
+    print "-" * 75
+
+    for item in cursor.description:
+      print item
+
+    print "-" * 75
+
+    for (ix, rec) in enumerate (cursor.fetchall ()):
+      print "Record:", ix
+      for item in rec:
+        print item, type (item)
+      print "-" * 75
+
+    self.writeCheck ()
+
+
+  def writeCheck (self):
+    """
+    """
+    
+    cursor = self.conn.makecursor ('SELECT id FROM drvCheck WHERE id = 3')
+    if cursor.fetchall ():
+      cursor = self.conn.makecursor ('DELETE FROM drvCheck WHERE id = 3')
+
+    adate = datetime.date (2004, 10, 22)
+    atime = datetime.time (17, 23, 45, 453678)
+    datim = datetime.datetime (2005, 6, 20, 11, 12, 13, 214365)
+
+    cmd = "INSERT INTO drvCheck (id, adate, atime, adatetime) " \
+          "VALUES (%(id)s, %(adate)s, %(atime)s, %(adatetime)s)"
+    params = {'id': 3, 'adate': adate, 'atime': atime, 'adatetime': datim}
+
+    cursor = self.conn.makecursor (cmd, params)
+
+    self.conn.commit ()
+
+    # ------------------------------------------------------------------------
+    cmd = "UPDATE drvCheck set name = %(name)s WHERE id = %(id)s"
+    params = {'name': u'Fred\xf6 has \u20ac 200,-', 'id': 3}
+
+    cursor = self.conn.makecursor (cmd, params)
+
+    self.conn.commit ()
+
+
+
+
+
+if __name__ == '__main__':
+  BackendCheck ().run ()


Property changes on: trunk/gnue-common/tests/drivers/checkem.py
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keyword
   + Id
Name: svn:keywords
   + Id

Added: trunk/gnue-common/tests/drivers/drivers.gsd
===================================================================
--- trunk/gnue-common/tests/drivers/drivers.gsd 2005-07-08 08:12:18 UTC (rev 
7709)
+++ trunk/gnue-common/tests/drivers/drivers.gsd 2005-07-08 08:25:16 UTC (rev 
7710)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema>
+  <tables>
+    <table name="drvCheck">
+      <fields>
+        <field name="id" type="number" length="8" nullable="False"/>
+        <field name="name" type="string" length="30"/>
+        <field name="adate" type="date" />
+        <field name="atime" type="time" />
+        <field name="adatetime" type="datetime" />
+        <field name="afloat" type="number" length="7" precision="2" />
+        <field name="awhole" type="number" length="6" />
+        <field name="aflag" type="boolean" />
+      </fields>
+      <primarykey name="pk_drvCheck">
+        <pkfield name="id" />
+      </primarykey>
+    </table>
+  </tables>
+
+  <data>
+    <tabledata name="drvSamples" tablename="drvCheck">
+      <rows>
+        <row>
+          <value field="id">1</value>
+          <value field="name">John Doe</value>
+          <value field="adate">2005-04-23</value>
+          <value field="atime">17:24:45.127</value>
+          <value field="adatetime">2001-11-18T14:23:56.217654</value>
+          <value field="afloat">42.11</value>
+          <value field="awhole">27</value>
+          <value field="aflag">TRUE</value>
+        </row>
+        <row>
+          <value field="id">2</value>
+          <value field="name">Möchtegern € 100,-</value>
+          <value field="adate">2005-07-20</value>
+          <value field="atime">09:08:07.45</value>
+          <value field="adatetime">2002-10-08T03:04:05.67</value>
+          <value field="afloat">11.42</value>
+          <value field="awhole">72</value>
+          <value field="aflag">FALSE</value>
+        </row>
+      </rows>
+    </tabledata>
+  </data>
+</schema>

Added: trunk/gnue-common/tests/drivers/drvcheck.gfd
===================================================================
--- trunk/gnue-common/tests/drivers/drvcheck.gfd        2005-07-08 08:12:18 UTC 
(rev 7709)
+++ trunk/gnue-common/tests/drivers/drvcheck.gfd        2005-07-08 08:25:16 UTC 
(rev 7710)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<form title="GNUe Application Server test">
+  <options>
+    <author>GNU Enterprise Common Test Suite</author>
+    <version>1.0</version>
+    <description>Testform for database driver checks</description>
+  </options>
+
+  <datasource name="dtsCheck" connection="gnue" table="drvCheck"
+    prequery="Y" order_by="id"/>
+
+  <logic>
+    <block name="blkCheck" datasource="dtsCheck" >
+      <field name="fldId"       field="id" typecast="number"/>
+      <field name="fldName"     field="name" max_length="30"/>
+      <field name="fldDate"     field="adate" typecast="date"/>
+      <field name="fldTime"     field="atime" typecast="date"/>
+      <field name="fldDatetime" field="adatetime" typecast="date"/>
+      <field name="fldFloat"    field="afloat" typecast="number"/>
+      <field name="fldWhole"    field="awhole" typecast="number"/>
+      <field name="fldFlag"     field="aflag" />
+    </block>
+  </logic>
+
+  <layout xmlns:c="GNUe:Layout:Char" c:height="14" c:width="75" >
+    <page name="pgSample" caption="Samples">
+      <label c:height="1" c:width="9"  c:x="1" c:y="1"  text="Id:"/>
+      <label c:height="1" c:width="9"  c:x="1" c:y="2"  text="Name:"/>
+      <label c:height="1" c:width="9"  c:x="1" c:y="3"  text="Date:"/>
+      <label c:height="1" c:width="9"  c:x="1" c:y="4"  text="Time:"/>
+      <label c:height="1" c:width="9"  c:x="1" c:y="5"  text="Datetime:"/>
+      <label c:height="1" c:width="9"  c:x="1" c:y="6"  text="Float:"/>
+      <label c:height="1" c:width="9"  c:x="1" c:y="7"  text="Whole:"/>
+      <label c:height="1" c:width="9"  c:x="1" c:y="8"  text="Flag:"/>
+
+      <entry c:height="1" c:width="10" c:x="14" c:y="1" block="blkCheck"
+        field="fldId" />
+      <entry c:height="1" c:width="30" c:x="14" c:y="2" block="blkCheck"
+        field="fldName" />
+      <entry c:height="1" c:width="8" c:x="14" c:y="3" block="blkCheck"
+        field="fldDate" displaymask="%x" inputmask="%x"/>
+      <entry c:height="1" c:width="25" c:x="14" c:y="4" block="blkCheck"
+        field="fldTime" displaymask="%X" inputmask="%X"/>
+      <entry c:height="1" c:width="25" c:x="14" c:y="5" block="blkCheck"
+        field="fldDatetime" displaymask="%x %X" inputmask="%x %X"/>
+      <entry c:height="1" c:width="15" c:x="14" c:y="6" block="blkCheck"
+        field="fldFloat"/>
+      <entry c:height="1" c:width="15" c:x="14" c:y="7" block="blkCheck"
+        field="fldWhole"/>
+      <entry c:height="1" c:width="2" c:x="14" c:y="8" block="blkCheck"
+        field="fldFlag" style="checkbox"/>
+    </page>
+
+  </layout>
+</form>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]