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

[DOM-39831] - added forward slash check for file upload #144

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to the `python-domino` library will be documented in this fi
* Fixed issues with import from domino_data
* Updated nbconvert dependency version to 6.3.0
* updated request user-agent to python-domino/{version}
* Changed file handling for `files_upload`

## 1.0.8

Expand Down
6 changes: 4 additions & 2 deletions domino/domino.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
DOMINO_HOST_KEY_NAME,
DOMINO_LOG_LEVEL_KEY_NAME,
MINIMUM_EXTERNAL_VOLUME_MOUNTS_SUPPORT_DOMINO_VERSION,
MINIMUM_GA_DOMINO_VERSION,
MINIMUM_SUPPORTED_DOMINO_VERSION,
MINIMUM_ON_DEMAND_SPARK_CLUSTER_SUPPORT_DOMINO_VERSION,
)
from domino.http_request_manager import _HttpRequestManager
Expand Down Expand Up @@ -52,7 +52,7 @@ def __init__(

# Get version
self._version = self.deployment_version().get("version")
assert self.requires_at_least(MINIMUM_GA_DOMINO_VERSION)
assert self.requires_at_least(MINIMUM_SUPPORTED_DOMINO_VERSION)

self._logger.debug(
f"Domino deployment {host} is running version {self._version}"
Expand Down Expand Up @@ -667,6 +667,8 @@ def files_list(self, commitId, path="/"):
return self._get(url)

def files_upload(self, path, file):
if not path.startswith("/"):
path = "/" + path
url = self._routes.files_upload(path)
return self._put_file(url, file)

Expand Down
11 changes: 11 additions & 0 deletions tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ def test_upload_file_to_project(default_domino_client):
assert response.status_code == 201
assert response.json()["path"] == "test_file.py"

def test_upload_file_to_project_without_forward_slash(default_domino_client):
"""
Confirm that the python-domino client can upload a file to a project.
"""
with open(__file__, "rb") as test_file:
response = default_domino_client.files_upload(
path="test_file.py", file=test_file
)
assert response.status_code == 201
assert response.json()["path"] == "test_file.py"


@pytest.mark.skipif(
not domino_is_reachable(), reason="No access to a live Domino deployment"
Expand Down