Skip to content
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

Add test helpers, rewrite integration tests #100

Merged
merged 9 commits into from
May 25, 2021

Conversation

Kyle-Verhoog
Copy link
Member

@Kyle-Verhoog Kyle-Verhoog commented Nov 28, 2020

Add test helpers to do proper input/output testing.

@Kyle-Verhoog Kyle-Verhoog added the no-changelog This does not need a user visible changelog label Nov 28, 2020
@Kyle-Verhoog Kyle-Verhoog requested a review from a team as a code owner November 28, 2020 23:58
@codecov-io
Copy link

codecov-io commented Nov 28, 2020

Codecov Report

Merging #100 (0bd9ccd) into master (27fd17d) will decrease coverage by 5.92%.
The diff coverage is 96.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
- Coverage   95.37%   89.44%   -5.93%     
==========================================
  Files           7        9       +2     
  Lines         584      597      +13     
==========================================
- Hits          557      534      -23     
- Misses         27       63      +36     
Impacted Files Coverage Δ
tests/test_cli.py 97.91% <ø> (-2.09%) ⬇️
tests/proctest.py 88.37% <88.37%> (ø)
tests/test_integration.py 100.00% <100.00%> (ø)
riot/riot.py 81.53% <0.00%> (-10.00%) ⬇️
riot/cli.py 90.00% <0.00%> (-5.00%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27fd17d...d04ac50. Read the comment docs.

riotfile.py Outdated Show resolved Hide resolved
tests/proctest.py Outdated Show resolved Hide resolved
tests/proctest.py Outdated Show resolved Hide resolved
tests/proctest.py Outdated Show resolved Hide resolved
tests/proctest.py Outdated Show resolved Hide resolved
tests/test_integration.py Outdated Show resolved Hide resolved
tests/test_integration.py Outdated Show resolved Hide resolved
assert result.stderr == ""
assert result.returncode == 0

result = run("riot list", cwd=tmp_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should get the same for riot run and riot generate right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, are you suggesting that we should also check those here? Would be an easy parametrization

tests/test_integration.py Show resolved Hide resolved
Comment on lines +217 to +218
test .* 'pkg1==1.0'
test .* 'pkg1==2.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should know this exact string no? since this is the python version and we know the currently running version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning here is that the interpreter could be platform dependent. Right now it'd be fine because the output there would probably just be Interpreter(_hint="3") but in #137 we'd also have the path to the interpreter.

What we can do is at least match on Interpreter(.*) or similar. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes me wonder if we need better output here than what we have now repr(Interpreter)

could make this more of a consistent format

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I am suggesting a specific change right now, just talking out loud.

Reduces the boilerplate of having to specify cwd every time when
commands are 99% of the time run in the tmp_path.
Protocol was only introduced in Python 3.8. typing_extensions makes
it available for older Pythons.
tests/test_integration.py Show resolved Hide resolved
tests/test_integration.py Outdated Show resolved Hide resolved
tests/test_integration.py Outdated Show resolved Hide resolved
tests/test_integration.py Show resolved Hide resolved
Comment on lines +217 to +218
test .* 'pkg1==1.0'
test .* 'pkg1==2.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes me wonder if we need better output here than what we have now repr(Interpreter)

could make this more of a consistent format

Comment on lines +217 to +218
test .* 'pkg1==1.0'
test .* 'pkg1==2.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I am suggesting a specific change right now, just talking out loud.

assert result.returncode == 1


def test_bad_interpreter(tmp_path: pathlib.Path, tmp_run: _T_TmpRun) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_bad_interpreter(tmp_path: pathlib.Path, tmp_run: _T_TmpRun) -> None:
@with_riotfile(
"""
from riot import Venv
venv = Venv(
...
)
"""
, filename="bad-riotfile.py", # Obviously the default is `riotfile.py`
)
def test_bad_interpreter(riotfile: pathlib.Path, tmp_run: _T_TmpRun) -> None:
Suggested change
def test_bad_interpreter(tmp_path: pathlib.Path, tmp_run: _T_TmpRun) -> None:
@with_riotfile_fixture("some-file-in-data-dir.py)
def test_bad_interpreter(riotfile: pathlib.Path, tmp_run: _T_TmpRun) -> None:

Just writing something down as a trial to see how it felt, not suggesting a change here.

Co-authored-by: Brett Langdon <me@brett.is>
@jd jd added the manual merge Do not merge automatically label May 25, 2021
Copy link
Contributor

@jd jd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Adding manual merge in case we want another review.
Feel free to remove it if everyone's happy.

@brettlangdon brettlangdon removed the manual merge Do not merge automatically label May 25, 2021
@mergify mergify bot merged commit 5ad6e6d into DataDog:master May 25, 2021
@Kyle-Verhoog Kyle-Verhoog deleted the tests branch May 25, 2021 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog This does not need a user visible changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants