Mercurial > sqlpython
changeset 176:210d01022343
added application testing
author | catherine@dellzilla |
---|---|
date | Tue, 28 Oct 2008 16:06:45 -0400 |
parents | f19e4c198251 |
children | 87eb1c6ed59b |
files | sqlpython/exampleSession.txt sqlpython/mysqlpy.py sqlpython/sqlpyPlus.py |
diffstat | 3 files changed, 76 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sqlpython/exampleSession.txt Tue Oct 28 16:06:45 2008 -0400 @@ -0,0 +1,62 @@ +SQL.No_Connection> connect testschema/testschema@eqtest +testschema@eqtest> CREATE TABLE play ( +> title VARCHAR2(40) CONSTRAINT xpk_play PRIMARY KEY, +> author VARCHAR2(40)); + +Executed + +testschema@eqtest> INSERT INTO play VALUES ('Twelfth Night', 'Shakespeare'); + +Executed (1 rows) + +testschema@eqtest> INSERT INTO play VALUES ('The Tempest', 'Shakespeare'); + +Executed (1 rows) + +testschema@eqtest> INSERT INTO play VALUES ('Agamemnon', 'Aeschylus'); + +Executed (1 rows) + +testschema@eqtest> commit; + +Executed + +testschema@eqtest> select +> * +> from +> play; + +TITLE AUTHOR +------------- ----------- +Twelfth Night Shakespeare +The Tempest Shakespeare +Agamemnon Aeschylus + +3 rows selected. + +testschema@eqtest> ls +INDEX/XPK_PLAY +TABLE/PLAY +testschema@eqtest> ls table +TABLE/PLAY +testschema@eqtest> desc play +TABLE TESTSCHEMA.PLAY + +COLUMN_NAME Null? DATA_TYPE +----------- -------- ------------ +TITLE NOT NULL VARCHAR2(40) +AUTHOR NULL VARCHAR2(40) + +2 rows selected. + +testschema@eqtest> COMMENT ON COLUMN play.author IS 'Primary author (if multiple)'; + +Executed + +testschema@eqtest> COMMENT ON TABLE play IS 'I like plays.'; + +Executed + +#testschema@eqtest> drop table play; + +Executed \ No newline at end of file
--- a/sqlpython/mysqlpy.py Tue Oct 28 15:06:27 2008 -0400 +++ b/sqlpython/mysqlpy.py Tue Oct 28 16:06:45 2008 -0400 @@ -9,7 +9,7 @@ # http://catherine.devlin.googlepages.com/ from sqlpyPlus import * -import binascii, sys, tempfile +import binascii, sys, tempfile, optparse, unittest class mysqlpy(sqlpyPlus): ''' @@ -188,5 +188,16 @@ pass my.cmdloop() +class TestCase(Cmd2TestCase): + CmdApp = mysqlpy + transcriptFileName = 'exampleSession.txt' + if __name__ == '__main__': - run() + parser = optparse.OptionParser() + parser.add_option('-t', '--test', dest='unittests', action='store_true', default=False, help='Run unit test suite') + (callopts, callargs) = parser.parse_args() + if callopts.unittests: + sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() + unittest.main() + else: + run() \ No newline at end of file
--- a/sqlpython/sqlpyPlus.py Tue Oct 28 15:06:27 2008 -0400 +++ b/sqlpython/sqlpyPlus.py Tue Oct 28 16:06:45 2008 -0400 @@ -24,7 +24,7 @@ - catherinedevlin.blogspot.com May 31, 2006 """ import sys, os, re, sqlpython, cx_Oracle, pyparsing, re, completion, datetime, pickle -from cmd2 import Cmd, make_option, options, Statekeeper +from cmd2 import Cmd, make_option, options, Statekeeper, Cmd2TestCase from output_templates import output_templates from plothandler import Plot try: