(self)
| 156 | db.ctx.db.close() |
| 157 | |
| 158 | def test_multiple_insert(self): |
| 159 | db = self.db |
| 160 | db.multiple_insert("person", [dict(name="a"), dict(name="b")], seqname=False) |
| 161 | |
| 162 | assert db.select("person", where="name='a'").list() |
| 163 | assert db.select("person", where="name='b'").list() |
| 164 | |
| 165 | # Create table `mi` |
| 166 | if self.driver in web.db.pg_drivers: |
| 167 | db.query("CREATE TABLE mi (id SERIAL PRIMARY KEY, v VARCHAR(5))") |
| 168 | elif self.driver in web.db.mysql_drivers: |
| 169 | self.db.query( |
| 170 | "CREATE TABLE mi (id INT(10) UNSIGNED AUTO_INCREMENT, v VARCHAR(5), PRIMARY KEY (`id`))" |
| 171 | ) |
| 172 | elif self.driver in web.db.sqlite_drivers: |
| 173 | self.db.query( |
| 174 | "CREATE TABLE mi (id INTEGER PRIMARY KEY NOT NULL, v VARCHAR(5))" |
| 175 | ) |
| 176 | |
| 177 | # Insert rows and verify returned row id. |
| 178 | if ( |
| 179 | self.driver |
| 180 | in web.db.pg_drivers + web.db.mysql_drivers + web.db.sqlite_drivers |
| 181 | ): |
| 182 | values = [{"v": "a"}, {"v": "b"}, {"v": "c"}] |
| 183 | |
| 184 | ids = db.multiple_insert("mi", values) |
| 185 | # `psycopg2` returns `range(1, 4)` instead of `[1, 2, 3]` on Python-3. |
| 186 | assert list(ids) == [1, 2, 3] |
| 187 | |
| 188 | ids = db.multiple_insert("mi", values) |
| 189 | assert list(ids) == [4, 5, 6] |
| 190 | |
| 191 | def test_result_is_true(self): |
| 192 | self.db.insert("person", False, name="user") |
nothing calls this directly
no test coverage detected