-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Remove/Keep only specified DBs in mongodb_factory #812
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
Open
tyzhnenko
wants to merge
12
commits into
dbfixtures:main
Choose a base branch
from
tyzhnenko:add_filter_for_databases
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6ba5d17
feat: Remove only specified DBs in mongodb_factory
tyzhnenko 8e9159a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c35915a
docs: add 812.feature.rst
tyzhnenko 326f2df
bug: fix configuration
tyzhnenko 0ec9aab
chore: typo fix
tyzhnenko 011b08a
chore: make linter happy
tyzhnenko 6154e7c
feat: add keep parameter
tyzhnenko 839353c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 71ee7ac
docs: update newsfragments
tyzhnenko 80a15fd
chore: set type to parser ini
tyzhnenko 1443d37
chore: make linter happy
tyzhnenko 294e28d
chore: make linter happy p.2
tyzhnenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Improve mongodb_factory to keep or delete provided databases. | ||
| It's useful to run xdist tests in parallel, and avoid deleting databases created by other test workers. | ||
| Now you can keep preseed databases which won't be deleted after each test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """Test MongoDB cleanup functionality.""" | ||
|
|
||
| from pymongo import MongoClient | ||
|
|
||
|
|
||
| def test_clean_specified_databases(mongodb4: MongoClient) -> None: | ||
| """Test if only specified databases are cleaned.""" | ||
| test_db = mongodb4["test_db"] | ||
| test_db.test.insert_one({"test": "test"}) | ||
| test_db2 = mongodb4["test_db2"] | ||
| test_db2.test.insert_one({"test": "test"}) | ||
|
|
||
| assert "test_db" in mongodb4.list_database_names() | ||
| assert "test_db2" in mongodb4.list_database_names() | ||
|
|
||
|
|
||
| def test_clean_specified_databases_again(mongodb5: MongoClient) -> None: | ||
| """Test if only specified databases are cleaned.""" | ||
| assert "test_db" not in mongodb5.list_database_names() | ||
| assert "test_db2" in mongodb5.list_database_names() | ||
|
|
||
|
|
||
| def test_keep_specified_databases(mongodb5: MongoClient) -> None: | ||
| """Test if only specified databases are kept.""" | ||
| assert "test_db" not in mongodb5.list_database_names() | ||
| assert "test_db2" in mongodb5.list_database_names() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tyzhnenko I think it'd be easier to maintain a single list, just name it dbs, that would describe the databases we'll be managing in the breath of this client fixture. Don't like the double list here.
Now, if it's defined, attempt to delete them, and only them.
End goal would be to drop the delete all behavior.
Two options: