Skip to content

Conversation

@cmutel
Copy link

@cmutel cmutel commented Jan 7, 2025

Allow for Postgres as a backend through setting environment variables:

  • BW_DATA_POSTGRES: Should be truthy
  • BW_DATA_POSTGRES_DATABASE: Postgres database name
  • BW_DATA_POSTGRES_USER: Postgres username
  • BW_DATA_POSTGRES_PASSWORD: Postgres password for username
  • BW_DATA_POSTGRES_PORT: Port, default is 5432
  • BW_DATA_POSTGRES_URL: Host URL, default is "localhost"

Current test implementation uses testcontainers, and tests on both Postgres and SQLite. The implementation isn't ideal as the container is rebuilt on each test, making them much slower than the SQLite tests. However, there are enough differences in the Peewee implementation that tests against Postgres are necessary, even in development.

Under Postgres there is no difference between projects, as we don't have separate database per project. This can be addressed later.

Only the tests in tests/database.py have been adapted - the switch from a decorator to a pytest fixture means either manual adaptation or some clever regex function needs to be applied.

cmutel added 9 commits January 7, 2025 11:07
I don't understand why disabling search functionality would effect these tests, but don't care enough to find out as we want to change the events in any case.
psycopg2 is default for Peewee
Uses testcontainers and changes decorator to pytest parameterized fixture which runs on both SQLite and Postgres.

Testcontainers requires a working installation of Docker. See https://java.testcontainers.org/supported_docker_environment/
@cmutel cmutel marked this pull request as draft January 7, 2025 15:09
@cmutel cmutel requested a review from jsvgoncalves January 7, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants