|
| 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