brighthive / data-resource-api

An elegant, opinionated framework for deploying BrightHive Data Resources with zero coding.
MIT License
4 stars 1 forks source link

SQLAlchemy, clear database content but don't drop the schema #68

Closed loganripplinger closed 4 years ago

loganripplinger commented 4 years ago

Story details: https://app.clubhouse.io/brighthive/story/681

This PR makes two significant improvements to the test suite.

  1. Database will stay up during the duration of the test. Between module tests the entire DB is emptied.
  2. Each function level test will perform a tear down and clear the database and will preserve the tables present.

In total this reduces the full test time from one minute to 3 seconds.

If the database needs to be stood or taken down it takes 7 seconds to perform on my machine. If you want to leave the database up after the tests have been run for the lightning fast 3 second tests then provide the following env var:

DR_LEAVE_DB=true pipenv run pytest