Skip to content

Commit

Permalink
removed code that breaks tests temporarily (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
tech3371 authored Nov 13, 2024
1 parent 3d43327 commit 6d95102
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions tests/lambda_endpoints/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Setup testing environment to test lambda handler code."""

import subprocess
from unittest.mock import patch

import boto3
Expand Down Expand Up @@ -59,31 +58,18 @@ def events_client():
yield boto3.client("events", region_name="us-west-2")


# Check if postgres is available on the system. If it is returncode == 0
POSTGRES_AVAILABLE = (
subprocess.run("which psql", shell=True, check=False).returncode == 0
)

if POSTGRES_AVAILABLE:

@pytest.fixture()
def connection(postgresql):
"""Use a postgres connection string."""
return f"postgresql+psycopg://{postgresql.info.user}:@{postgresql.info.host}:{postgresql.info.port}/{postgresql.info.dbname}"
else:

@pytest.fixture()
def connection():
"""Fallback to sqlite in memory database."""
return "sqlite:///:memory:"
# Check if `psycopg` and PostgreSQL are both available and compatible.
POSTGRES_AVAILABLE = False
# TODO: fix this to work with postgres locally


# NOTE: The default scope is function, so each test function will
# get a new database session and start fresh each time.
@pytest.fixture()
def session(connection):
def session():
"""Create a test postgres database engine."""
with patch.object(db, "Session") as mock_session:
connection = "sqlite:///:memory:"
engine = create_engine(connection)

# Create the tables and session
Expand Down

0 comments on commit 6d95102

Please sign in to comment.