mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-23 18:59:56 +00:00
feat: add ability to run build process to remote instances (#118)
This commit is contained in:
1
tests/ahriman/web/schemas/test_build_options_schema.py
Normal file
1
tests/ahriman/web/schemas/test_build_options_schema.py
Normal file
@ -0,0 +1 @@
|
||||
# schema testing goes in view class tests
|
@ -193,6 +193,9 @@ async def test_username(base: BaseView, mocker: MockerFixture) -> None:
|
||||
policy = AsyncMock()
|
||||
policy.identify.return_value = "identity"
|
||||
mocker.patch("aiohttp.web.Application.get", return_value=policy)
|
||||
json = AsyncMock()
|
||||
json.return_value = {}
|
||||
base._request = pytest.helpers.request(base.request.app, "", "", json=json)
|
||||
|
||||
assert await base.username() == "identity"
|
||||
policy.identify.assert_called_once_with(base.request)
|
||||
@ -202,4 +205,26 @@ async def test_username_no_auth(base: BaseView) -> None:
|
||||
"""
|
||||
must return None in case if auth is disabled
|
||||
"""
|
||||
json = AsyncMock()
|
||||
json.return_value = {}
|
||||
base._request = pytest.helpers.request(base.request.app, "", "", json=json)
|
||||
|
||||
assert await base.username() is None
|
||||
|
||||
|
||||
async def test_username_request(base: BaseView) -> None:
|
||||
"""
|
||||
must read packager from request
|
||||
"""
|
||||
json = AsyncMock()
|
||||
json.return_value = {"packager": "identity"}
|
||||
base._request = pytest.helpers.request(base.request.app, "", "", json=json)
|
||||
|
||||
assert await base.username() == "identity"
|
||||
|
||||
|
||||
async def test_username_request_exception(base: BaseView) -> None:
|
||||
"""
|
||||
must not fail in case if cannot read request
|
||||
"""
|
||||
assert await base.username() is None
|
||||
|
@ -41,7 +41,8 @@ async def test_post(client: TestClient, repository_id: RepositoryId, mocker: Moc
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.post("/api/v1/service/add", json=payload)
|
||||
assert response.ok
|
||||
add_mock.assert_called_once_with(repository_id, ["ahriman"], "username", patches=[], now=True)
|
||||
add_mock.assert_called_once_with(repository_id, ["ahriman"], "username",
|
||||
patches=[], now=True, increment=True, refresh=False)
|
||||
|
||||
json = await response.json()
|
||||
assert json["process_id"] == "abc"
|
||||
@ -74,7 +75,8 @@ async def test_post_patches(client: TestClient, repository_id: RepositoryId, moc
|
||||
response = await client.post("/api/v1/service/add", json=payload)
|
||||
assert response.ok
|
||||
add_mock.assert_called_once_with(repository_id, ["ahriman"], "username",
|
||||
patches=[PkgbuildPatch("k", "v"), PkgbuildPatch("k2", "")], now=True)
|
||||
patches=[PkgbuildPatch("k", "v"), PkgbuildPatch("k2", "")],
|
||||
now=True, increment=True, refresh=False)
|
||||
|
||||
|
||||
async def test_post_empty(client: TestClient, mocker: MockerFixture) -> None:
|
||||
|
@ -40,7 +40,7 @@ async def test_post(client: TestClient, repository_id: RepositoryId, mocker: Moc
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.post("/api/v1/service/rebuild", json=payload)
|
||||
assert response.ok
|
||||
rebuild_mock.assert_called_once_with(repository_id, "python", "username")
|
||||
rebuild_mock.assert_called_once_with(repository_id, "python", "username", increment=True)
|
||||
|
||||
json = await response.json()
|
||||
assert json["process_id"] == "abc"
|
||||
|
@ -41,7 +41,8 @@ async def test_post(client: TestClient, repository_id: RepositoryId, mocker: Moc
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.post("/api/v1/service/request", json=payload)
|
||||
assert response.ok
|
||||
add_mock.assert_called_once_with(repository_id, ["ahriman"], "username", patches=[], now=False)
|
||||
add_mock.assert_called_once_with(repository_id, ["ahriman"], "username",
|
||||
patches=[], now=False, increment=False, refresh=False)
|
||||
|
||||
json = await response.json()
|
||||
assert json["process_id"] == "abc"
|
||||
@ -74,7 +75,8 @@ async def test_post_patches(client: TestClient, repository_id: RepositoryId, moc
|
||||
response = await client.post("/api/v1/service/request", json=payload)
|
||||
assert response.ok
|
||||
add_mock.assert_called_once_with(repository_id, ["ahriman"], "username",
|
||||
patches=[PkgbuildPatch("k", "v"), PkgbuildPatch("k2", "")], now=False)
|
||||
patches=[PkgbuildPatch("k", "v"), PkgbuildPatch("k2", "")],
|
||||
now=False, increment=False, refresh=False)
|
||||
|
||||
|
||||
async def test_post_exception(client: TestClient, mocker: MockerFixture) -> None:
|
||||
|
@ -40,6 +40,8 @@ async def test_post(client: TestClient, repository_id: RepositoryId, mocker: Moc
|
||||
"aur": True,
|
||||
"local": True,
|
||||
"manual": True,
|
||||
"increment": True,
|
||||
"refresh": False,
|
||||
}
|
||||
|
||||
for payload in (
|
||||
|
Reference in New Issue
Block a user