Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use different database to run the unit tests #2987

Closed
gabrielmbmb opened this issue May 25, 2023 · 0 comments · Fixed by #2993
Closed

Use different database to run the unit tests #2987

gabrielmbmb opened this issue May 25, 2023 · 0 comments · Fixed by #2993
Assignees
Labels
type: enhancement Indicates new feature requests

Comments

@gabrielmbmb
Copy link
Member

gabrielmbmb commented May 25, 2023

The current setup for the unit tests uses the same engine with the same URL for connecting to the database that gets deployed when executing the Argilla server locally. This is not ideal, because if you have played with the server, added datasets, annotated, etc, and then run the unit tests, the database will get erased losing all the work done manually.

Apart from that, the current pytest fixture to yield the DB session is removing all the rows from the tables after the test gets executed instead of rolling back.

I would like a different database to be used to run the unit tests and to roll back the transactions instead of removing all the rows after the test gets executed.

@gabrielmbmb gabrielmbmb added the type: enhancement Indicates new feature requests label May 25, 2023
@gabrielmbmb gabrielmbmb self-assigned this May 25, 2023
@gabrielmbmb gabrielmbmb linked a pull request May 25, 2023 that will close this issue
11 tasks
@gabrielmbmb gabrielmbmb added area: api Indicates that an issue or pull request is related to the Fast API server or REST endpoints and removed area: api Indicates that an issue or pull request is related to the Fast API server or REST endpoints labels May 26, 2023
frascuchon pushed a commit that referenced this issue May 31, 2023
# Description

I've updated the unit test setup to use a different database than the
one used by the local deployment of the Argilla server. In addition,
I've updated the pytest fixtures that provided a connection to the DB,
and now before executing every test a new transaction is created that
gets rollbacked when the execution of the test has finished, leaving no
traces in the DB.

Also, I've aligned the SQLAlchemy models metadata with the metadata in
the current alembic migrations scripts.

Closes #2987 

**Type of change**

- [x] New feature (non-breaking change which adds functionality)
- [x] Refactor (change restructuring the codebase without changing
functionality)
- [x] Improvement (change adding some improvement to an existing
functionality)

**How Has This Been Tested**

All the unit tests are passing using this new DB for the tests.

**Checklist**

- [x] I have merged the original branch into my forked branch
- [ ] I added relevant documentation
- [x] follows the style guidelines of this project
- [x] I did a self-review of my code
- [ ] I made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant