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

Avoid using falsy tests for None #1390

Merged
merged 2 commits into from
May 18, 2021

Conversation

jku
Copy link
Member

@jku jku commented May 14, 2021

Fix a bug in DelegatedRole serialization and change all "falsy" object comparisons to something else.

A DelegatedRole with paths=[] fails to serialize correctly (paths is not
included in the output json).

Fix the issue, modify tests to notice a regression.

Fixes theupdateframework#1389

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
@jku
Copy link
Member Author

jku commented May 14, 2021

The fact that these issues are found tells me our testing is not adequate. I'll file an issue on that, if one does not exist: #1391

@jku jku requested a review from sechkova May 14, 2021 11:58
Copy link
Contributor

@sechkova sechkova left a comment

Choose a reason for hiding this comment

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

One comment about a test case, otherwise LGTM.

tests/test_api.py Outdated Show resolved Hide resolved
Use either "if X is not None:" or a try-except instead of a "if X:".

I believe Targets.from_dict() was not really broken with previous code
but it looks suspicious and did fail the added test with a strange
exception: I expect the from_dict() methods to mainly fail with
KeyErrors, ValueErrors or AttributeErrors if file format structure
is incorrect.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
@jku jku force-pushed the no-falsy-tests-for-none branch from 73a8f24 to 14f5957 Compare May 14, 2021 13:14
Copy link
Member

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

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

Nice fixes, thanks!

@jku jku merged commit d002dcd into theupdateframework:develop May 18, 2021
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.

3 participants