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

Assets: default asset name to empty string #4416

Conversation

clebergnu
Copy link
Contributor

Instead of allowing it to be given an explicit None. The problem with
allowing None is that the name is given to Python's urlparse(), and it
has the behavior of returning either a ParseResult or a
ParseResultBytes depending on the input given.

To prevent having to add further logic on a large part of the asset
code, let's just normalize the input.

Reference: https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse
Signed-off-by: Cleber Rosa crosa@redhat.com

Instead of allowing it to be given an explicit None.  The problem with
allowing None is that the name is given to Python's urlparse(), and it
has the behavior of returning either a ParseResult or a
ParseResultBytes depending on the input given.

To prevent having to add further logic on a large part of the asset
code, let's just normalize the input.

Reference: https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Copy link
Contributor

@wainersm wainersm left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -62,7 +62,7 @@ def __init__(self, name, asset_hash=None, algorithm=None, locations=None,
:param expire: time in seconds for the asset to expire
:param metadata: metadata which will be saved inside metadata file
"""
self.name = name
self.name = name or ''
Copy link
Contributor

Choose a reason for hiding this comment

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

With a high-level look at the code, I think it will cause misbehavior in the Asset API. I'll do a more in-depth review and test on Monday.

@codeclimate
Copy link

codeclimate bot commented Feb 12, 2021

Code Climate has analyzed commit 229d64f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 70.3% (0.0% change).

View more on Code Climate.

@willianrampazzo willianrampazzo merged commit 9abe250 into avocado-framework:master Feb 23, 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.

None yet

3 participants