-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from wtsi-hgi/feature/upload-endpoint
Add upload endpoint for builder to pass artifacts to be uploaded to repo.
- Loading branch information
Showing
9 changed files
with
191 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Copyright (c) 2023 Genome Research Ltd. | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
from softpack_core.app import app | ||
from softpack_core.schemas.environment import Environment | ||
from softpack_core.service import ServiceAPI | ||
from tests.integration.utils import file_in_repo | ||
|
||
pytestmark = pytest.mark.repo | ||
|
||
|
||
def test_builder_upload(testable_env_input): | ||
ServiceAPI.register() | ||
client = TestClient(app.router) | ||
|
||
env_parent = "groups/hgi" | ||
env_name = "unknown-env" | ||
env_path = env_parent + "/" + env_name | ||
|
||
softpackYaml = "softpack.yaml" | ||
softpackYamlContents = b"softpack yaml file" | ||
|
||
spackLock = "spack.lock" | ||
spackLockContents = b"spack lock file" | ||
|
||
assert Environment.check_env_exists(Path(env_path)) is not None | ||
resp = client.post( | ||
url="/upload?" + env_path, | ||
files=[ | ||
("file", (softpackYaml, softpackYamlContents)), | ||
("file", (spackLock, spackLockContents)), | ||
], | ||
) | ||
assert resp.status_code == 200 | ||
assert resp.json().get("message") == "Successfully written artifact(s)" | ||
assert Environment.check_env_exists(Path(env_path)) is None | ||
assert file_in_repo( | ||
Environment.artifacts, | ||
Path(Environment.artifacts.environments_root, env_path, softpackYaml), | ||
) | ||
assert file_in_repo( | ||
Environment.artifacts, | ||
Path(Environment.artifacts.environments_root, env_path, spackLock), | ||
) | ||
|
||
tree = Environment.artifacts.get(env_parent, env_name) | ||
assert tree is not None | ||
|
||
assert tree[softpackYaml].data == softpackYamlContents | ||
assert tree[spackLock].data == spackLockContents |
Oops, something went wrong.