Skip to content

Commit

Permalink
Issue #218: rework connection lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Werbrouck committed Nov 29, 2024
1 parent 879743c commit 722e3f0
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,31 @@

from dotenv import load_dotenv

import datastore.db.__init__ as db
from fertiscan import get_full_inspection_json
from fertiscan.db.metadata.inspection import Inspection
from fertiscan.db.queries.inspection import update_inspection

load_dotenv()

# Constants for test configuration
TEST_DB_CONNECTION_STRING = os.environ.get("FERTISCAN_DB_URL")
if not TEST_DB_CONNECTION_STRING:
DB_CONNECTION_STRING = os.environ.get("FERTISCAN_DB_URL")
if not DB_CONNECTION_STRING:
raise ValueError("FERTISCAN_DB_URL is not set")

TEST_DB_SCHEMA = os.environ.get("FERTISCAN_SCHEMA_TESTING")
if not TEST_DB_SCHEMA:
DB_SCHEMA = os.environ.get("FERTISCAN_SCHEMA_TESTING")
if not DB_SCHEMA:
raise ValueError("FERTISCAN_SCHEMA_TESTING is not set")

TEST_INSPECTION_JSON_PATH = "tests/fertiscan/inspection.json"


class TestInspectionUpdatePythonFunction(unittest.TestCase):
def setUp(self):
# Set up database connection and cursor
self.conn = connect(
TEST_DB_CONNECTION_STRING, options=f"-c search_path={TEST_DB_SCHEMA},public"
)
self.conn.autocommit = False
self.cursor = self.conn.cursor()
# Connect to the PostgreSQL database with the specified schema
self.conn = db.connect_db(DB_CONNECTION_STRING, DB_SCHEMA)
self.cursor = db.cursor(self.conn)
db.create_search_path(self.conn, self.cursor, DB_SCHEMA)

# Create a user to act as inspector
self.cursor.execute(
Expand Down

0 comments on commit 722e3f0

Please sign in to comment.