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

tests: update env.py and conftest so tests use unique databases #3654

Merged
merged 36 commits into from
Oct 10, 2024

Conversation

ogabrielluiz
Copy link
Contributor

This pull request includes refactoring of the Alembic environment script to simplify the database connection logic and remove unused imports. It also refactors the test client fixture to use TemporaryDirectory and UUID for the database path. These changes improve the code readability and maintainability.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 2, 2024
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3654.dmtpw4p5recq1.amplifyapp.com

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Sep 3, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 3, 2024
- Added cleanup steps to various pytest fixtures to ensure temporary directories, database entries, and other resources are properly cleaned up after tests.
- Modified fixtures to use `yield` for better resource management.
- Ensured database connections are closed and tables are dropped after tests.
- Improved temporary directory handling with context managers.
… and fixtures, and update existing fixtures for consistency.
- Corrected the import order in `utils.py`.
- Added validation for `flow_id` in the transaction handling logic to ensure it is set correctly.
- Introduced `_delete_transactions_and_vertex_builds` function to remove transactions and vertex builds associated with a user.
- Updated `user` fixture to call the new cleanup function before deleting the user.
@ogabrielluiz ogabrielluiz marked this pull request as draft September 6, 2024 18:05
@ogabrielluiz ogabrielluiz marked this pull request as ready for review October 8, 2024 11:31
@ogabrielluiz ogabrielluiz removed the request for review from nicoloboschi October 8, 2024 11:32
@ogabrielluiz ogabrielluiz added lgtm This PR has been approved by a maintainer and removed lgtm This PR has been approved by a maintainer labels Oct 9, 2024
Copy link
Contributor

github-actions bot commented Oct 9, 2024

Cannot auto-update because of conflicts.

@ogabrielluiz ogabrielluiz added lgtm This PR has been approved by a maintainer and removed lgtm This PR has been approved by a maintainer labels Oct 9, 2024
@ogabrielluiz ogabrielluiz added lgtm This PR has been approved by a maintainer and removed lgtm This PR has been approved by a maintainer labels Oct 9, 2024
@ogabrielluiz ogabrielluiz added lgtm This PR has been approved by a maintainer and removed lgtm This PR has been approved by a maintainer labels Oct 10, 2024
@ogabrielluiz ogabrielluiz merged commit 2adda78 into main Oct 10, 2024
27 checks passed
@ogabrielluiz ogabrielluiz deleted the fix/migrationenvpy branch October 10, 2024 11:45
diogocabral pushed a commit to headlinevc/langflow that referenced this pull request Nov 26, 2024
…flow-ai#3654)

* Refactor Alembic environment script to simplify database connection logic and remove unused imports

* Refactor test client fixture to use TemporaryDirectory and UUID for database path

* Add `reload_engine` method to reinitialize the database engine

* Add cleanup steps to test fixtures to ensure proper resource management

- Added cleanup steps to various pytest fixtures to ensure temporary directories, database entries, and other resources are properly cleaned up after tests.
- Modified fixtures to use `yield` for better resource management.
- Ensured database connections are closed and tables are dropped after tests.
- Improved temporary directory handling with context managers.

* Add unit test to verify return type of list_flows method in custom component

* Refactor tests in `test_custom_component.py` to remove unused imports and fixtures, and update existing fixtures for consistency.

* Add debug checks for user existence in `test_user_waiting_for_approval` test

* Fix import order and add flow_id validation in transaction handling

- Corrected the import order in `utils.py`.
- Added validation for `flow_id` in the transaction handling logic to ensure it is set correctly.

* Add function to delete transactions by flow ID in CRUD module

* Add cleanup for transactions and vertex builds in test teardown

- Introduced `_delete_transactions_and_vertex_builds` function to remove transactions and vertex builds associated with a user.
- Updated `user` fixture to call the new cleanup function before deleting the user.

* Refactor flow_id assignment logic in `utils.py` to improve readability and correctness

* [autofix.ci] apply automated fixes

* Refactor test to use pytest's tmp_path fixture for temporary directory creation

* Convert `test_user_waiting_for_approval` to an async test function

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants