Mercurial > p > roundup > code
comparison test/test_postgresql.py @ 6605:3f13ddd98e5c
Replace does_index_exist with db.sql_index_exists.
Use pre-existing function and remove the one I wrote.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 27 Jan 2022 22:21:17 -0500 |
| parents | 0d99ae7c8de6 |
| children | 2a3bd715bbeb |
comparison
equal
deleted
inserted
replaced
| 6604:0d99ae7c8de6 | 6605:3f13ddd98e5c |
|---|---|
| 66 | 66 |
| 67 def tearDown(self): | 67 def tearDown(self): |
| 68 DBTest.tearDown(self) | 68 DBTest.tearDown(self) |
| 69 postgresqlOpener.tearDown(self) | 69 postgresqlOpener.tearDown(self) |
| 70 | 70 |
| 71 def does_index_exist(self, index_name): | |
| 72 sql = """SELECT count(*) > 0 | |
| 73 FROM pg_class c | |
| 74 WHERE c.relname = '%s' | |
| 75 AND c.relkind = 'i';""" % index_name | |
| 76 | |
| 77 self.db.sql(sql) | |
| 78 return self.db.cursor.fetchone()[0] | |
| 79 | |
| 80 def testUpgrade_6_to_7(self): | 71 def testUpgrade_6_to_7(self): |
| 81 | 72 |
| 82 # load the database | 73 # load the database |
| 83 self.db.issue.create(title="flebble frooz") | 74 self.db.issue.create(title="flebble frooz") |
| 84 self.db.commit() | 75 self.db.commit() |
| 111 | 102 |
| 112 with self.assertRaises(psycopg2.errors.UndefinedTable) as ctx: | 103 with self.assertRaises(psycopg2.errors.UndefinedTable) as ctx: |
| 113 self.db.sql("select * from _fts") | 104 self.db.sql("select * from _fts") |
| 114 self.db.rollback() | 105 self.db.rollback() |
| 115 | 106 |
| 116 self.assertFalse(self.does_index_exist('__fts_idx')) | 107 self.assertFalse(self.db.sql_index_exists('__fts', '__fts_idx')) |
| 117 | 108 |
| 118 if hasattr(self, "downgrade_only"): | 109 if hasattr(self, "downgrade_only"): |
| 119 return | 110 return |
| 120 | 111 |
| 121 # test upgrade path | 112 # test upgrade path |
| 130 self.db.sql("insert into __words VALUES('%s',1)" % too_long_string) | 121 self.db.sql("insert into __words VALUES('%s',1)" % too_long_string) |
| 131 | 122 |
| 132 # clean db handle | 123 # clean db handle |
| 133 self.db.rollback() | 124 self.db.rollback() |
| 134 | 125 |
| 135 self.assertTrue(self.does_index_exist('__fts_idx')) | 126 self.assertTrue(self.db.sql_index_exists('__fts', '__fts_idx')) |
| 136 | 127 |
| 137 self.db.sql("select * from __fts") | 128 self.db.sql("select * from __fts") |
| 138 | 129 |
| 139 self.assertEqual(self.db.database_schema['version'], | 130 self.assertEqual(self.db.database_schema['version'], |
| 140 self.db.current_db_version) | 131 self.db.current_db_version) |
