-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoint for adding job to analysis
- Loading branch information
Showing
8 changed files
with
95 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from flask.testing import FlaskClient | ||
from http import HTTPStatus | ||
from trailblazer.dto.create_job_request import CreateJobRequest | ||
|
||
from trailblazer.store.models import Analysis | ||
|
||
TYPE_JSON = "application/json" | ||
|
||
|
||
def test_add_job_to_analysis(client: FlaskClient, analysis: Analysis): | ||
# GIVEN an analysis | ||
|
||
# GIVEN a valid request to add a job to the analysis | ||
create_job_request = CreateJobRequest(name="job", slurm_id="12345") | ||
data: str = create_job_request.model_dump_json() | ||
|
||
# WHEN sending the request | ||
response = client.post( | ||
f"/api/v1/analyses/{analysis.id}/jobs", data=data, content_type=TYPE_JSON | ||
) | ||
|
||
# THEN it gives a success response | ||
assert response.status_code == HTTPStatus.CREATED | ||
|
||
# THEN it should return the job | ||
assert response.json["name"] == create_job_request.name |
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,9 @@ | ||
from pydantic import BaseModel | ||
|
||
from trailblazer.constants import JobType | ||
|
||
|
||
class CreateJobRequest(BaseModel): | ||
name: str | ||
job_type: JobType | None = JobType.ANALYSIS | ||
slurm_id: int |
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,7 @@ | ||
from pydantic import BaseModel | ||
|
||
from trailblazer.constants import JobType | ||
|
||
|
||
class JobResponse(BaseModel): | ||
name: str |
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