-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from UoA-eResearch/add-factories
add factories for models
- Loading branch information
Showing
7 changed files
with
474 additions
and
183 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,2 +1,3 @@ | ||
[MASTER] | ||
ignore-paths="^tests/.*$" | ||
ignore-paths="^tests/.*$" | ||
init-hook='import sys; sys.path.append("src")' |
Large diffs are not rendered by default.
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
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,44 @@ | ||
"functions and classes for testing the factories for populating classes" | ||
from factory.alchemy import SQLAlchemyModelFactory | ||
from sqlmodel import Session, select | ||
|
||
from models.project import Project | ||
|
||
|
||
def test_factories_all( # pylint: disable=too-many-arguments,too-many-positional-arguments | ||
person_factory: SQLAlchemyModelFactory, | ||
member_factory: SQLAlchemyModelFactory, | ||
code_factory: SQLAlchemyModelFactory, | ||
research_drive_service_factory: SQLAlchemyModelFactory, | ||
drive_offboard_submission_factory: SQLAlchemyModelFactory, | ||
project_factory: SQLAlchemyModelFactory, | ||
) -> None: | ||
"Test the basic functionality of all factories" | ||
person_factory.build() | ||
member_factory.build() | ||
code_factory.build() | ||
research_drive_service_factory.build() | ||
drive_offboard_submission_factory.build() | ||
project_factory.build() | ||
|
||
|
||
def test_project_retrieval( | ||
project_factory: SQLAlchemyModelFactory, session: Session | ||
) -> None: | ||
"test factories create within DB correctly" | ||
project = project_factory.create(title="test12345") | ||
|
||
project_query = select(Project).where(Project.title == "test12345") | ||
project_found = session.exec(project_query).first() | ||
assert project_found == project | ||
|
||
|
||
def test_project_session_scope( | ||
project_factory: SQLAlchemyModelFactory, session: Session | ||
) -> None: | ||
"check session scope is only within each unit test for factories" | ||
project_factory.create(title="test54321") | ||
|
||
project_query = select(Project).where(Project.title == "test12345") | ||
project_found = session.exec(project_query).first() | ||
assert project_found is None |
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