aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jenkinsfile189
-rw-r--r--generalresearch/incite/base.py10
-rw-r--r--generalresearch/managers/thl/ipinfo.py4
-rw-r--r--generalresearch/models/gr/__init__.py22
-rw-r--r--generalresearch/models/gr/business.py4
-rw-r--r--generalresearch/models/thl/session.py2
-rw-r--r--test_utils/conftest.py42
-rw-r--r--test_utils/managers/cashout_methods.py85
-rw-r--r--test_utils/managers/conftest.py7
-rw-r--r--test_utils/managers/gr/conftest.py4
-rw-r--r--test_utils/models/thl/conftest.py12
-rw-r--r--tests/managers/thl/test_cashout_method.py7
-rw-r--r--tests/models/gr/test_base.py9
13 files changed, 119 insertions, 278 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index e829ba9..d3bc039 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -12,45 +12,22 @@ pipeline {
environment {
VENV = "${env.WORKSPACE}/generalresearch-venv"
- SPECTRUM_CARER_VENV = "${env.WORKSPACE}/thl-spectrum-carer-venv"
- GRLIQ_CARER_VENV = "${env.WORKSPACE}/grliq-carer-venv"
- GR_CARER_VENV = "${env.WORKSPACE}/gr-carer-venv"
-
- INCITE_MOUNT_DIR = '/mnt/thl-incite'
- TMP_DIR = "${env.WORKSPACE}/tmp"
}
stages {
stage('python versions') {
+
matrix {
axes {
axis {
name 'PYTHON_VERSION'
- values 'python3.14' 'python3.13', 'python3.12', 'python3.11', 'python3.10'
+ values 'python3.14' 'python3.13', 'python3.12', 'python3.11'
}
}
stages {
- stage('Setup DB') {
- script {
- env.REDIS_DB = new Random().nextInt(1024).toString()
- env.REDIS = "${env.REDIS}:6379/${env.REDIS_DB}"
- env.THL_REDIS = "${env.THL_REDIS}:6379/${env.REDIS_DB}"
- echo "Using THL Redis: ${env.REDIS}"
- if (sh(script: "redis-cli -u ${env.REDIS} SET jenkins_lock 1 NX EX 3600", returnStdout: true).trim() != 'OK')
- error('Redis already locked... aborting.')
- }
- script {
- env.GR_REDIS_DB = new Random().nextInt(1024).toString()
- env.GR_REDIS = "redis://${env.REDIS}:6379/${env.GR_REDIS_DB}"
- echo "Using GR Redis: ${env.GR_REDIS}"
- if (sh(script: "redis-cli -u ${env.GR_REDIS} SET jenkins_lock 1 NX EX 3600", returnStdout: true).trim() != 'OK')
- error('Redis already locked... aborting.')
- }
- }
- }
- stage('Setup Git') {
+ stage('Setup') {
steps {
cleanWs()
@@ -67,188 +44,32 @@ pipeline {
url: 'ssh://code.g-r-l.com:6611/generalresearch']
],
)
- }
-
- dir("thl-spectrum:$PYTHON_VERSION/") {
- checkout scmGit(
- branches: [[name: env.BRANCH_NAME]],
- extensions: [ cloneOption(shallow: true) ],
- userRemoteConfigs: [
- [credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
- url: 'ssh://code.g-r-l.com:6611/thl-marketplaces/thl-spectrum']
- ],
- )
- }
- dir("grliq:$PYTHON_VERSION/") {
- checkout scmGit(
- branches: [[name: env.BRANCH_NAME]],
- extensions: [ cloneOption(shallow: true) ],
- userRemoteConfigs: [
- [credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
- url: 'ssh://code.g-r-l.com:6611/grl-iq']
- ],
- )
- }
-
- dir("gr:$PYTHON_VERSION/") {
- checkout scmGit(
- branches: [[name: env.BRANCH_NAME]],
- extensions: [ cloneOption(shallow: true) ],
- userRemoteConfigs: [
- [credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
- url: 'ssh://code.g-r-l.com:6611/general-research/gr-carer']
- ],
- )
- }
- }
- }
-
- stage('Env & Migration') {
- steps {
- dir("generalresearch:$PYTHON_VERSION/") {
sh "/usr/local/bin/$PYTHON_VERSION -m venv $VENV-$PYTHON_VERSION"
sh "$VENV-$PYTHON_VERSION/bin/pip install -U setuptools wheel pip"
sh "$VENV-$PYTHON_VERSION/bin/pip install -r requirements.txt"
sh "$VENV-$PYTHON_VERSION/bin/pip install '.[django]'"
- sh """
- export DB_NAME=${DB_NAME}
- export DB_USER=${env.DB_USER}
- export DB_PASSWORD=${env.DB_PASSWORD}
- export DB_HOST=${env.DB_POSTGRESQL_HOST}
- $VENV-$PYTHON_VERSION/bin/$PYTHON_VERSION -m generalresearch.thl_django.app.manage migrate
- """
- }
-
- dir("thl-spectrum:$PYTHON_VERSION/") {
- dir('carer') {
- sh "/usr/local/bin/$PYTHON_VERSION -m venv $SPECTRUM_CARER_VENV-$PYTHON_VERSION"
- sh "$SPECTRUM_CARER_VENV-$PYTHON_VERSION/bin/pip install -U setuptools wheel pip"
- sh "$SPECTRUM_CARER_VENV-$PYTHON_VERSION/bin/pip install -r requirements.txt"
-
- sh """
- export DB_NAME=${SPECTRUM_DB_NAME}
- $SPECTRUM_CARER_VENV-$PYTHON_VERSION/bin/$PYTHON_VERSION manage.py migrate --settings=carer.settings.unittest
- """
- }
- }
-
- dir("grliq:$PYTHON_VERSION/") {
- dir('carer') {
- sh "/usr/local/bin/$PYTHON_VERSION -m venv $GRLIQ_CARER_VENV-$PYTHON_VERSION"
- sh "$GRLIQ_CARER_VENV-$PYTHON_VERSION/bin/pip install -U setuptools wheel pip"
- sh "$GRLIQ_CARER_VENV-$PYTHON_VERSION/bin/pip install -r requirements.txt"
-
- sh """
- export DB_NAME=${GRLIQ_DB_NAME}
- $GRLIQ_CARER_VENV-$PYTHON_VERSION/bin/$PYTHON_VERSION manage.py migrate --settings=carer.settings.unittest
- """
- }
- }
-
- dir("gr:$PYTHON_VERSION/") {
- sh "/usr/local/bin/$PYTHON_VERSION -m venv $GR_CARER_VENV-$PYTHON_VERSION"
- sh "$GR_CARER_VENV-$PYTHON_VERSION/bin/pip install -U setuptools wheel pip"
- sh "$GR_CARER_VENV-$PYTHON_VERSION/bin/pip install -r requirements.txt"
-
- sh """
- export DB_NAME=${GR_DB_NAME}
- $GR_CARER_VENV-$PYTHON_VERSION/bin/$PYTHON_VERSION manage.py migrate --settings=gr.settings.unittest
- """
}
}
}
stage('base') {
- when {
- expression { return true }
- }
- steps {
- dir("generalresearch:$PYTHON_VERSION") {
- sh "$VENV-$PYTHON_VERSION/bin/pytest -v tests/sql_helper.py"
- }
- }
- }
-
- stage('models') {
- when {
- expression { return true }
- }
steps {
dir("generalresearch:$PYTHON_VERSION") {
- sh "$VENV-$PYTHON_VERSION/bin/pytest -v tests/models"
+ sh "$VENV-$PYTHON_VERSION/bin/pytest tests/models/gr/test_base.py -vs"
}
}
}
- stage('managers') {
- steps {
- dir("generalresearch:$PYTHON_VERSION") {
- sh "$VENV-$PYTHON_VERSION/bin/pytest -v tests/managers"
- }
- }
- }
-
- stage('wall_status_codes') {
- steps {
- dir("generalresearch:$PYTHON_VERSION") {
- sh "$VENV-$PYTHON_VERSION/bin/pytest -v tests/wall_status_codes"
- }
- }
- }
-
- stage('wxet') {
- steps {
- dir("generalresearch:$PYTHON_VERSION") {
- sh "$VENV-$PYTHON_VERSION/bin/pytest -v tests/wxet"
- }
- }
- }
-
- stage('grliq') {
- steps {
- dir("generalresearch:$PYTHON_VERSION") {
- sh "$VENV-$PYTHON_VERSION/bin/pytest -v tests/grliq"
- }
- }
- }
-
- stage('incite') {
- steps {
- dir("generalresearch:$PYTHON_VERSION") {
- sh "$VENV-$PYTHON_VERSION/bin/pytest -v tests/incite"
- }
- }
- }
}
}
}
}
+
post {
always {
echo 'One way or another, I have finished'
deleteDir() /* clean up our workspace */
- sh """
- mariadb -h ${env.DB_MARIA_HOST} -u ${env.DB_USER} -p${env.DB_PASSWORD} --ssl=0 -e 'DROP DATABASE `${env.SPECTRUM_DB_NAME}`;'
- """
- sh """
- PGPASSWORD=${env.DB_PASSWORD} psql -h ${env.DB_POSTGRESQL_HOST} -U ${env.DB_USER} -d postgres <<EOF
- DROP DATABASE "${env.DB_NAME}";
- EOF
- """
- sh """
- PGPASSWORD=${env.DB_PASSWORD} psql -h ${env.DB_POSTGRESQL_HOST} -U ${env.DB_USER} -d postgres <<EOF
- DROP DATABASE "${env.GRLIQ_DB_NAME}";
- EOF
- """
- sh """
- PGPASSWORD=${env.DB_PASSWORD} psql -h ${env.DB_POSTGRESQL_HOST} -U ${env.DB_USER} -d postgres <<EOF
- DROP DATABASE "${env.GR_DB_NAME}";
- EOF
- """
-
- sh "redis-cli -u ${env.THL_REDIS} FLUSHDB"
- sh "redis-cli -u ${env.GR_REDIS} FLUSHDB"
}
}
}
diff --git a/generalresearch/incite/base.py b/generalresearch/incite/base.py
index 9dfec4f..473a124 100644
--- a/generalresearch/incite/base.py
+++ b/generalresearch/incite/base.py
@@ -37,7 +37,6 @@ from pydantic import (
PositiveInt,
PrivateAttr,
TypeAdapter,
- ValidationInfo,
field_validator,
model_validator,
)
@@ -46,7 +45,6 @@ from sentry_sdk import capture_exception
from generalresearch.config import is_debug
from generalresearch.incite import LOG
-from generalresearch.incite.collections.base import DFCollectionItem
from generalresearch.incite.schemas import (
ARCHIVE_AFTER,
empty_dataframe_from_schema,
@@ -54,7 +52,7 @@ from generalresearch.incite.schemas import (
from generalresearch.models.custom_types import AwareDatetimeISO
if TYPE_CHECKING:
- from generalresearch.incite.collections.base import DFCollection
+ from generalresearch.incite.collections.base import DFCollection, DFCollectionItem
from generalresearch.incite.collections.thl_marketplaces import (
DFCollectionType,
)
@@ -213,15 +211,13 @@ class CollectionBase(BaseModel):
return self
@field_validator("start")
- def check_start(
- cls, start: datetime | None, info: ValidationInfo
- ) -> datetime | None:
+ def check_start(cls, start: datetime | None) -> datetime | None:
if start and start.microsecond != 0:
raise ValueError("Collection.start must not have microseconds")
return start
@field_validator("offset")
- def check_offset(cls, v: str | None, info: ValidationInfo):
+ def check_offset(cls, v: str | None):
# pd.offsets.__all__
if v is None:
# In MergeCollections, offset can be None
diff --git a/generalresearch/managers/thl/ipinfo.py b/generalresearch/managers/thl/ipinfo.py
index 98a9a32..496fe3e 100644
--- a/generalresearch/managers/thl/ipinfo.py
+++ b/generalresearch/managers/thl/ipinfo.py
@@ -6,6 +6,7 @@ from decimal import Decimal
import faker
import pymysql
+from grip_client.enums import AccessType
from more_itertools import chunked
from psycopg import Cursor
from pydantic import PositiveInt
@@ -24,7 +25,6 @@ from generalresearch.models.thl.ipinfo import (
IPInformation,
normalize_ip,
)
-from generalresearch.models.thl.maxmind.definitions import UserType
from generalresearch.pg_helper import PostgresConfig
fake = faker.Faker()
@@ -244,7 +244,7 @@ class IPInformationManager(PostgresManager):
network: str | None = None,
organization: str | None = None,
static_ip_score: float | None = None,
- user_type: UserType | None = None,
+ user_type: AccessType | None = None,
postal_code: str | None = None,
latitude: Decimal | None = None,
longitude: Decimal | None = None,
diff --git a/generalresearch/models/gr/__init__.py b/generalresearch/models/gr/__init__.py
index 7e1516b..79f05d3 100644
--- a/generalresearch/models/gr/__init__.py
+++ b/generalresearch/models/gr/__init__.py
@@ -1,13 +1,13 @@
-from generalresearch.models.gr.authentication import GRToken, GRUser
-from generalresearch.models.gr.business import Business
-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
+# from generalresearch.models.gr.authentication import GRToken, GRUser
+# from generalresearch.models.gr.business import Business
+# 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
+# _ = Business, Product, BrokerageProductPayoutEvent, BusinessBalances
-GRUser.model_rebuild()
-GRToken.model_rebuild()
-Business.model_rebuild()
-Team.model_rebuild()
+# GRUser.model_rebuild()
+# GRToken.model_rebuild()
+# Business.model_rebuild()
+# Team.model_rebuild()
diff --git a/generalresearch/models/gr/business.py b/generalresearch/models/gr/business.py
index 11a5770..f6689a8 100644
--- a/generalresearch/models/gr/business.py
+++ b/generalresearch/models/gr/business.py
@@ -207,13 +207,13 @@ class Business(BaseModel):
# Initialization is deferred until unless it's called
# (see .prebuild_***())
- balance: BusinessBalances | None = Field(default=None, name="Business Balance")
+ balance: BusinessBalances | None = Field(default=None, title="Business Balance")
payouts_total_str: str | None = Field(default=None)
payouts_total: USDCent | None = Field(default=None)
payouts: list[BusinessPayoutEvent] | None = Field(
default=None,
- name="Business Payouts",
+ title="Business Payouts",
description=(
"These are the ACH or Wire payments that were sent to the"
"Business as a single amount, summed for all the Business"
diff --git a/generalresearch/models/thl/session.py b/generalresearch/models/thl/session.py
index 7121ea5..5653526 100644
--- a/generalresearch/models/thl/session.py
+++ b/generalresearch/models/thl/session.py
@@ -27,7 +27,6 @@ from generalresearch.models.custom_types import (
)
from generalresearch.models.legacy.bucket import Bucket
from generalresearch.models.thl import (
- Product,
decimal_to_int_cents,
int_cents_to_decimal,
)
@@ -47,6 +46,7 @@ if TYPE_CHECKING:
from generalresearch.managers.thl.ledger_manager.thl_ledger import (
ThlLedgerManager,
)
+ from generalresearch.models.thl.product import Product
from generalresearch.models.thl.user import User
logger = logging.getLogger("Wall")
diff --git a/test_utils/conftest.py b/test_utils/conftest.py
index 6894450..757f141 100644
--- a/test_utils/conftest.py
+++ b/test_utils/conftest.py
@@ -23,6 +23,18 @@ from generalresearch.models.custom_types import InternalHostname, PostgresDict
from generalresearch.pg_helper import PostgresConfig
from generalresearch.sql_helper import SqlHelper
+# -- redis notes from jenkins file
+# sh "redis-cli -u ${env.THL_REDIS} FLUSHDB"
+# sh "redis-cli -u ${env.GR_REDIS} FLUSHDB"
+
+# script {
+# env.GR_REDIS_DB = new Random().nextInt(1024).toString()
+# env.GR_REDIS = "redis://${env.REDIS}:6379/${env.GR_REDIS_DB}"
+# echo "Using GR Redis: ${env.GR_REDIS}"
+# if (sh(script: "redis-cli -u ${env.GR_REDIS} SET jenkins_lock 1 NX EX 3600", returnStdout: true).trim() != 'OK')
+# error('Redis already locked... aborting.')
+# }
+
@pytest.fixture(scope="session")
def env_file_path(pytestconfig: Config) -> Path:
@@ -178,18 +190,18 @@ def gr_repo(
repo_url = "ssh://code.g-r-l.com/general-research/gr-carer.git"
_ran = {}
- if _ran.get(repo_url, False):
- print(f"Already ran django_db_factory.{repo_url}")
- return
-
- _ran[repo_url] = True
fn = tmp_path_factory.mktemp("repos")
repo_path = fn / "gr-carer"
- repo_path.mkdir(parents=True, exist_ok=True)
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 "
@@ -206,11 +218,6 @@ def gr_repo(
env=env,
)
- result = subprocess.run(
- ["cat", git_key_path], capture_output=True, text=True, check=False
- )
- print(repr(result.stdout))
-
return repo_path
return _inner
@@ -236,7 +243,8 @@ def django_db_factory(
if _ran.get(django_project, False):
print(f"Already ran django_db_factory.{django_project}")
- return
+ return postgres_instance
+
_ran[django_project] = True
if "gr" in django_project:
@@ -246,6 +254,8 @@ def django_db_factory(
# 1. Bootstrapping Django settings
if not django_settings.configured:
+ print(postgres_instance_dict)
+
django_settings.configure(
DATABASES={
"default": {
@@ -265,11 +275,13 @@ def django_db_factory(
)
django.setup()
- for model in apps.get_models():
- print(f"Discovered model: {model._meta.label}")
+ # for model in apps.get_models():
+ # print(f"Discovered model: {model._meta.label}")
# 2. Run migrations directly during fixture activation
- call_command("makemigrations", "gr", interactive=False)
+ if "gr" in django_project:
+ call_command("makemigrations", "common", interactive=False)
+
call_command("migrate")
# 3. Return the Dsn so the factory gives a way to connect
diff --git a/test_utils/managers/cashout_methods.py b/test_utils/managers/cashout_methods.py
index b201e8c..238cdda 100644
--- a/test_utils/managers/cashout_methods.py
+++ b/test_utils/managers/cashout_methods.py
@@ -1,6 +1,11 @@
+from __future__ import annotations
+
import random
+from collections.abc import Callable
from uuid import uuid4
+import pytest
+
from generalresearch.models.thl.wallet import Currency, PayoutType
from generalresearch.models.thl.wallet.cashout_method import (
CashoutMethod,
@@ -8,45 +13,55 @@ from generalresearch.models.thl.wallet.cashout_method import (
)
-def random_ext_id(base: str = "U02"):
- suffix = random.randint(0, 99999)
- return f"{base}{suffix:05d}"
+@pytest.fixture(scope="session")
+def random_ext_id_factory(base: str = "U02") -> Callable[..., str]:
+
+ def _inner() -> str:
+ suffix = random.randint(0, 99999)
+ return f"{base}{suffix:05d}"
+ return _inner
-EXAMPLE_TANGO_CASHOUT_METHODS = [
- CashoutMethod(
- id=uuid4().hex,
- last_updated="2021-06-23T20:45:38.239182Z",
- is_live=True,
- type=PayoutType.TANGO,
- ext_id=random_ext_id(),
- name="Safeway eGift Card $25",
- data=TangoCashoutMethodData(
- value_type="fixed", countries=["US"], utid=random_ext_id()
+
+@pytest.fixture(scope="session")
+def example_tango_cashout_methods(
+ random_ext_id_factory: Callable[..., str],
+) -> list[CashoutMethod]:
+ return [
+ CashoutMethod(
+ id=uuid4().hex,
+ last_updated="2021-06-23T20:45:38.239182Z",
+ is_live=True,
+ type=PayoutType.TANGO,
+ ext_id=random_ext_id_factory(),
+ name="Safeway eGift Card $25",
+ data=TangoCashoutMethodData(
+ value_type="fixed", countries=["US"], utid=random_ext_id_factory()
+ ),
+ user=None,
+ image_url="https://d30s7yzk2az89n.cloudfront.net/images/brands/b694446-1200w-326ppi.png",
+ original_currency=Currency.USD,
+ min_value=2500,
+ max_value=2500,
),
- user=None,
- image_url="https://d30s7yzk2az89n.cloudfront.net/images/brands/b694446-1200w-326ppi.png",
- original_currency=Currency.USD,
- min_value=2500,
- max_value=2500,
- ),
- CashoutMethod(
- id=uuid4().hex,
- last_updated="2021-06-23T20:45:38.239182Z",
- is_live=True,
- type=PayoutType.TANGO,
- ext_id=random_ext_id(),
- name="Amazon.it Gift Certificate",
- data=TangoCashoutMethodData(
- value_type="variable", countries=["IT"], utid="U006961"
+ CashoutMethod(
+ id=uuid4().hex,
+ last_updated="2021-06-23T20:45:38.239182Z",
+ is_live=True,
+ type=PayoutType.TANGO,
+ ext_id=random_ext_id_factory(),
+ name="Amazon.it Gift Certificate",
+ data=TangoCashoutMethodData(
+ value_type="variable", countries=["IT"], utid="U006961"
+ ),
+ user=None,
+ image_url="https://d30s7yzk2az89n.cloudfront.net/images/brands/b405753-1200w-326ppi.png",
+ original_currency=Currency.EUR,
+ min_value=1,
+ max_value=10000,
),
- user=None,
- image_url="https://d30s7yzk2az89n.cloudfront.net/images/brands/b405753-1200w-326ppi.png",
- original_currency=Currency.EUR,
- min_value=1,
- max_value=10000,
- ),
-]
+ ]
+
# AMT_ASSIGNMENT_CASHOUT_METHOD = CashoutMethod(
# id=uuid4().hex,
diff --git a/test_utils/managers/conftest.py b/test_utils/managers/conftest.py
index b03a646..9c6a1a7 100644
--- a/test_utils/managers/conftest.py
+++ b/test_utils/managers/conftest.py
@@ -32,12 +32,10 @@ from generalresearch.managers.thl.userhealth import (
UserIpHistoryManager,
)
from generalresearch.models import Source
+from generalresearch.models.thl.wallet.cashout_method import CashoutMethod
from generalresearch.pg_helper import PostgresConfig
from generalresearch.redis_helper import RedisConfig
from generalresearch.sql_helper import SqlHelper
-from test_utils.managers.cashout_methods import (
- EXAMPLE_TANGO_CASHOUT_METHODS,
-)
# === THL ===
@@ -172,12 +170,13 @@ def delete_cashoutmethod_db(thl_web_rw: PostgresConfig) -> Callable[..., None]:
def setup_cashoutmethod_db(
cashout_method_manager: CashoutMethodManager,
delete_cashoutmethod_db: Callable[..., None],
+ example_tango_cashout_methods: list[CashoutMethod],
) -> Callable[..., None]:
def _inner():
delete_cashoutmethod_db()
- for x in EXAMPLE_TANGO_CASHOUT_METHODS:
+ for x in example_tango_cashout_methods:
cashout_method_manager.create(x)
# TODO: convert these ids into instances to use.
diff --git a/test_utils/managers/gr/conftest.py b/test_utils/managers/gr/conftest.py
index 4da8fe3..69f3e9a 100644
--- a/test_utils/managers/gr/conftest.py
+++ b/test_utils/managers/gr/conftest.py
@@ -56,9 +56,11 @@ def gr_redis_config(settings: GRLBaseSettings) -> RedisConfig:
@pytest.fixture(scope="session")
def gr_db(django_db_factory: Callable[..., PostgresDsn]) -> PostgresConfig:
+ _dsn = django_db_factory("gr.common")
+ print("DDDD:", _dsn)
return PostgresConfig(
- dsn=django_db_factory("gr_carer"),
+ dsn=_dsn,
connect_timeout=1,
statement_timeout=5,
)
diff --git a/test_utils/models/thl/conftest.py b/test_utils/models/thl/conftest.py
index 907306d..fc57c73 100644
--- a/test_utils/models/thl/conftest.py
+++ b/test_utils/models/thl/conftest.py
@@ -4,13 +4,13 @@ from collections.abc import Callable
from datetime import UTC, datetime
from decimal import ROUND_DOWN, Decimal
from random import choice as rand_choice
-from random import choice as rchoice
from random import randint, random
from typing import Any
from uuid import uuid4
import faker
import pytest
+from grip_client.enums import AccessType
from pydantic import PositiveInt
from generalresearch.managers.thl.ipinfo import IPGeonameManager, IPInformationManager
@@ -30,7 +30,7 @@ from generalresearch.models.legacy.bucket import Bucket
from generalresearch.models.thl.definitions import (
PayoutStatus,
)
-from generalresearch.models.thl.ipinfo import IPGeoname, IPInformation, UserType
+from generalresearch.models.thl.ipinfo import IPGeoname, IPInformation
from generalresearch.models.thl.payout import UserPayoutEvent
from generalresearch.models.thl.product import (
PayoutConfig,
@@ -118,7 +118,7 @@ def wall_factory(
session = session_factory()
session_id = session.id
- source = source or rchoice(list(Source))
+ source = source or rand_choice(list(Source))
req_survey_id = req_survey_id or uuid4().hex
req_cpi = req_cpi or Decimal(fake.random_int(min=1, max=150) / 100).quantize(
Decimal(".01"), rounding=ROUND_DOWN
@@ -284,7 +284,7 @@ def ipinformation_factory(
network: str | None = None,
organization: str | None = None,
static_ip_score: float | None = None,
- user_type: UserType | None = None,
+ user_type: AccessType | None = None,
postal_code: str | None = None,
latitude: Decimal | None = None,
longitude: Decimal | None = None,
@@ -426,8 +426,8 @@ def auditlog_factory(audit_log_manager: AuditLogManager):
return audit_log_manager.create(
user_id=user_id,
- level=level or rchoice(list(AuditLogLevel)),
- event_type=event_type or rchoice(list(event_types)),
+ level=level or rand_choice(list(AuditLogLevel)),
+ event_type=event_type or rand_choice(list(event_types)),
event_msg=event_msg,
event_value=event_value,
)
diff --git a/tests/managers/thl/test_cashout_method.py b/tests/managers/thl/test_cashout_method.py
index 451d3e0..ca85c6b 100644
--- a/tests/managers/thl/test_cashout_method.py
+++ b/tests/managers/thl/test_cashout_method.py
@@ -12,12 +12,10 @@ from generalresearch.models.thl.user import User
from generalresearch.models.thl.wallet import PayoutType
from generalresearch.models.thl.wallet.cashout_method import (
CashMailCashoutMethodData,
+ CashoutMethod,
PaypalCashoutMethodData,
USDeliveryAddress,
)
-from test_utils.managers.cashout_methods import (
- EXAMPLE_TANGO_CASHOUT_METHODS,
-)
class TestTangoCashoutMethods:
@@ -26,13 +24,14 @@ class TestTangoCashoutMethods:
self,
cashout_method_manager: CashoutMethodManager,
setup_cashoutmethod_db: Callable[..., None],
+ example_tango_cashout_methods: list[CashoutMethod],
):
setup_cashoutmethod_db()
res = cashout_method_manager.filter(payout_types=[PayoutType.TANGO])
assert len(res) == 2
cm = next(x for x in res if x.ext_id == "U025035")
- assert EXAMPLE_TANGO_CASHOUT_METHODS[0] == cm
+ assert example_tango_cashout_methods[0] == cm
def test_user(
self,
diff --git a/tests/models/gr/test_base.py b/tests/models/gr/test_base.py
index 412fa52..a066fa1 100644
--- a/tests/models/gr/test_base.py
+++ b/tests/models/gr/test_base.py
@@ -15,8 +15,6 @@ class TestGRPostgresDjangoCreation:
def test_git(self, gr_repo: Callable[..., Path]):
repo_path = gr_repo()
- print("test_git.PATH:", repo_path)
-
try:
# Run the git command inside the target directory
result = subprocess.run(
@@ -37,16 +35,15 @@ class TestGRPostgresDjangoCreation:
django_db_factory: Callable[..., None],
):
- dsn = django_db_factory("gr")
+ dsn = django_db_factory("gr.common")
assert isinstance(dsn, PostgresDsn)
def test_django_tables(self, gr_db: PostgresConfig):
res = gr_db.execute_sql_query(query="""
- SELECT COUNT(*)
+ SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = 'public';
""")
print(res)
assert len(res) == 1
- assert res[0]["count"] == 56
- assert True
+ assert res[0]["count"] == 10