-
Notifications
You must be signed in to change notification settings - Fork 294
Add integration tests using InvocationMode.SUBPROCESS and validate output
#2287
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
094bf92
Tmp commit with WIP code
tatiana e6baa5c
Fix test
tatiana 1cb4117
Fix test
tatiana e4234c7
Revert integraion test temporary change
tatiana fdad323
Fix MyPy checks
tatiana be798d9
Add tests
tatiana 7c05492
Fix test
tatiana 0595504
Normalise Cosmos logs
tatiana 58d3100
Fix integration test that was failing due to capsys/caplog
tatiana 2a6d5a8
Merge branch 'main' into refactor-watcher-log-processor
tatiana 435a2ee
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] 503d80d
Merge branch 'main' into refactor-watcher-log-processor
tatiana 4f4e514
Remove no longer needed tests
tatiana e6ba318
Revert changes to example dag
tatiana d4f61ba
Apply suggestion from @tatiana
tatiana 822c5c9
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] 441ae2d
Address feedback from copilot on code duplicate
tatiana e0f6b83
Merge branch 'main' into refactor-watcher-log-processor
tatiana 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
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,39 @@ | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| from cosmos.dbt.executable import get_system_dbt, is_dbt_installed_in_same_environment | ||
|
|
||
|
|
||
| class TestGetSystemDbt: | ||
| @patch("shutil.which") | ||
| def test_get_system_dbt_returns_path_when_found(self, mock_which): | ||
| """Test that get_system_dbt returns the path when dbt is found.""" | ||
| mock_which.return_value = "/usr/local/bin/dbt" | ||
| result = get_system_dbt() | ||
| assert result == "/usr/local/bin/dbt" | ||
| mock_which.assert_called_once_with("dbt") | ||
|
|
||
| @patch("shutil.which") | ||
| def test_get_system_dbt_returns_dbt_when_not_found(self, mock_which): | ||
| """Test that get_system_dbt returns 'dbt' when dbt is not found.""" | ||
| mock_which.return_value = None | ||
| result = get_system_dbt() | ||
| assert result == "dbt" | ||
| mock_which.assert_called_once_with("dbt") | ||
|
|
||
|
|
||
| class TestIsDbtInstalledInSameEnvironment: | ||
| @patch("cosmos.dbt.executable.find_spec") | ||
| def test_is_dbt_installed_in_same_environment_returns_true_when_dbt_found(self, mock_find_spec): | ||
| """Test that is_dbt_installed_in_same_environment returns True when find_spec finds dbt.""" | ||
| mock_find_spec.return_value = MagicMock() # Simulates dbt module spec found | ||
| result = is_dbt_installed_in_same_environment() | ||
| assert result is True | ||
| mock_find_spec.assert_called_once_with("dbt") | ||
|
|
||
| @patch("cosmos.dbt.executable.find_spec") | ||
| def test_is_dbt_installed_in_same_environment_returns_false_when_import_error(self, mock_find_spec): | ||
| """Test that is_dbt_installed_in_same_environment returns False when find_spec raises ImportError.""" | ||
| mock_find_spec.side_effect = ImportError("No module named 'dbt'") | ||
| result = is_dbt_installed_in_same_environment() | ||
| assert result is False | ||
| mock_find_spec.assert_called_once_with("dbt") |
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
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.
Uh oh!
There was an error while loading. Please reload this page.