Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcanay committed Jul 10, 2024
1 parent a03af09 commit c146195
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions backend/repository/sqllite.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ class Modality(Base):


class SQLLiteRepository:
def __init__(self, db_path: str = "./db/cdm.db", cdm_path: str = "./data/cdm", replace_if_exists: bool = False):
def __init__(self, db_path: str = "./db/cdm.db", cdm_path: str = "./data/cdm", initiate_with_data: bool = True, replace_if_exists: bool = False):
self.db_path = db_path
if replace_if_exists and os.path.exists(self.db_path):
os.remove(self.db_path)
self.engine = create_engine(f"sqlite:///{db_path}")
Session = sessionmaker(bind=self.engine, autoflush=False)
self.session = Session()
self.__initiate()
self.update_cdm_locally(cdm_path)
if initiate_with_data:
self.__initiate()
self.update_cdm_locally(cdm_path)

def close(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@pytest.fixture
def sqlite_repo(tmp_path: Path):
db_path = tmp_path / "test.db"
repo = SQLLiteRepository(str(db_path))
repo = SQLLiteRepository(str(db_path), initiate_with_data=False)
yield repo
repo.close()

Expand Down

0 comments on commit c146195

Please sign in to comment.