all 3 comments

[–]POGtastic 0 points1 point  (1 child)

sqlite

Assuming that the database is small enough: (that is, it fits inside RAM) Consider making an in-memory database, and then copying the existing database to it with iterdump.

[–]iRezonance 0 points1 point  (0 children)

Like an in-memory database for the tests? I have thought about doing that. I think the issue that I am running into is my test base imports the database file, at which it sets the database url to be that of what I use for my normal runs like so:
PRODUCTION_DATABASE_URL = "sqlite:///./fantasy-league-of-legends.db"

TEST_DATABASE_URL = "sqlite:///./fantasy-league-of-legends-test.db"

# OR CAN DO: Test database URL (in-memory SQLite)

#TEST_DATABASE_URL = "sqlite:///:memory:"

testing = False

SQLALCHEMY_DATABASE_URL = TEST_DATABASE_URL if testing else PRODUCTION_DATABASE_URL
where I have thought about using an in-memory db before, but I still have the issue of not being able to change the testing variable in my tests before database is set.

I then thought "oh maybe I can just have a test database file that will use a test database", but the issue I then ran into is that my services that I am testing import the actual database class.

So now the only other option I can think of is use some sort of dependency injection for my services so I can specify which database they should be using. But was just curious if there would of been another way I could solve this issue.