コード例 #1
0
ファイル: test_oas.py プロジェクト: sanderegg/osparc-simcore
def test_openapi_specs():
    openapi_path = resources.get_path(resources.RESOURCE_OPEN_API)
    with resources.stream(resources.RESOURCE_OPEN_API) as fh:
        specs = yaml.safe_load(fh)
        try:
            validate_spec(specs, spec_url=openapi_path.as_uri())
        except OpenAPIValidationError as err:
            pytest.fail(err.message)
コード例 #2
0
ファイル: test_oas.py プロジェクト: sanderegg/osparc-simcore
def test_server_specs():
    with resources.stream(resources.RESOURCE_OPEN_API) as fh:
        specs = yaml.safe_load(fh)

        # client-sdk current limitation
        #  - hooks to first server listed in oas
        default_server = specs["servers"][0]
        assert (default_server["url"] == "http://{host}:{port}/{version}"
                ), "Invalid convention"
コード例 #3
0
async def test_services_conformity(configure_schemas_location, push_services):
    from simcore_service_director import resources

    services = await push_services(1, 1)
    with resources.stream(resources.RESOURCE_NODE_SCHEMA) as file_pt:
        service_schema = json.load(file_pt)
    for service in services:
        # validate service
        json_schema_validator.validate_instance_object(
            service["service_description"], service_schema)
コード例 #4
0
def test_openapi_specs(version):
    name = "{root}/{version}/openapi.yaml".format(
        root=resources.RESOURCE_OPENAPI_ROOT, version=version)
    openapi_path = resources.get_path(name)
    with resources.stream(name) as fh:
        specs = yaml.safe_load(fh)
        try:
            validate_spec(specs, spec_url=openapi_path.as_uri())
        except OpenAPIValidationError as err:
            pytest.fail(err.message)
コード例 #5
0
ファイル: handlers.py プロジェクト: oetiker/osparc-simcore
async def root_get(request):  # pylint:disable=unused-argument
    log.debug("Client does root_get request %s", request)
    distb = pkg_resources.get_distribution('simcore-service-director')
    with resources.stream(resources.RESOURCE_OPEN_API) as file_ptr:
        api_dict = yaml.safe_load(file_ptr)

    service_health = dict(name=distb.project_name,
                          status="SERVICE_RUNNING",
                          api_version=api_dict["info"]["version"],
                          version=distb.version)
    return web.json_response(dict(data=service_health))
コード例 #6
0
def test_server_specs(version):
    name = "{root}/{version}/openapi.yaml".format(
        root=resources.RESOURCE_OPENAPI_ROOT, version=version)
    with resources.stream(name) as fh:
        specs = yaml.safe_load(fh)

        # client-sdk current limitation
        #  - hooks to first server listed in oas
        default_server = specs['servers'][0]
        assert default_server[
            'url'] == 'http://{host}:{port}/{version}', "Invalid convention"
コード例 #7
0
def test_v0_services_nonconformity(configure_schemas_location,
                                   push_v0_schema_services):
    from simcore_service_director import resources

    services = push_v0_schema_services(1, 1)
    with resources.stream(resources.RESOURCE_NODE_SCHEMA) as file_pt:
        service_schema = json.load(file_pt)

    for service in services:
        # validate service
        with pytest.raises(Exception,
                           message="expecting json schema validation error"):
            json_schema_validator.validate_instance_object(
                service["service_description"], service_schema)
コード例 #8
0
def is_service_valid(service: Dict):
    with resources.stream(resources.RESOURCE_NODE_SCHEMA) as fp:
        schema = json.load(fp)
        try:
            validate(service, schema)
            log.debug("service [%s] validated", service["key"])
            return True
        except ValidationError as exc:
            log.debug("Node validation error: %s", exc.message)
            return False
        except SchemaError:
            log.exception("Schema error:")
            raise exceptions.DirectorException(
                "Incorrect json schema used from %s" %
                (resources.get_path(resources.RESOURCE_NODE_SCHEMA)))