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
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ This requires Python |minimum-python-version|\+.
import requests

from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

with MockVWS() as mock:
database = VuforiaDatabase()
database = CloudDatabase()
mock.add_database(database=database)
# This will use the Vuforia mock.
requests.get(url="https://vws.vuforia.com/summary", timeout=30)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/basic-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo
import requests

from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

with MockVWS() as mock:
database = VuforiaDatabase()
database = CloudDatabase()
mock.add_database(database=database)
# This will use the Vuforia mock.
requests.get(url="https://vws.vuforia.com/summary", timeout=30)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/mock-api-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ API Reference
:members:
:undoc-members:

.. Many parts of the VuforiaDatabase API are used for the Flask target
.. Many parts of the CloudDatabase API are used for the Flask target
.. database app, but Python users are not expected to use them.
.. Therefore, they are not documented.

.. autoclass:: mock_vws.database.VuforiaDatabase
.. autoclass:: mock_vws.database.CloudDatabase
:members:
:undoc-members:
:exclude-members: to_dict, get_target, from_dict, not_deleted_targets, active_targets, inactive_targets, failed_targets, processing_targets
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ ignore_names = [
# pydantic-settings
"model_config",
# Used in TYPE_CHECKING for type hints
"DatabaseDict",
"CloudDatabaseDict",
"VuMarkDatabaseDict",
]
# Duplicate some of .gitignore
Expand Down
10 changes: 5 additions & 5 deletions src/mock_vws/_database_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from beartype import beartype
from vws_auth_tools import authorization_header

from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase


@beartype
Expand All @@ -15,8 +15,8 @@ def get_database_matching_client_keys(
request_body: bytes | None,
request_method: str,
request_path: str,
databases: Iterable[VuforiaDatabase],
) -> VuforiaDatabase:
databases: Iterable[CloudDatabase],
) -> CloudDatabase:
"""Return the first of the given databases which is being accessed by
the
given client request.
Expand Down Expand Up @@ -64,8 +64,8 @@ def get_database_matching_server_keys(
request_body: bytes | None,
request_method: str,
request_path: str,
databases: Iterable[VuforiaDatabase],
) -> VuforiaDatabase:
databases: Iterable[CloudDatabase],
) -> CloudDatabase:
"""Return the first of the given databases which is being accessed by
the
given server request.
Expand Down
6 changes: 3 additions & 3 deletions src/mock_vws/_flask_server/target_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from flask import Flask, Response, request
from pydantic_settings import BaseSettings

from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.states import States
from mock_vws.target import ImageTarget
from mock_vws.target_manager import TargetManager
Expand Down Expand Up @@ -133,7 +133,7 @@ def create_database() -> Response:

:status 201: The database has been successfully created.
"""
random_database = VuforiaDatabase()
random_database = CloudDatabase()
request_json = json.loads(s=request.data)
server_access_key = request_json.get(
"server_access_key",
Expand Down Expand Up @@ -162,7 +162,7 @@ def create_database() -> Response:

state = States[state_name]

database = VuforiaDatabase(
database = CloudDatabase(
server_access_key=server_access_key,
server_secret_key=server_secret_key,
client_access_key=client_access_key,
Expand Down
6 changes: 3 additions & 3 deletions src/mock_vws/_flask_server/vwq.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from mock_vws._query_validators.exceptions import (
ValidatorError,
)
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.image_matchers import (
ExactMatcher,
ImageMatcher,
Expand Down Expand Up @@ -63,15 +63,15 @@ class VWQSettings(BaseSettings):


@beartype
def get_all_databases() -> set[VuforiaDatabase]:
def get_all_databases() -> set[CloudDatabase]:
"""Get all database objects from the target manager back-end."""
settings = VWQSettings.model_validate(obj={})
response = requests.get(
url=f"{settings.target_manager_base_url}/databases",
timeout=30,
)
return {
VuforiaDatabase.from_dict(database_dict=database_dict)
CloudDatabase.from_dict(database_dict=database_dict)
for database_dict in response.json()
}

Expand Down
6 changes: 3 additions & 3 deletions src/mock_vws/_flask_server/vws.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
TargetStatusProcessingError,
ValidatorError,
)
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.image_matchers import (
ExactMatcher,
ImageMatcher,
Expand Down Expand Up @@ -86,7 +86,7 @@ class VWSSettings(BaseSettings):


@beartype
def get_all_databases() -> set[VuforiaDatabase]:
def get_all_databases() -> set[CloudDatabase]:
"""Get all database objects from the task manager back-end."""
settings = VWSSettings.model_validate(obj={})
timeout_seconds = 30
Expand All @@ -95,7 +95,7 @@ def get_all_databases() -> set[VuforiaDatabase]:
timeout=timeout_seconds,
)
return {
VuforiaDatabase.from_dict(database_dict=database_dict)
CloudDatabase.from_dict(database_dict=database_dict)
for database_dict in response.json()
}

Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/_query_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from mock_vws._constants import ResultCodes, TargetStatuses
from mock_vws._database_matchers import get_database_matching_client_keys
from mock_vws._mock_common import json_dump
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.image_matchers import ImageMatcher


Expand All @@ -25,7 +25,7 @@ def get_query_match_response_text(
request_body: bytes,
request_method: str,
request_path: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
query_match_checker: ImageMatcher,
) -> str:
"""
Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/_query_validators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from beartype import beartype

from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

from .accept_header_validators import validate_accept_header
from .auth_validators import (
Expand Down Expand Up @@ -45,7 +45,7 @@ def run_query_validators(
request_headers: Mapping[str, str],
request_body: bytes,
request_method: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Run all validators.

Expand Down
6 changes: 3 additions & 3 deletions src/mock_vws/_query_validators/auth_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
AuthHeaderMissingError,
MalformedAuthHeaderError,
)
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

_LOGGER = logging.getLogger(name=__name__)

Expand Down Expand Up @@ -63,7 +63,7 @@ def validate_auth_header_number_of_parts(
def validate_client_key_exists(
*,
request_headers: Mapping[str, str],
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate the authorization header includes a client key for a
database.
Expand Down Expand Up @@ -113,7 +113,7 @@ def validate_authorization(
request_headers: Mapping[str, str],
request_body: bytes,
request_method: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate the authorization header given to the query endpoint.

Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/_query_validators/project_state_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from mock_vws._database_matchers import get_database_matching_client_keys
from mock_vws._query_validators.exceptions import InactiveProjectError
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.states import States

_LOGGER = logging.getLogger(name=__name__)
Expand All @@ -19,7 +19,7 @@ def validate_project_state(
request_headers: Mapping[str, str],
request_body: bytes,
request_method: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate the state of the project.

Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/_requests_mock_server/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from requests import PreparedRequest
from responses import RequestsMock

from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.image_matchers import (
ImageMatcher,
StructuralSimilarityMatcher,
Expand Down Expand Up @@ -126,7 +126,7 @@ def __init__(
query_match_checker=query_match_checker,
)

def add_database(self, database: VuforiaDatabase) -> None:
def add_database(self, database: CloudDatabase) -> None:
"""Add a cloud database.

Args:
Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/_services_validators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections.abc import Iterable, Mapping

from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

from .active_flag_validators import validate_active_flag
from .auth_validators import (
Expand Down Expand Up @@ -55,7 +55,7 @@ def run_services_validators(
request_headers: Mapping[str, str],
request_body: bytes,
request_method: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Run all validators.

Expand Down
6 changes: 3 additions & 3 deletions src/mock_vws/_services_validators/auth_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
AuthenticationFailureError,
FailError,
)
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

_LOGGER = logging.getLogger(name=__name__)

Expand All @@ -36,7 +36,7 @@ def validate_auth_header_exists(*, request_headers: Mapping[str, str]) -> None:
def validate_access_key_exists(
*,
request_headers: Mapping[str, str],
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate the authorization header includes an access key for a
database.
Expand Down Expand Up @@ -92,7 +92,7 @@ def validate_authorization(
request_headers: Mapping[str, str],
request_body: bytes,
request_method: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate the authorization header given to a VWS endpoint.

Expand Down
6 changes: 3 additions & 3 deletions src/mock_vws/_services_validators/name_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
FailError,
TargetNameExistError,
)
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

_LOGGER = logging.getLogger(name=__name__)

Expand Down Expand Up @@ -116,7 +116,7 @@ def validate_name_length(*, request_body: bytes) -> None:
@beartype
def validate_name_does_not_exist_new_target(
*,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
request_body: bytes,
request_headers: Mapping[str, str],
request_method: str,
Expand Down Expand Up @@ -176,7 +176,7 @@ def validate_name_does_not_exist_existing_target(
request_body: bytes,
request_method: str,
request_path: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate that the name does not exist for any existing target apart
from
Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/_services_validators/project_state_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from mock_vws._database_matchers import get_database_matching_server_keys
from mock_vws._services_validators.exceptions import ProjectInactiveError
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.states import States

_LOGGER = logging.getLogger(name=__name__)
Expand All @@ -21,7 +21,7 @@ def validate_project_state(
request_headers: Mapping[str, str],
request_body: bytes,
request_method: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate the state of the project.

Expand Down
4 changes: 2 additions & 2 deletions src/mock_vws/_services_validators/target_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from mock_vws._database_matchers import get_database_matching_server_keys
from mock_vws._services_validators.exceptions import UnknownTargetError
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

_LOGGER = logging.getLogger(name=__name__)
_TARGETS_WITH_INSTANCE_PATH_LENGTH = 4
Expand All @@ -20,7 +20,7 @@ def validate_target_id_exists(
request_headers: Mapping[str, str],
request_body: bytes,
request_method: str,
databases: Iterable[VuforiaDatabase],
databases: Iterable[CloudDatabase],
) -> None:
"""Validate that if a target ID is given, it exists in the database
matching the request.
Expand Down
Loading