aboutsummaryrefslogtreecommitdiff
path: root/tests/test_postgres.py
diff options
context:
space:
mode:
authorstuppie2026-09-07 11:47:43 -0600
committerstuppie2026-09-07 11:47:43 -0600
commit092960233652cce1f4dc7841856034a6635e9cd9 (patch)
tree46e5fcd4d1e1b7ed0b987980c6c67ffa6e6b45c7 /tests/test_postgres.py
parent80fd8aab4c7271ddb619b0de18741d7ac77b490b (diff)
parent242579a44855873d5e054e375440e9d3492cd682 (diff)
downloadgeneralresearch-092960233652cce1f4dc7841856034a6635e9cd9.tar.gz
generalresearch-092960233652cce1f4dc7841856034a6635e9cd9.zip
Merge branch 'master' into dev-greg
Diffstat (limited to 'tests/test_postgres.py')
-rw-r--r--tests/test_postgres.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/tests/test_postgres.py b/tests/test_postgres.py
index 3b3ddd0..de3f5d8 100644
--- a/tests/test_postgres.py
+++ b/tests/test_postgres.py
@@ -1,18 +1,21 @@
import socket
import subprocess
-from typing import Callable
+from collections.abc import Callable
+from typing import TYPE_CHECKING
from pydantic import PostgresDsn
-from generalresearch.models.custom_types import InternalHostname, PostgresDict
from generalresearch.pg_helper import PostgresConfig
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import InternalHostname, PostgresDict
+
def is_port_open(host: InternalHostname, port: int = 5432, timeout: int = 3):
try:
with socket.create_connection((host, port), timeout=timeout):
return True
- except (socket.timeout, ConnectionRefusedError, OSError):
+ except (TimeoutError, ConnectionRefusedError, OSError):
return False
@@ -65,4 +68,32 @@ class TestPostgresDjangoCreation:
WHERE table_schema = 'public';
""")
assert len(res) == 1
- assert res[0]["count"] == 56
+ assert res[0]["count"] == 57
+
+ def test_django_tables_only_gr(self, gr_db: PostgresConfig):
+ """
+ IMPORTANT: This can't really run with only the GR tables,
+ that's because we have most of the database init fixtures
+ as session scoped; and we can't ensure that this will
+ run before any test that depends on the core thl
+ migrations
+ """
+
+ res = gr_db.execute_sql_query(query="""
+ SELECT COUNT(*)
+ FROM information_schema.tables
+ WHERE table_schema = 'public';
+ """)
+ assert len(res) == 1
+ assert res[0]["count"] == 65
+
+ def test_django_tables_with_gr(
+ self, thl_web_rw: PostgresConfig, gr_db: PostgresConfig
+ ):
+ res = thl_web_rw.execute_sql_query(query="""
+ SELECT COUNT(*)
+ FROM information_schema.tables
+ WHERE table_schema = 'public';
+ """)
+ assert len(res) == 1
+ assert res[0]["count"] == 65