aboutsummaryrefslogtreecommitdiff
path: root/tests/models/gr/test_base.py
diff options
context:
space:
mode:
authorMax Nanis2026-08-21 11:31:13 -0700
committerMax Nanis2026-08-21 11:31:13 -0700
commitff538deb290c851364df85aa6ccc64bc3719ef64 (patch)
treec04c3573ab6adab70971fef00d3420a5da5f9619 /tests/models/gr/test_base.py
parent4fe0f6b5e0f0c744902e4c3ab8940e23a6f8a2e1 (diff)
parentc4a44873540ca4c0a3ab19b9beef4cfc6e0252a7 (diff)
downloadgeneralresearch-ff538deb290c851364df85aa6ccc64bc3719ef64.tar.gz
generalresearch-ff538deb290c851364df85aa6ccc64bc3719ef64.zip
Merge branch 'master' into dev
Diffstat (limited to 'tests/models/gr/test_base.py')
-rw-r--r--tests/models/gr/test_base.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/models/gr/test_base.py b/tests/models/gr/test_base.py
new file mode 100644
index 0000000..a9f01a8
--- /dev/null
+++ b/tests/models/gr/test_base.py
@@ -0,0 +1,46 @@
+import subprocess
+from pathlib import Path
+from typing import Callable
+
+import pytest
+from pydantic import PostgresDsn
+
+from generalresearch.pg_helper import PostgresConfig
+
+
+class TestGRPostgresDjangoCreation:
+
+ def test_git(self, git_key_path: Path, gr_repo: Callable[..., Path]):
+ repo_path = gr_repo()
+
+ try:
+ # Run the git command inside the target directory
+ result = subprocess.run(
+ ["git", "rev-parse", "--is-inside-work-tree"],
+ cwd=repo_path,
+ capture_output=True,
+ text=True,
+ check=True,
+ )
+ # Check if the output string is exactly "true"
+ assert result.stdout.strip() == "true"
+
+ except (subprocess.CalledProcessError, FileNotFoundError) as e:
+ pytest.fail(f"Directory is not a Git repo or Git is not installed: {e}")
+
+ def test_django_creation(
+ self,
+ django_db_factory: Callable[..., None],
+ ):
+
+ dsn = django_db_factory("gr")
+ assert isinstance(dsn, PostgresDsn)
+
+ # def test_django_tables(self, thl_web_rw: 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"] == 56