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

Fix test helpers for results #7002

Merged
merged 3 commits into from
Oct 13, 2022
Merged

Conversation

bpoldrack
Copy link
Member

@bpoldrack bpoldrack commented Sep 1, 2022

The helpers for testing result records had a couple of bugs.
Most noteably, some (e.g. assert_status) would pass when no result was
given at all. Therefore command calls that did not return any result
were passing assertions about the status field of their results.

Furthermore, most of those helpers did not properly deal with all three
"representations" of results that are (and need to be) passed to them:

  1. list of dict
  2. single dict
  3. generator

That's because ensure_list is used with the incoming results, but this
turns dicts that are not encapsulated by a list into a list of their
keys rather than a single-item list of dict. Reason for that is, that a
dict is iterable.

The falsely passing helpers also hid bugs in the tests - mostly command calls (clone) failing to set result_xfm correctly and therefore not getting result records back, but then proceeding to assertions about such result records.

This patch should fix this.

@bpoldrack bpoldrack marked this pull request as draft September 1, 2022 13:41
@mih
Copy link
Member

mih commented Sep 7, 2022

This change breaks a lot. Is there an issue that explains what is happening here, or why it needs doing? Or can this be closed?

@bpoldrack bpoldrack force-pushed the bf-result-assertions branch 2 times, most recently from b52f771 to 9e23c57 Compare October 12, 2022 13:23
@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Base: 74.88% // Head: 75.61% // Increases project coverage by +0.73% 🎉

Coverage data is based on head (4ce17b1) compared to base (ddd9b7b).
Patch coverage: 71.42% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##            maint    #7002      +/-   ##
==========================================
+ Coverage   74.88%   75.61%   +0.73%     
==========================================
  Files         355      355              
  Lines       59105    59312     +207     
  Branches     6318     6320       +2     
==========================================
+ Hits        44262    44851     +589     
+ Misses      14829    14446     -383     
- Partials       14       15       +1     
Impacted Files Coverage Δ
datalad/core/distributed/tests/test_clone.py 67.38% <63.63%> (-8.11%) ⬇️
datalad/tests/utils_pytest.py 89.91% <69.23%> (-0.22%) ⬇️
datalad/utils.py 73.85% <100.00%> (-2.16%) ⬇️
datalad/cmdline/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
datalad/cmdline/helpers.py 0.00% <0.00%> (-78.27%) ⬇️
datalad/__main__.py 39.65% <0.00%> (-29.32%) ⬇️
datalad/support/sshrun.py 92.85% <0.00%> (-4.65%) ⬇️
datalad/distribution/create_sibling.py 56.62% <0.00%> (-3.86%) ⬇️
datalad/interface/base.py 92.30% <0.00%> (-3.08%) ⬇️
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bpoldrack bpoldrack force-pushed the bf-result-assertions branch from 9e23c57 to ccb7f7a Compare October 12, 2022 14:29
@bpoldrack bpoldrack marked this pull request as ready for review October 12, 2022 14:37
@codeclimate
Copy link

codeclimate bot commented Oct 12, 2022

Code Climate has analyzed commit 16a162d and detected 0 issues on this pull request.

View more on Code Climate.

### Tests

- Fix broken test helpers for result record testing that would falsely pass.
https://github.com/datalad/datalad/pull/7002 (by @bpoldrack)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should tune up our template ... filed #7084 . up to you to fix it up or not here.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean like this: 4ce17b1 ?

@yarikoptic
Copy link
Member

why master and not maint - sounds like an important Fix to have in maint!

@yarikoptic
Copy link
Member

nice find -- thanks @bpoldrack ! IMHO should go against maint and ideally just get ensure_results helper to centralize "casting" ;)

The helpers for testing result records had a couple of bugs.
Most noteably, some (e.g. `assert_status`) would pass when no result was
given at all. Therefore command calls that did not return any result
were passing assertions about the `status` field of their results.

Furthermore, most of those helpers did not properly deal with all three
"representations" of results that are (and need to be) passed to them:
1. list of dict
2. single dict
3. generator

That's because `ensure_list` is used with the incoming results, but this
turns dicts that are not encapsulated by a list into a list of their
keys rather than a single-item list of dict. Reason for that is, that a
dict is iterable.

This patch should fix this.
Previous commit fixed a couple of test helpers for result record
testing. Those were falsely passing when they shouldn't and hid
bugs/mistakes in the tests themselves. Most noteably, that's command
calls (mostly `clone`) failing to set `result_xfm` correctly and
therefore not getting result records back, but then proceeding to
assertions about such result records.
@bpoldrack bpoldrack changed the base branch from master to maint October 13, 2022 06:54
@bpoldrack bpoldrack force-pushed the bf-result-assertions branch from 16a162d to 4ce17b1 Compare October 13, 2022 06:54
@bpoldrack bpoldrack added the semver-tests Changes only affect tests, no impact on version label Oct 13, 2022
@bpoldrack
Copy link
Member Author

Thx, @yarikoptic. All addressed, I think.

@yarikoptic
Copy link
Member

Looks great to me! -deprecated -- seems to be a real one to fix up, filed datalad/datalad-deprecated#69 . There is some minor nit-picking I could have done (avoidable diff now that there is a helper etc) but to progress -- let's just merge! Thank you @bpoldrack -- I will submit a test PR for merge maint into master shortly after this merge. Hopefully we would not get many failures in other untested here extensions whenever we release datalad ;-)

@yarikoptic yarikoptic merged commit 8ca27d7 into datalad:maint Oct 13, 2022
@yarikoptic-gitmate
Copy link
Collaborator

PR released in 0.17.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-tests Changes only affect tests, no impact on version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants