aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Stupp2026-10-13 22:36:37 +0000
committerGreg Stupp2026-10-13 22:36:37 +0000
commitaad04d47a507cdec4ceabd3d978dd1a08ad28234 (patch)
tree942e5e1266aefe3b0f86a107f122de7540f75cf5
parentc265cc29d7a864651377c94be8695c9cf9b79bf1 (diff)
parente5ba13edd8afa10330ad8e6e67fa1c023263345c (diff)
downloadgeneralresearch-aad04d47a507cdec4ceabd3d978dd1a08ad28234.tar.gz
generalresearch-aad04d47a507cdec4ceabd3d978dd1a08ad28234.zip
Merges pull request #10 v3.8.1
Fix BusinessCreate and Fix pytest fixtures for gr
-rw-r--r--generalresearch/models/gr/__init__.py6
-rw-r--r--generalresearch/models/gr/business.py19
-rw-r--r--pyproject.toml2
-rw-r--r--test_utils/conftest.py76
-rw-r--r--test_utils/managers/gr/conftest.py2
-rw-r--r--tests/models/gr/test_base.py33
6 files changed, 21 insertions, 117 deletions
diff --git a/generalresearch/models/gr/__init__.py b/generalresearch/models/gr/__init__.py
index 7e1516b..132f72b 100644
--- a/generalresearch/models/gr/__init__.py
+++ b/generalresearch/models/gr/__init__.py
@@ -1,13 +1,15 @@
from generalresearch.models.gr.authentication import GRToken, GRUser
-from generalresearch.models.gr.business import Business
+from generalresearch.models.gr.business import Business, BusinessCreate
from generalresearch.models.gr.team import Team
from generalresearch.models.thl.finance import BusinessBalances
from generalresearch.models.thl.payout import BrokerageProductPayoutEvent
from generalresearch.models.thl.product import Product
-_ = Business, Product, BrokerageProductPayoutEvent, BusinessBalances
+# To prevent type checkers from removing these imports from this file
+_ = Product, BrokerageProductPayoutEvent, BusinessBalances
GRUser.model_rebuild()
GRToken.model_rebuild()
+BusinessCreate.model_rebuild()
Business.model_rebuild()
Team.model_rebuild()
diff --git a/generalresearch/models/gr/business.py b/generalresearch/models/gr/business.py
index 5ab819f..efda584 100644
--- a/generalresearch/models/gr/business.py
+++ b/generalresearch/models/gr/business.py
@@ -19,12 +19,10 @@ from pydantic import (
Field,
PositiveInt,
ValidationError,
- computed_field,
)
from pydantic.json_schema import SkipJsonSchema
from pydantic_extra_types.phone_numbers import PhoneNumber
-from generalresearch.currency import USDCent
from generalresearch.decorators import LOG
from generalresearch.incite.schemas.mergers.pop_ledger import (
numerical_col_names,
@@ -42,16 +40,7 @@ from generalresearch.models.thl.finance import (
BusinessUserWalletBalances,
POPFinancial,
)
-from generalresearch.models.thl.ledger import LedgerAccount, OrderBy
-from generalresearch.models.thl.payout import BusinessPayoutEvent
-
-if TYPE_CHECKING:
- from generalresearch.incite.mergers.pop_ledger import PopLedgerMerge
- from generalresearch.pg_helper import PostgresConfig
- from generalresearch.redis_helper import RedisConfig
-
-logging.basicConfig()
-logger = logging.getLogger(__name__)
+from generalresearch.models.thl.ledger import LedgerAccount
if TYPE_CHECKING:
from generalresearch.incite.base import GRLDatasets
@@ -61,6 +50,7 @@ if TYPE_CHECKING:
from generalresearch.incite.mergers.foundations.enriched_wall import (
EnrichedWallMerge,
)
+ from generalresearch.incite.mergers.pop_ledger import PopLedgerMerge
from generalresearch.managers.gr.business import (
BusinessBankAccountManager,
)
@@ -75,6 +65,11 @@ if TYPE_CHECKING:
)
from generalresearch.managers.thl.product import ProductManager
from generalresearch.models.thl.product import Product
+ from generalresearch.pg_helper import PostgresConfig
+ from generalresearch.redis_helper import RedisConfig
+
+logging.basicConfig()
+logger = logging.getLogger(__name__)
class BusinessBankAccount(BaseModel):
diff --git a/pyproject.toml b/pyproject.toml
index 2bca0ef..c9fc83c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "generalresearch"
-version = "3.8.0"
+version = "3.8.1"
description = "Python Utilities for General Research"
readme = "README.md"
requires-python = ">=3.14"
diff --git a/test_utils/conftest.py b/test_utils/conftest.py
index cd3fd45..450c90e 100644
--- a/test_utils/conftest.py
+++ b/test_utils/conftest.py
@@ -2,7 +2,6 @@ from __future__ import annotations
import os
import shutil
-import stat
import subprocess
import sys
from collections.abc import Callable, Generator
@@ -156,66 +155,6 @@ def postgres_instance_host(
@pytest.fixture(scope="session")
-def git_key_path(
- tmp_path_factory: TempPathFactory,
- settings: GRLBaseSettings,
-) -> Generator[Path]:
- # We are using the tmp_path_factory because unlike the tmp_path (which
- # is function scoped), this is session scoped.
-
- assert settings.git_creds, "Must define key to download alternative models"
- fn = tmp_path_factory.mktemp("keys") / "git_creds"
- key_content = settings.git_creds.replace("\\n", "\n")
- fn.write_text(key_content, encoding="utf-8")
- os.chmod(fn, stat.S_IRUSR | stat.S_IWUSR)
-
- yield Path(fn)
-
- os.unlink(fn)
-
-
-@pytest.fixture(scope="session")
-def gr_repo(
- git_key_path: Path,
- tmp_path_factory: TempPathFactory,
-) -> Callable[..., Path | None]:
- repo_url = "ssh://code.g-r-l.com:6611/general-research/gr-carer.git"
-
- _ran = {}
-
- fn = tmp_path_factory.mktemp("repos")
- repo_path = fn / "gr-carer"
-
- def _inner() -> Path:
-
- if _ran.get(repo_url, False):
- print(f"Already ran django_db_factory.{repo_url}")
- return repo_path
-
- _ran[repo_url] = True
-
- ssh_cmd = (
- f'ssh -i "{git_key_path}" '
- "-o IdentitiesOnly=yes "
- "-o StrictHostKeyChecking=no "
- )
- env = {**os.environ, "GIT_SSH_COMMAND": ssh_cmd}
-
- if repo_path.exists():
- subprocess.run(["git", "-C", str(repo_path), "pull"], check=True, env=env)
- else:
- subprocess.run(
- ["git", "clone", "--depth", "1", repo_url, str(repo_path)],
- check=True,
- env=env,
- )
-
- return repo_path
-
- return _inner
-
-
-@pytest.fixture(scope="session")
def django_settings_file(
postgres_instance_dict: PostgresDict,
tmp_path_factory: TempPathFactory,
@@ -259,17 +198,14 @@ USE_TZ = True
@pytest.fixture(scope="session")
def django_db_factory(
postgres_instance: PostgresDsn,
- gr_repo: Callable[..., Path],
django_settings_file: Callable[..., tuple[str, Path]],
- postgres_instance_dict: PostgresDict,
- tmp_path_factory: TempPathFactory,
-) -> Callable[..., PostgresDsn | None]:
+) -> Callable[..., PostgresDsn]:
_ran = {}
def _inner(
django_project: str = "generalresearch.thl_django",
- ) -> PostgresDsn | None:
+ ) -> PostgresDsn:
if _ran.get(django_project, False):
print(f"Already ran django_db_factory:{django_project}")
@@ -285,11 +221,11 @@ def django_db_factory(
],
)
- elif django_project == "gr.common":
- _cwd = gr_repo()
- _manage_path = "gr.app.manage"
+ elif django_project == "generalresearch.gr_django":
+ _cwd = None
+ _manage_path = "generalresearch.gr_django.app.manage"
_settings_module, _settings_dir = django_settings_file(
- extra_installed_apps=["gr.common"]
+ extra_installed_apps=["generalresearch.gr_django"]
)
else:
diff --git a/test_utils/managers/gr/conftest.py b/test_utils/managers/gr/conftest.py
index 09e08f5..9a0654a 100644
--- a/test_utils/managers/gr/conftest.py
+++ b/test_utils/managers/gr/conftest.py
@@ -67,7 +67,7 @@ def gr_redis_config(
@pytest.fixture(scope="session")
def gr_db(django_db_factory: Callable[..., PostgresDsn]) -> PostgresConfig:
- _dsn = django_db_factory("gr.common")
+ _dsn = django_db_factory("generalresearch.gr_django")
return PostgresConfig(
dsn=_dsn,
diff --git a/tests/models/gr/test_base.py b/tests/models/gr/test_base.py
index 5ab5dff..d312501 100644
--- a/tests/models/gr/test_base.py
+++ b/tests/models/gr/test_base.py
@@ -1,41 +1,12 @@
-from __future__ import annotations
-
-import subprocess
from collections.abc import Callable
-from pathlib import Path
-from typing import TYPE_CHECKING
-import pytest
from pydantic import PostgresDsn
-if TYPE_CHECKING:
- from generalresearch.pg_helper import PostgresConfig
-
class TestGRPostgresDjangoCreation:
-
- def test_git(self, 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],
+ django_db_factory: Callable[..., PostgresDsn],
):
-
- dsn = django_db_factory("gr.common")
+ dsn = django_db_factory("generalresearch.gr_django")
assert isinstance(dsn, PostgresDsn)