Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version = 1

exclude_patterns = ["tests/**", "db_init.py"]

[[analyzers]]
name = "python"

[analyzers.meta]
runtime_version = "3.x.x"
runtime_version = "3.x.x"
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ jobs:

- name: Set up the Database
env:
DATABASE_URL: postgresql+psycopg2://postgres:postgres@localhost:5432/labconnect
DB: postgresql+psycopg2://postgres:postgres@localhost:5432/labconnect
run: |
python db_init.py create

- name: Running pytest
env:
DATABASE_URL: postgresql+psycopg2://postgres:postgres@localhost:5432/labconnect
DB: postgresql+psycopg2://postgres:postgres@localhost:5432/labconnect
run: |
python -m pytest tests/
16 changes: 13 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
from os import getenv, path

from dotenv import load_dotenv
from sqlalchemy.pool import StaticPool

basedir = path.abspath(path.dirname(__file__))

_test_db_uri = getenv(
"DATABASE_URL",
getenv("DB", "postgresql+psycopg2://postgres:root@localhost/labconnect"),
)


class Config:
load_dotenv()
Expand All @@ -25,9 +31,7 @@ class Config:
SENTRY_TRACES_SAMPLE_RATE = float(getenv("SENTRY_TRACES_SAMPLE_RATE", 1.0))
SENTRY_PROFILES_SAMPLE_RATE = float(getenv("SENTRY_PROFILES_SAMPLE_RATE", 1.0))

SQLALCHEMY_DATABASE_URI = getenv(
"DB", "postgresql+psycopg2://postgres:root@localhost/labconnect"
)
SQLALCHEMY_DATABASE_URI = _test_db_uri

JWT_SECRET_KEY = getenv("JWT_SECRET_KEY", "jwt-secret")
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
Expand All @@ -47,6 +51,12 @@ class TestingConfig(Config):
DEBUG = True
JWT_COOKIE_SECURE = False

if _test_db_uri.startswith("sqlite"):
SQLALCHEMY_ENGINE_OPTIONS = {
"connect_args": {"check_same_thread": False},
"poolclass": StaticPool,
}


class ProductionConfig(Config):
TESTING = False
Expand Down
Loading
Loading