Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mock_vws/_flask_server/target_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ def delete_target(database_name: str, target_id: str) -> Response:
rule="/cloud_databases/<string:database_name>/targets/<string:target_id>",
methods=[HTTPMethod.PUT],
)
@beartype
def update_target(database_name: str, target_id: str) -> Response:
"""Update a target."""
(database,) = (
Expand Down
2 changes: 2 additions & 0 deletions src/mock_vws/_flask_server/vwq.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def add_response_delay(response: Response) -> Response:


@CLOUDRECO_FLASK_APP.errorhandler(code_or_exception=ValidatorError)
@beartype
def handle_exceptions(exc: ValidatorError) -> Response:
"""Return the error response associated with the given exception."""
response = Response(
Expand All @@ -127,6 +128,7 @@ def handle_exceptions(exc: ValidatorError) -> Response:


@CLOUDRECO_FLASK_APP.route(rule="/v1/query", methods=[HTTPMethod.POST])
@beartype
def query() -> Response:
"""Perform an image recognition query."""
settings = VWQSettings.model_validate(obj={})
Expand Down
6 changes: 6 additions & 0 deletions src/mock_vws/_flask_server/vws.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def get_all_vumark_databases() -> set[VuMarkDatabase]:


@VWS_FLASK_APP.before_request
@beartype
def set_terminate_wsgi_input() -> None:
"""We set ``wsgi.input_terminated`` to ``True`` when going through
``requests`` in our tests, so that requests have the given ``Content-
Expand Down Expand Up @@ -171,6 +172,7 @@ def add_response_delay(response: Response) -> Response:


@VWS_FLASK_APP.errorhandler(code_or_exception=ValidatorError)
@beartype
def handle_exceptions(exc: ValidatorError) -> Response:
"""Return the error response associated with the given exception."""
response = Response(
Expand Down Expand Up @@ -319,6 +321,7 @@ def get_target(target_id: str) -> Response:
rule="/targets/<string:target_id>",
methods=[HTTPMethod.DELETE],
)
@beartype
def delete_target(target_id: str) -> Response:
"""Delete a target.

Expand Down Expand Up @@ -499,6 +502,7 @@ def database_summary() -> Response:
rule="/summary/<string:target_id>",
methods=[HTTPMethod.GET],
)
@beartype
def target_summary(target_id: str) -> Response:
"""Get a summary report for a target.

Expand Down Expand Up @@ -616,6 +620,7 @@ def get_duplicates(target_id: str) -> Response:


@VWS_FLASK_APP.route(rule="/targets", methods=[HTTPMethod.GET])
@beartype
def target_list() -> Response:
"""Get a list of all targets.

Expand Down Expand Up @@ -658,6 +663,7 @@ def target_list() -> Response:
@VWS_FLASK_APP.route(
rule="/targets/<string:target_id>", methods=[HTTPMethod.PUT]
)
@beartype
def update_target(target_id: str) -> Response:
"""Update a target.

Expand Down
2 changes: 2 additions & 0 deletions src/mock_vws/_mock_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from beartype import beartype


@beartype
@dataclass(frozen=True)
class RequestData:
"""A library-agnostic representation of an HTTP request.
Expand All @@ -25,6 +26,7 @@ class RequestData:
body: bytes


@beartype
@dataclass(frozen=True)
class Route:
"""A representation of a VWS route.
Expand Down
1 change: 1 addition & 0 deletions src/mock_vws/_query_validators/content_type_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

@beartype
def validate_content_type_header(
*,
request_headers: Mapping[str, str],
request_body: bytes,
) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/mock_vws/_query_validators/date_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def validate_date_header_given(*, request_headers: Mapping[str, str]) -> None:
raise DateHeaderNotGivenError


@beartype
def _accepted_date_formats() -> set[str]:
"""Return all known accepted date formats.

Expand Down
1 change: 1 addition & 0 deletions src/mock_vws/_query_validators/image_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def validate_image_format(

@beartype
def validate_image_is_image(
*,
request_headers: Mapping[str, str],
request_body: bytes,
) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

@beartype
def validate_include_target_data(
*,
request_headers: Mapping[str, str],
request_body: bytes,
) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/mock_vws/_query_validators/project_state_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

@beartype
def validate_project_state(
*,
request_path: str,
request_headers: Mapping[str, str],
request_body: bytes,
Expand Down
1 change: 1 addition & 0 deletions src/mock_vws/_requests_mock_server/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
_BRISQUE_TRACKING_RATER = BrisqueTargetTrackingRater()


@beartype
class MissingSchemeError(Exception):
"""Raised when a URL is missing a schema."""

Expand Down
1 change: 1 addition & 0 deletions src/mock_vws/_requests_mock_server/mock_web_query_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _ResponseType:

@beartype
def route(
*,
path_pattern: str,
http_methods: Iterable[str],
) -> Callable[[_RouteMethod[_P]], _RouteMethod[_P]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _ResponseType:

@beartype
def route(
*,
path_pattern: str,
http_methods: Iterable[HTTPMethod],
) -> Callable[[_RouteMethod[_P]], _RouteMethod[_P]]:
Expand Down
4 changes: 4 additions & 0 deletions src/mock_vws/_services_validators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from collections.abc import Iterable, Mapping

from beartype import beartype

from mock_vws._database_matchers import AnyDatabase

from .active_flag_validators import validate_active_flag
Expand Down Expand Up @@ -50,7 +52,9 @@
from .width_validators import validate_width


@beartype
def run_services_validators(
*,
request_path: str,
request_headers: Mapping[str, str],
request_body: bytes,
Expand Down
1 change: 1 addition & 0 deletions src/mock_vws/_services_validators/key_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
_LOGGER = logging.getLogger(name=__name__)


@beartype
@dataclass
class _Route:
"""A representation of a VWS route.
Expand Down