-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Repository unit tests for ManifestLoader.get_full_manifest
#10147
Merged
QMalcolm
merged 6 commits into
main
from
qmalcolm--9865-repo-unit-test-get_full_manifest
May 15, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
15f27b6
Add test for different `write_perf_info` values to `get_full_manifest`
QMalcolm a54d734
Add test for different `reset` values to `get_full_manifest`
QMalcolm 791ec1d
Abstract required mocks for `get_full_manifest` tests to reduce dupli…
QMalcolm 8dc4228
Add test for different `PARTIAL_PARSE_FILE_DIFF` values to `get_full_…
QMalcolm 184fe9a
Refactor mock fixtures in `test_manifest.py` to make them more widely…
QMalcolm 16edcbb
Convert `set_required_mocks` of `TestGetFullManifest` into a fixture
QMalcolm 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 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 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 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,21 @@ | ||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
|
||
from dbt.adapters.postgres import PostgresAdapter | ||
from dbt.adapters.sql import SQLConnectionManager | ||
|
||
|
||
@pytest.fixture | ||
def mock_connection_manager() -> MagicMock: | ||
mock_connection_manager = MagicMock(SQLConnectionManager) | ||
mock_connection_manager.set_query_header = lambda query_header_context: None | ||
return mock_connection_manager | ||
|
||
|
||
@pytest.fixture | ||
def mock_adapter(mock_connection_manager: MagicMock) -> MagicMock: | ||
mock_adapter = MagicMock(PostgresAdapter) | ||
mock_adapter.connections = mock_connection_manager | ||
mock_adapter.clear_macro_resolver = MagicMock() | ||
return mock_adapter |
This file contains 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
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.
Is it possible to do the patch inside the fixture? So users of those fixtures can just request the fixture then the patch is done?
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.
I tried doing so but, as noted in the commit message of 791ec1d, the mocks stopped propagating when I did so. I can take another stab at it, but can't make any promises. It definitely would be nice if we could do it as a fixture though.
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.
Converting it to a fixture does seem to work now. Not sure why it didn't before and why it does now 🤔 🤷
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.
I wonder whether it was not imported properly before