Skip to content

Commit

Permalink
DEV-1174 changing the engine logic so that integration tests can be d…
Browse files Browse the repository at this point in the history
…ebugged in graphmanager
  • Loading branch information
stilesj-uchicago committed May 31, 2022
1 parent 2f76352 commit ed8ca71
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions indexd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from sqlalchemy import create_engine
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.orm import sessionmaker

import sqlalchemy_utils

Expand Down Expand Up @@ -32,13 +33,9 @@ def try_drop_test_data(

# Using an engine that connects to the `postgres` database allows us to
# create a new database.
engine = create_engine("postgresql://{user}@{host}/{name}".format(
user=root_user, host=host, name=database))

if sqlalchemy_utils.database_exists(engine.url):
sqlalchemy_utils.drop_database(engine.url)

engine.dispose()
url = "postgresql://{user}@{host}/{name}".format(user=root_user, host=host, name=database)
if sqlalchemy_utils.database_exists(url):
sqlalchemy_utils.drop_database(url)


def setup_database(
Expand All @@ -51,11 +48,11 @@ def setup_database(

# Create an engine connecting to the `postgres` database allows us to
# create a new database from there.
engine = create_engine("postgresql://{user}@{host}/{name}".format(
user=root_user, host=host, name=database))
if not sqlalchemy_utils.database_exists(engine.url):
sqlalchemy_utils.create_database(engine.url)
url = "postgresql://{user}@{host}/{name}".format(user=root_user, host=host, name=database)
if not sqlalchemy_utils.database_exists(url):
sqlalchemy_utils.create_database(url)

engine = create_engine(url)
conn = engine.connect()

if not no_user:
Expand Down

0 comments on commit ed8ca71

Please sign in to comment.