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

Metadata API: add Metadata.to_bytes() #1490

Merged
merged 1 commit into from
Jul 16, 2021

Conversation

MVrachev
Copy link
Collaborator

@MVrachev MVrachev commented Jul 9, 2021

Fixes #1487

Description of the changes being introduced by the pull request:

Metadata.to_bytes() is missing from the API and that is now becoming
annoying when writing the tests.
I think it makes sense to add:
it'll complete the serializing counterparts to from_bytes()/from_file().

Signed-off-by: Martin Vrachev mvrachev@vmware.com

Please verify and check that the pull request fulfills the following
requirements
:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

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.

Can we make use of the new to_bytes method from the to_file method? That avoids us duplicating logic which defines the default serialiser.

@MVrachev MVrachev force-pushed the metadata-to-bytes branch 2 times, most recently from ffc37b6 to af4329b Compare July 14, 2021 18:51
@MVrachev
Copy link
Collaborator Author

I updated the pr so that Metadata.to_file() uses Metadata.to_bytes().
Additionally, I added tests for the two cases for the JsonSerializer - compact and noncompact.

tuf/api/metadata.py Outdated Show resolved Hide resolved
Metadata.to_bytes() is missing from the API and that is now becoming
annoying when writing the tests.
I think it makes sense to add:
it'll complete the serializing counterparts to from_bytes()/from_file().

We can also reuse to_bytes() in to_file() and that way ensure we don't
import the JSONSerializer locally twice.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@jku jku merged commit 69dca08 into theupdateframework:develop Jul 16, 2021
@MVrachev MVrachev deleted the metadata-to-bytes branch July 19, 2021 13:35
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.

Metadata API: Add Metadata.to_bytes()
3 participants