1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/data/migrations/test/test_db_config.py
Kenny Lee Sin Cheong 5f63b3a7bb chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -04:00

29 lines
944 B
Python

from test.fixtures import *
import pytest
from alembic.script import ScriptDirectory
from mock import patch
from data.runmigration import run_alembic_migration
@pytest.mark.parametrize(
"db_uri, is_valid",
[
("postgresql://devtable:password@quay-postgres/registry_database", True),
("postgresql://devtable:password%25@quay-postgres/registry_database", False),
("postgresql://devtable:password%%25@quay-postgres/registry_database", True),
("postgresql://devtable@db:password@quay-postgres/registry_database", True),
],
)
def test_alembic_db_uri(db_uri, is_valid):
"""
Test if the given URI is escaped for string interpolation (Python's configparser).
"""
with patch("alembic.script.ScriptDirectory.run_env") as m:
if is_valid:
run_alembic_migration(db_uri)
else:
with pytest.raises(ValueError):
run_alembic_migration(db_uri)