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

Ensure verdi group show --limit respects limit even in raw mode #4092

Merged
merged 2 commits into from
May 20, 2020

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented May 20, 2020

Fixes #4091

The code is affected by the --limit flag both where the --raw flag
is enabled and if it is disabled. However, in the disabled case the
limit was not respected. This was not detected because the unit test
only tested the code path when --raw is enabled.

@codecov
Copy link

codecov bot commented May 20, 2020

Codecov Report

Merging #4092 into develop will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4092      +/-   ##
===========================================
- Coverage    78.81%   78.79%   -0.01%     
===========================================
  Files          463      463              
  Lines        34413    34413              
===========================================
- Hits         27119    27114       -5     
- Misses        7294     7299       +5     
Flag Coverage Δ
#django 70.71% <100.00%> (ø)
#sqlalchemy 71.59% <100.00%> (-0.01%) ⬇️
Impacted Files Coverage Δ
aiida/cmdline/commands/cmd_group.py 87.78% <100.00%> (ø)
aiida/orm/utils/log.py 76.67% <0.00%> (-16.66%) ⬇️

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 0f23507...88311b2. Read the comment docs.

The code is affected by the `--limit` flag both where the `--raw` flag
is enabled and if it is disabled. However, in the disabled case the
limit was not respected. This was not detected because the unit test
only tested the code path when `--raw` is enabled.
@sphuber sphuber force-pushed the fix/4091/verdi-group-show-limit branch from 82ecf9f to dab183a Compare May 20, 2020 13:41
@sphuber sphuber requested a review from ramirezfranciscof May 20, 2020 16:39
Copy link
Member

@ramirezfranciscof ramirezfranciscof left a comment

Choose a reason for hiding this comment

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

All good!

Comment on lines +201 to +202
self.assertTrue(not (str(nodes[0].pk) in result.output and str(nodes[1].pk) in result.output))

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps the second assert could be replaced by checking the length of the output to be 1? Feels a bit more straighforward and easy to read than the negative of the intersection (although less logically-fancy). Also it feels a bit more resistant to the DB leackeages that sometimes ocurr with the tests. Idk, just an idea, up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would agree that that would be easier, except, unfortunately, in this case the output is not a list. It is a single string. That is the reason I used --raw before in the original test, so I would only get the nodes as rows, so I could exactly use the count. But that caused the hiding of the bug that this very PR resolves. So I cannot use --raw and so I have to "parse" the full string, or at best the lines of the result. Since I don't want to make the parsing dependent on the number of header and footer lines, I solved it like this.

Copy link
Member

Choose a reason for hiding this comment

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

Uhm, I see, I didn't notice the string casting. Question: although I guess very unlikely, but this way of checking with strings could raise a false fail if the nodes were assigned, say, pk=1 and pk=12, because both "12" and "1" are in "12", correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well they should get adjacent identifiers, but that is besides the point. You are correct that this test is vulnerable to false positives, but also to false negatives.

@sphuber sphuber merged commit 5e02e16 into aiidateam:develop May 20, 2020
@sphuber sphuber deleted the fix/4091/verdi-group-show-limit branch May 20, 2020 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

verdi group show does not respect the limit if raw=False
2 participants