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

Artifacts #12

Merged
merged 30 commits into from
Jan 6, 2020
Merged

Artifacts #12

merged 30 commits into from
Jan 6, 2020

Conversation

anancarv
Copy link
Owner

No description provided.

@anancarv
Copy link
Owner Author

Wait for review to upgrade package version

Repository owner deleted a comment Oct 3, 2019
Repository owner deleted a comment Oct 4, 2019
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
pyartifactory/objects.py Outdated Show resolved Hide resolved
pyartifactory/objects.py Outdated Show resolved Hide resolved
pyartifactory/objects.py Outdated Show resolved Hide resolved
tests/test_artifacts.py Outdated Show resolved Hide resolved
Comment on lines 56 to 58
artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
artifact = artifactory.download(ARTIFACT_PATH)
os.remove("file.txt")
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the "Temporary files & directories" fixtures from Pytest to avoid deleting files: https://docs.pytest.org/en/latest/tmpdir.html

pyartifactory/objects.py Outdated Show resolved Hide resolved
@@ -0,0 +1,123 @@
import os
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we check any failure case in this test?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's only used for removing the file.txt file

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wasn't talking about the os import, I just wanted to add a comment to the whole file... But anyway, you told me that Artifactory cannot fail, so there is no test for that.
Maybe at least something like testing a download for which the artifact is not found?

Repository owner deleted a comment Jan 2, 2020
README.md Outdated

# Update user
user.email = "[email protected]"
updated_user = art.users.update(User(**user.dict()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

With your version of Pydantic you have access to the User.parse_obj method, which is exactly for this use case: https://pydantic-docs.helpmanual.io/usage/models/#helper-functions

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, why do you need to create a new user from the old instance? Can't you just pass the modified user?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Right, I can pass the pass the modified user

Comment on lines +26 to +29
class User(BaseUserModel):
email: Optional[EmailStr] = None


Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this new model represent? (Just asking ^^)

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is for fixing the update user issue. Indeed, the method update user used to require a NewUser object. However, this object contains a password, which is problematic for update operations. Therefore, I created this new model only for the update operation.

Comment on lines 601 to 603
if local_file_path:
Path(local_file_path).mkdir(parents=True, exist_ok=True)
local_file_full_path = f"{local_file_path}/{local_filename}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you call your method parameter local_file_path, I expect the artifact to be saved under this exact name, and not to create a directory called local_file_path in which the artifact will be saved.

requests = "^2.21"
email_validator = "^1.0"
requests_toolbelt = "^0.9.1"
pydantic = "^1.3"

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Adding a comment on this line because I cannot add it below)
If you upgrade the versions of mypy, black and detect-secrets in the pre-commit config, you should update them here too ^^

)

artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
artifact = artifactory.download(ARTIFACT_PATH, LOCAL_FILE_PATH)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would really use the tmp_path Pytest fixture instead of managing test created files manually...

artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
artifact = artifactory.download(ARTIFACT_PATH, LOCAL_FILE_PATH)

assert artifact == f"{LOCAL_FILE_PATH}/{artifact_name}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you also assert that a file has really been created?

@anancarv
Copy link
Owner Author

anancarv commented Jan 6, 2020

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- tests/test_artifacts.py  3
- pyartifactory/objects.py  2
- pyartifactory/models/Artifact.py  1
         

Clones removed
==============
+ tests/test_users.py  -2
         

See the complete overview on Codacy

@anancarv anancarv merged commit 0f54563 into master Jan 6, 2020
@anancarv anancarv deleted the artifacts branch January 6, 2020 12:55
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.

2 participants