-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only missing check that objects coincide
- Loading branch information
1 parent
728c497
commit 7a6ca5f
Showing
1 changed file
with
38 additions
and
5 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 |
---|---|---|
@@ -1,13 +1,46 @@ | ||
import pytest | ||
from pytest_mock import MockerFixture | ||
from osparc import JobMetadata | ||
from osparc import JobMetadata, MetadataValue, ApiClient, SolversApi | ||
from faker import Faker | ||
from urllib3 import HTTPResponse | ||
|
||
|
||
@pytest.fixture | ||
def job_metadata(faker: Faker): | ||
JobMetadata(job_id=faker.uuid4(), metadata={"int": 2}) | ||
def job_metadata(faker: Faker) -> JobMetadata: | ||
_job_id = faker.uuid4() | ||
return JobMetadata( | ||
job_id=f"{_job_id}", | ||
metadata={ | ||
"job_id": MetadataValue(_job_id), | ||
"job_name": MetadataValue(faker.text()), | ||
"node_id": MetadataValue(faker.uuid4()), | ||
}, | ||
url=faker.url(), | ||
) | ||
|
||
|
||
def test_job_metadata_serialization(mocker: MockerFixture): | ||
pass | ||
def test_job_metadata_serialization( | ||
mocker: MockerFixture, | ||
job_metadata: JobMetadata, | ||
api_client: ApiClient, | ||
faker: Faker, | ||
): | ||
def _get_job_sideeffect( | ||
method: str, | ||
url: str, | ||
body=None, | ||
fields=None, | ||
headers=None, | ||
json=None, | ||
**urlopen_kw, | ||
) -> HTTPResponse: | ||
response = HTTPResponse(status=200, body=job_metadata.to_json().encode()) | ||
return response | ||
|
||
mocker.patch("urllib3.PoolManager.request", side_effect=_get_job_sideeffect) | ||
|
||
_solvers_api = SolversApi(api_client=api_client) | ||
metadata = _solvers_api.get_job_custom_metadata( | ||
solver_key="mysolver", version="1.2.3", job_id=f"{faker.uuid4()}" | ||
) | ||
print(metadata) |