-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Robert Cronin <[email protected]>
- Loading branch information
1 parent
849a05c
commit 971d68b
Showing
23 changed files
with
240 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.orm import declarative_base | ||
# Create Base class | ||
Base = declarative_base() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[pytest] | ||
pythonpath = . | ||
testpaths = tests | ||
python_files = test_*.py | ||
python_classes = Test* | ||
python_functions = test_* | ||
markers = | ||
unit: marks unit tests | ||
integration: marks integration tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from odr_core.models.base import Base | ||
from odr_core.schemas.user import UserCreate | ||
from odr_core.crud.user import create_user | ||
|
||
# Use an in-memory SQLite database for testing | ||
SQLALCHEMY_DATABASE_URL = "sqlite:///:memory:" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def engine(): | ||
return create_engine(SQLALCHEMY_DATABASE_URL) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def TestingSessionLocal(engine): | ||
return sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def db(TestingSessionLocal, engine): | ||
Base.metadata.create_all(bind=engine) | ||
db = TestingSessionLocal() | ||
try: | ||
yield db | ||
finally: | ||
db.close() | ||
Base.metadata.drop_all(bind=engine) | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def test_user(db): | ||
user_data = UserCreate( | ||
username="testuser", | ||
email="[email protected]", | ||
password="testpassword" | ||
) | ||
return create_user(db, user_data) |
Empty file.
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Oops, something went wrong.