Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed May 22, 2023
1 parent 83a9620 commit c5c135b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
import logging
import urllib.parse
from typing import Any, Iterator

import orjson
Expand All @@ -17,7 +18,7 @@
)
from models_library.users import UserID
from pint import UnitRegistry
from pydantic import BaseModel, Extra, Field
from pydantic import BaseModel, Extra, Field, validator
from servicelib.aiohttp.requests_validation import (
handle_validation_as_http_error,
parse_request_path_parameters_as,
Expand Down Expand Up @@ -81,6 +82,14 @@ class Config:
allow_population_by_field_name = True
extra = Extra.forbid

@validator("service_key", pre=True)
@classmethod
def ensure_unquoted(cls, v):
# NOTE: this is needed as in pytest mode, the aiohttp server does not seem to unquote automatically
if v is not None:
return urllib.parse.unquote(v)
return v


@routes.get(f"{VTAG}/catalog/services")
@login_required
Expand Down Expand Up @@ -284,7 +293,6 @@ async def get_service_resources_handler(request: Request):
"""
ctx = _RequestContext.create(request)
path_params = parse_request_path_parameters_as(_ServicePathParams, request)

service_resources: ServiceResourcesDict = await client.get_service_resources(
request.app,
user_id=ctx.user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# pylint:disable=redefined-outer-name

import re
import urllib.parse

import pytest
from aiohttp import web
Expand Down Expand Up @@ -118,7 +119,7 @@ async def test_get_service_resources(
assert client.app
assert client.app.router
url = client.app.router["get_service_resources_handler"].url_for(
service_key="simcore%2Fservices%2Fdynamic%2Fsomeservice",
service_key=urllib.parse.quote("simcore/services/dynamic/someservice", safe=""),
service_version="3.4.5",
)
response = await client.get(f"{url}")
Expand Down

0 comments on commit c5c135b

Please sign in to comment.