-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor/remove prysk #87
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
6 commits
Select commit
Hold shift + click to select a range
7207a0b
Updated poetry.lock
266156c
Added generated workflow files
ckunki 3d10c4a
Updated pytest
ckunki 2c8c0cb
Removed prysk and replaced integration tests by ordinary pytest itests
ckunki f3f41b9
Merge branch 'main' into refactor/remove-prysk
ckunki ba6fd2a
nox -s format:fix
ckunki 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 |
|---|---|---|
|
|
@@ -137,3 +137,6 @@ doc/_build | |
|
|
||
| .lint.json | ||
| .lint.txt | ||
|
|
||
| /.serena | ||
| /.codex | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import json | ||
| import os | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| REPO_ROOT = Path(__file__).resolve().parents[2] | ||
| PYMODULE_CONTENT = """from exasol import error | ||
| from exasol.error import Parameter | ||
| error1 = error.ExaError( | ||
| "E-TEST-1", | ||
| "this is an error", | ||
| ["no mitigation available"], | ||
| {"param": Parameter("value", "some description")}, | ||
| ) | ||
| error2 = error.ExaError( | ||
| "E-TEST-2", "this is an error", ["no mitigation available"], {"param": "value"} | ||
| ) | ||
| """ | ||
| EXPECTED_ERRORS = [ | ||
| { | ||
| "identifier": "E-TEST-1", | ||
| "message": "this is an error", | ||
| "messagePlaceholders": [ | ||
| {"placeholder": "param", "description": "some description"} | ||
| ], | ||
| "description": None, | ||
| "internalDescription": None, | ||
| "potentialCauses": None, | ||
| "mitigations": ["no mitigation available"], | ||
| "sourceFile": "pymodule.py", | ||
| "sourceLine": 3, | ||
| "contextHash": None, | ||
| }, | ||
| { | ||
| "identifier": "E-TEST-2", | ||
| "message": "this is an error", | ||
| "messagePlaceholders": [{"placeholder": "param", "description": ""}], | ||
| "description": None, | ||
| "internalDescription": None, | ||
| "potentialCauses": None, | ||
| "mitigations": ["no mitigation available"], | ||
| "sourceFile": "pymodule.py", | ||
| "sourceLine": 9, | ||
| "contextHash": None, | ||
| }, | ||
| ] | ||
|
|
||
|
|
||
| def _env(): | ||
| env = os.environ.copy() | ||
| pythonpath = env.get("PYTHONPATH") | ||
| env["PYTHONPATH"] = ( | ||
| f"{REPO_ROOT}{os.pathsep}{pythonpath}" if pythonpath else str(REPO_ROOT) | ||
| ) | ||
| return env | ||
|
|
||
|
|
||
| def _run(command: list[str], *args: str, cwd: Path) -> subprocess.CompletedProcess[str]: | ||
| return subprocess.run( | ||
| [*command, "--debug", *args], | ||
| cwd=cwd, | ||
| env=_env(), | ||
| check=True, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
|
|
||
|
|
||
| def _commands(): | ||
| yield pytest.param([sys.executable, "-m", "exasol.error"], id="module-entrypoint") | ||
| ec_path = shutil.which("ec") | ||
| if ec_path: | ||
| yield pytest.param([ec_path], id="console-script") | ||
| else: | ||
| yield pytest.param( | ||
| [sys.executable, "-c", "from exasol.error._cli import main; main()"], | ||
| id="cli-module-fallback", | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_module(tmp_path: Path) -> Path: | ||
| module = tmp_path / "pymodule.py" | ||
| module.write_text(PYMODULE_CONTENT, encoding="utf-8") | ||
| return module | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("command", _commands()) | ||
| def test_parse_subcommand(command: list[str], sample_module: Path): | ||
| result = _run(command, "parse", sample_module.name, cwd=sample_module.parent) | ||
|
|
||
| assert result.stderr == "" | ||
| assert [json.loads(line) for line in result.stdout.splitlines()] == EXPECTED_ERRORS | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("command", _commands()) | ||
| def test_generate_subcommand(command: list[str], sample_module: Path): | ||
| result = _run( | ||
| command, "generate", "modulename", "1.2.0", ".", cwd=sample_module.parent | ||
| ) | ||
|
|
||
| assert result.stderr == "" | ||
| assert json.loads(result.stdout) == { | ||
| "$schema": "https://schemas.exasol.com/error_code_report-1.0.0.json", | ||
| "projectName": "modulename", | ||
| "projectVersion": "1.2.0", | ||
| "errorCodes": EXPECTED_ERRORS, | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
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.
Can --debug cause any stderr output?
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 did not find any reference to CLI option
--debugexcept in_cli.py.Hence, I don't assume CLI option
--debugto cause any specific output.However, with or without CLI option
--debugI think, output to stderr is possible.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 meant the
--debugin_run(...). But maybe I am lacking the context, so feel free to ignore it.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.
My current guess is, that the CLI option
--debugis used to preventsubprocess.run()to raise errors during integration tests.Actually I think this is not optimal and could be avoided by using
click.CliRunner().I also see some more questionable things, e.g.
ec_path = shutil.which("ec").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.
The tests are not perfect, but better then prysk. For that reason, I suggest we merge them for the moment and we create a ticket to refactor the cli and make it easier testable.
Uh oh!
There was an error while loading. Please reload this page.
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.
See