Skip to content

Commit bff7e63

Browse files
committed
Added probation approve/reject methods from the R client.
1 parent b965b83 commit bff7e63

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

src/pygobbler/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@
3737
from .version_path import version_path
3838
from .refresh_latest import refresh_latest
3939
from .refresh_usage import refresh_usage
40+
from .approve_probation import approve_probation
41+
from .reject_probation import reject_probation

src/pygobbler/approve_probation.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from . import _utils as ut
2+
3+
4+
def approve_probation(project: str, asset: str, version: str, staging: str, url: str):
5+
"""
6+
Approve a probational upload of a version of a project's asset.
7+
8+
Args:
9+
project:
10+
The name of the project.
11+
12+
asset:
13+
The name of the asset of the ``project``.
14+
15+
version:
16+
The name of the version of the ``asset`` to approve.
17+
18+
staging:
19+
Path to the staging directory.
20+
21+
url:
22+
URL to the Gobbler REST API.
23+
"""
24+
ut.dump_request(staging, url, "approve_probation", { "project": project, "asset": asset, "version": version })

src/pygobbler/reject_probation.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from . import _utils as ut
2+
3+
4+
def reject_probation(project: str, asset: str, version: str, staging: str, url: str):
5+
"""
6+
Reject a probational upload of a version of a project's asset.
7+
8+
Args:
9+
project:
10+
The name of the project.
11+
12+
asset:
13+
The name of the asset of the ``project``.
14+
15+
version:
16+
The name of the version of the ``asset`` to reject.
17+
18+
staging:
19+
Path to the staging directory.
20+
21+
url:
22+
URL to the Gobbler REST API.
23+
"""
24+
ut.dump_request(staging, url, "reject_probation", { "project": project, "asset": asset, "version": version })

tests/test_probation.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pygobbler as pyg
2+
import pytest
3+
import os
4+
5+
6+
@pytest.fixture(scope="module")
7+
def setup():
8+
_, staging, registry, url = pyg.start_gobbler()
9+
pyg.remove_project("test", staging=staging, url=url)
10+
pyg.create_project("test", staging=staging, url=url)
11+
12+
src = pyg.allocate_upload_directory(staging)
13+
with open(os.path.join(src, "foo"), "w") as handle:
14+
handle.write("BAR")
15+
pyg.upload_directory("test", "probation", "good", src, staging=staging, url=url, probation=True)
16+
pyg.upload_directory("test", "probation", "bad", src, staging=staging, url=url, probation=True)
17+
18+
19+
def test_approve_probation(setup):
20+
_, staging, registry, url = pyg.start_gobbler()
21+
assert pyg.fetch_summary("test", "probation", "good", registry=registry, url=url)["on_probation"]
22+
assert pyg.fetch_latest("test", "probation", registry=registry, url=url) is None
23+
24+
pyg.approve_probation("test", "probation", "good", staging=staging, url=url)
25+
assert "on_probation" not in pyg.fetch_summary("test", "probation", "good", registry=registry, url=url)
26+
assert pyg.fetch_latest("test", "probation", registry=registry, url=url) == "good"
27+
28+
29+
def test_reject_probation(setup):
30+
_, staging, registry, url = pyg.start_gobbler()
31+
assert pyg.fetch_summary("test", "probation", "bad", registry=registry, url=url)["on_probation"]
32+
33+
pyg.reject_probation("test", "probation", "bad", staging=staging, url=url)
34+
assert "bad" not in pyg.list_versions("test", "probation", registry=registry, url=url)

0 commit comments

Comments
 (0)