Skip to content

Commit

Permalink
Improve test_postgres_schema_delete_and_create
Browse files Browse the repository at this point in the history
Verify that the table and schema still exists after Postgres
refused to drop them.
  • Loading branch information
Photonios committed Apr 6, 2023
1 parent 5476b25 commit 69bece0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 69bece0

Please sign in to comment.