From 69bece0185e7f474110bdc5faf56f197feb0c857 Mon Sep 17 00:00:00 2001 From: Swen Kooij Date: Thu, 6 Apr 2023 10:56:12 +0300 Subject: [PATCH] Improve `test_postgres_schema_delete_and_create` Verify that the table and schema still exists after Postgres refused to drop them. --- tests/test_schema.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_schema.py b/tests/test_schema.py index e187f967..840dfc38 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -86,11 +86,17 @@ def test_postgres_schema_delete_and_create(): pg_error = extract_postgres_error(exc_info.value) assert pg_error.pgcode == errorcodes.DEPENDENT_OBJECTS_STILL_EXIST + # Verify that the schema and table still exist + assert _does_schema_exist(schema.name) + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM test.bla") + assert cursor.fetchone() == ("hello",) + # Dropping the schema should work with cascade=True schema = PostgresSchema.delete_and_create(schema.name, cascade=True) assert _does_schema_exist(schema.name) - # Since the schema was deleteped and re-created, the `bla` + # Since the schema was deleted and re-created, the `bla` # table should not exist anymore. with pytest.raises(ProgrammingError) as exc_info: with connection.cursor() as cursor: