File tree Expand file tree Collapse file tree 3 files changed +67
-1
lines changed
src/simcore_service_api_server/models/schemas Expand file tree Collapse file tree 3 files changed +67
-1
lines changed Original file line number Diff line number Diff line change 3434)
3535
3636JobID : TypeAlias = UUID
37+ assert JobID == ProjectID
3738
3839# ArgumentTypes are types used in the job inputs (see ResultsTypes)
3940ArgumentTypes : TypeAlias = (
Original file line number Diff line number Diff line change 88import pytest
99import simcore_service_api_server
1010from dotenv import dotenv_values
11+ from models_library .projects import ProjectID
12+ from pydantic import parse_obj_as
1113from pytest_simcore .helpers .monkeypatch_envs import EnvVarsDict
14+ from simcore_service_api_server .models .schemas .jobs import JobID
1215
1316CURRENT_DIR = Path (sys .argv [0 ] if __name__ == "__main__" else __file__ ).resolve ().parent
1417
@@ -96,3 +99,11 @@ def tests_utils_dir(project_tests_dir: Path) -> Path:
9699 utils_dir = (project_tests_dir / "utils" ).resolve ()
97100 assert utils_dir .exists ()
98101 return utils_dir
102+
103+
104+ ## BASIC IDENTIFIERS ---
105+
106+
107+ @pytest .fixture
108+ def job_id (project_id : ProjectID ) -> JobID :
109+ return parse_obj_as (JobID , project_id )
Original file line number Diff line number Diff line change 33# pylint: disable=unused-variable
44
55import random
6+ import textwrap
67import urllib .parse
78from copy import deepcopy
89from uuid import uuid4
910
1011import pytest
12+ from faker import Faker
1113from fastapi import FastAPI
14+ from models_library .api_schemas_webserver .projects_metadata import ProjectMetadataGet
15+ from models_library .generics import Envelope
1216from simcore_service_api_server ._meta import API_VTAG
13- from simcore_service_api_server .models .schemas .jobs import Job , JobInputs
17+ from simcore_service_api_server .models .schemas .jobs import (
18+ Job ,
19+ JobID ,
20+ JobInputs ,
21+ JobMetadata ,
22+ )
1423from simcore_service_api_server .models .schemas .solvers import Solver
1524
1625
@@ -70,3 +79,48 @@ def test_job_resouce_names_has_associated_url(app: FastAPI):
7079 )
7180
7281 assert url_path == f"/{ API_VTAG } /{ urllib .parse .unquote_plus (job_name )} "
82+
83+
84+ @pytest .mark .acceptance_test (
85+ "Fixing https://github.com/ITISFoundation/osparc-simcore/issues/6556"
86+ )
87+ def test_parsing_job_custom_metadata (job_id : JobID , faker : Faker ):
88+ job_name = faker .name ()
89+
90+ got = Envelope [ProjectMetadataGet ].parse_raw (
91+ textwrap .dedent (
92+ f"""
93+ {{
94+ "data": {{
95+ "projectUuid": "{ job_id } ",
96+ "custom": {{
97+ "number": 3.14,
98+ "string": "foo",
99+ "boolean": true,
100+ "integer": 42,
101+ "job_id": "{ job_id } ",
102+ "job_name": "{ job_name } "
103+ }}
104+ }}
105+ }}
106+ """
107+ )
108+ )
109+
110+ assert got .data
111+ assert got .data .custom == {
112+ "number" : 3.14 ,
113+ "string" : "foo" ,
114+ "boolean" : True ,
115+ "integer" : 42 ,
116+ "job_id" : f"{ job_id } " ,
117+ "job_name" : job_name ,
118+ }
119+
120+ j = JobMetadata (
121+ job_id = job_id ,
122+ metadata = got .data .custom or {},
123+ url = faker .url (),
124+ )
125+
126+ assert j .metadata == got .data .custom
You can’t perform that action at this time.
0 commit comments