mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 23:10:24 +01:00
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
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
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,
|
|
)
|