home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2788 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.1 KB  |  47 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import unittest
  5. import sqlite3 as sqlite
  6.  
  7. class DumpTests(unittest.TestCase):
  8.     
  9.     def setUp(self):
  10.         self.cx = sqlite.connect(':memory:')
  11.         self.cu = self.cx.cursor()
  12.  
  13.     
  14.     def tearDown(self):
  15.         self.cx.close()
  16.  
  17.     
  18.     def CheckTableDump(self):
  19.         expected_sqls = [
  20.             'CREATE TABLE t1(id integer primary key, s1 text, t1_i1 integer not null, i2 integer, unique (s1), constraint t1_idx1 unique (i2));',
  21.             'INSERT INTO "t1" VALUES(1,\'foo\',10,20);',
  22.             'INSERT INTO "t1" VALUES(2,\'foo2\',30,30);',
  23.             'CREATE TABLE t2(id integer, t2_i1 integer, t2_i2 integer, primary key (id),foreign key(t2_i1) references t1(t1_i1));',
  24.             'CREATE TRIGGER trigger_1 update of t1_i1 on t1 begin update t2 set t2_i1 = new.t1_i1 where t2_i1 = old.t1_i1; end;',
  25.             'CREATE VIEW v1 as select * from t1 left join t2 using (id);']
  26.         [ self.cu.execute(s) for s in expected_sqls ]
  27.         i = self.cx.iterdump()
  28.         actual_sqls = [ s for s in i ]
  29.         expected_sqls = [
  30.             'BEGIN TRANSACTION;'] + expected_sqls + [
  31.             'COMMIT;']
  32.         [ self.assertEqual(expected_sqls[i], actual_sqls[i]) for i in xrange(len(expected_sqls)) ]
  33.  
  34.  
  35.  
  36. def suite():
  37.     return unittest.TestSuite(unittest.makeSuite(DumpTests, 'Check'))
  38.  
  39.  
  40. def test():
  41.     runner = unittest.TextTestRunner()
  42.     runner.run(suite())
  43.  
  44. if __name__ == '__main__':
  45.     test()
  46.  
  47.