mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
exp share refactor - ping on exp:remove, do not fail on error (#9248)
studio experiments share refactor 1) Pings Studio on exp remove 2) Does not fail on any error during request.post 3) UI improvement on exp remove
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from requests import Response
|
||||
|
||||
from dvc.repo.experiments.push import STUDIO_URL, _notify_studio
|
||||
|
||||
|
||||
def test_notify_studio_for_exp_push(mocker):
|
||||
valid_response = Response()
|
||||
valid_response.status_code = 200
|
||||
mock_post = mocker.patch("requests.Session.post", return_value=valid_response)
|
||||
|
||||
_notify_studio(
|
||||
["ref1", "ref2", "ref3"],
|
||||
"[email protected]:iterative/dvc.git",
|
||||
"TOKEN",
|
||||
)
|
||||
|
||||
assert mock_post.called
|
||||
assert mock_post.call_args == mocker.call(
|
||||
urljoin(STUDIO_URL, "/webhook/dvc"),
|
||||
json={
|
||||
"repo_url": "[email protected]:iterative/dvc.git",
|
||||
"client": "dvc",
|
||||
"refs": ["ref1", "ref2", "ref3"],
|
||||
},
|
||||
headers={"Authorization": "token TOKEN"},
|
||||
timeout=5,
|
||||
)
|
||||
@@ -0,0 +1,44 @@
|
||||
from urllib.parse import urljoin
|
||||
|
||||
import pytest
|
||||
from requests import Response
|
||||
|
||||
from dvc.utils.studio import STUDIO_URL, notify_refs
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"status_code",
|
||||
[
|
||||
200, # success
|
||||
401, # should not fail on client errors
|
||||
500, # should not fail even on server errors
|
||||
],
|
||||
)
|
||||
def test_notify_refs(mocker, status_code):
|
||||
response = Response()
|
||||
response.status_code = status_code
|
||||
|
||||
mock_post = mocker.patch("requests.Session.post", return_value=response)
|
||||
|
||||
notify_refs(
|
||||
"origin",
|
||||
"TOKEN",
|
||||
repo_url_finder=lambda: "[email protected]:iterative/dvc.git",
|
||||
pushed=["p1", "p2"],
|
||||
removed=["r1", "r2"],
|
||||
)
|
||||
|
||||
assert mock_post.called
|
||||
assert mock_post.call_args == mocker.call(
|
||||
urljoin(STUDIO_URL, "/webhook/dvc"),
|
||||
json={
|
||||
"repo_url": "[email protected]:iterative/dvc.git",
|
||||
"client": "dvc",
|
||||
"refs": {
|
||||
"pushed": ["p1", "p2"],
|
||||
"removed": ["r1", "r2"],
|
||||
},
|
||||
},
|
||||
headers={"Authorization": "token TOKEN"},
|
||||
timeout=5,
|
||||
)
|
||||
Reference in New Issue
Block a user