-
Notifications
You must be signed in to change notification settings - Fork 28
Improve test coverage by adding tests and removing dead code, bump fail-under to 92% #1222
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
8 commits
Select commit
Hold shift + click to select a range
87d5e17
Remove an unused internal module for 'activation'
sirosen 0431af3
Exclude local flake8 plugin from coverage reports
sirosen 2530a9a
Remove unused `get_endpoint_w_server_list` helper
sirosen 2ca67fa
Inline helper at its only usage site
sirosen dd65be0
Add a test for the `--map-http-status` option
sirosen 7c79135
Add tests for the `IdentityType` param type
sirosen 9dcfe11
Add tests of the version command
sirosen c252e4c
Update coverage fail under to 92%
sirosen 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 was deleted.
Oops, something went wrong.
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,120 @@ | ||
| import importlib.metadata | ||
| import textwrap | ||
|
|
||
| import pytest | ||
| import responses | ||
|
|
||
|
|
||
| def fmt_mod_info(modname): | ||
| mod = __import__(modname) | ||
| ver = importlib.metadata.distribution(modname).version | ||
| filepath, syspath = mod.__file__, mod.__path__ | ||
|
|
||
| return textwrap.dedent( | ||
| f"""\ | ||
| {modname}: | ||
| __version__: {ver} | ||
| __file__: {filepath} | ||
| __path__: {syspath} | ||
| """ | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def installed_cli_version(): | ||
| return importlib.metadata.distribution("globus_cli").version | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_pypi_version(): | ||
| def func(version): | ||
| responses.get( | ||
| url="https://pypi.python.org/pypi/globus-cli/json", | ||
| json={"releases": [version]}, | ||
| ) | ||
|
|
||
| return func | ||
|
|
||
|
|
||
| def test_version_command_on_latest(run_line, mock_pypi_version, installed_cli_version): | ||
| mock_pypi_version(installed_cli_version) | ||
|
|
||
| result = run_line("globus version") | ||
| assert result.output == textwrap.dedent( | ||
| f"""\ | ||
| Installed version: {installed_cli_version} | ||
| Latest version: {installed_cli_version} | ||
|
|
||
| You are running the latest version of the Globus CLI | ||
| """ | ||
| ) | ||
|
|
||
|
|
||
| def test_version_command_on_preview(run_line, mock_pypi_version, installed_cli_version): | ||
| mock_pypi_version("1.0") | ||
|
|
||
| result = run_line("globus version") | ||
| assert result.output == textwrap.dedent( | ||
| f"""\ | ||
| Installed version: {installed_cli_version} | ||
| Latest version: 1.0 | ||
|
|
||
| You are running a preview version of the Globus CLI | ||
| """ | ||
| ) | ||
|
|
||
|
|
||
| def test_version_command_newer_available( | ||
| run_line, mock_pypi_version, installed_cli_version | ||
| ): | ||
| major = int(installed_cli_version.partition(".")[0]) | ||
| latest = f"{major+1}.0" | ||
| mock_pypi_version(latest) | ||
|
|
||
| result = run_line("globus version") | ||
| assert result.output == textwrap.dedent( | ||
| f"""\ | ||
| Installed version: {installed_cli_version} | ||
| Latest version: {latest} | ||
|
|
||
| You should update your version of the Globus CLI with | ||
| globus update | ||
| """ | ||
| ) | ||
|
|
||
|
|
||
| def test_verbose_version_command_shows_related_package_versions( | ||
| run_line, mock_pypi_version, installed_cli_version | ||
| ): | ||
| mock_pypi_version(installed_cli_version) | ||
|
|
||
| result = run_line("globus version -v") | ||
|
|
||
| # TODO: do more to validate this output | ||
| for modname in ( | ||
| "globus_cli", | ||
| "globus_sdk", | ||
| "requests", | ||
| ): | ||
| assert textwrap.indent(fmt_mod_info(modname), " ") in result.output | ||
|
|
||
| assert "click" not in result.output | ||
| assert "cryptography" not in result.output | ||
| assert "jmespath" not in result.output | ||
|
|
||
|
|
||
| def test_very_verbose_version_command_shows_more_related_package_versions( | ||
| run_line, mock_pypi_version, installed_cli_version | ||
| ): | ||
| mock_pypi_version(installed_cli_version) | ||
|
|
||
| result = run_line("globus version -vv") | ||
| for modname in ( | ||
| "click", | ||
| "cryptography", | ||
| "globus_cli", | ||
| "globus_sdk", | ||
| "jmespath", | ||
| "requests", | ||
| ): | ||
| assert textwrap.indent(fmt_mod_info(modname), " ") in result.output |
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.
I have a feeling this shouldn't be in the
src/tree to begin with, but this is currently a helpful omission!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.
Yeah, I can understand that. In SDK we put the sphinx stuff (similar) into
src/globus_sdk/_internal/. We need various things to be importable in different contexts (e.g., tests) and I've not worked out a uniform pattern for this yet.