| 332 | |
| 333 | |
| 334 | async def test_commit(aconn): |
| 335 | aconn.pgconn.exec_(b"drop table if exists foo") |
| 336 | aconn.pgconn.exec_(b"create table foo (id int primary key)") |
| 337 | aconn.pgconn.exec_(b"begin") |
| 338 | assert aconn.pgconn.transaction_status == pq.TransactionStatus.INTRANS |
| 339 | aconn.pgconn.exec_(b"insert into foo values (1)") |
| 340 | await aconn.commit() |
| 341 | assert aconn.pgconn.transaction_status == pq.TransactionStatus.IDLE |
| 342 | res = aconn.pgconn.exec_(b"select id from foo where id = 1") |
| 343 | assert res.get_value(0, 0) == b"1" |
| 344 | |
| 345 | await aconn.close() |
| 346 | with pytest.raises(psycopg.OperationalError): |
| 347 | await aconn.commit() |
| 348 | |
| 349 | |
| 350 | @pytest.mark.crdb_skip("deferrable") |