debut changement vers google drive
CI - Security, Lint & Tests / validate (push) Failing after 1m14s
CI - Security, Lint & Tests / validate (push) Failing after 1m14s
This commit is contained in:
+14
-17
@@ -1,17 +1,17 @@
|
||||
"""Which PostgreSQL driver the application actually asks for — QUA-001.
|
||||
|
||||
`postgresql://…` is not "whichever driver is installed". SQLAlchemy reads it
|
||||
as psycopg2 and imports that module when the engine is created.
|
||||
requirements.txt pins psycopg 3 and no psycopg2, so a clean install against
|
||||
the URL Render hands out — the same form docs/database-restore.md documents
|
||||
— fails before the first request:
|
||||
as psycopg2 unless the URL names a driver. requirements.txt declares psycopg
|
||||
3, so create_app() must explicitly select it.
|
||||
|
||||
ModuleNotFoundError: No module named 'psycopg2'
|
||||
|
||||
create_app() now names the driver. These tests pin that down, and the last
|
||||
one proves the failure is real rather than theoretical.
|
||||
The test suite must not assume that psycopg2 is absent: a developer's virtual
|
||||
environment can contain optional packages in addition to the declared
|
||||
dependencies. These tests instead pin the application's selected driver and
|
||||
the dependency contract that production installs use.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
@@ -80,16 +80,13 @@ class TestTheFactory:
|
||||
assert app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite:///')
|
||||
|
||||
|
||||
class TestTheFailureIsReal:
|
||||
"""Not a hypothetical: this is what the deployed configuration did."""
|
||||
class TestDriverContract:
|
||||
def test_production_dependencies_select_psycopg_3(self):
|
||||
requirements = Path(__file__).resolve().parents[1] / 'requirements.txt'
|
||||
declared = requirements.read_text(encoding='utf-8')
|
||||
|
||||
def test_psycopg2_is_not_installed(self):
|
||||
with pytest.raises(ImportError):
|
||||
import psycopg2 # noqa: F401
|
||||
|
||||
def test_a_driverless_url_cannot_build_an_engine(self):
|
||||
with pytest.raises(ModuleNotFoundError):
|
||||
create_engine('postgresql://u:p@host/db')
|
||||
assert 'psycopg[binary]==' in declared
|
||||
assert 'psycopg2' not in declared
|
||||
|
||||
def test_the_normalised_url_can(self):
|
||||
engine = create_engine(normalise_database_url('postgresql://u:p@host/db'))
|
||||
|
||||
Reference in New Issue
Block a user