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
6 changes: 3 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest
from beartype import beartype
from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from sybil import Sybil
from sybil.parsers.rest import (
ClearNamespaceParser,
Expand Down Expand Up @@ -53,7 +53,7 @@ def fixture_mock_vws(
client_access_key = uuid.uuid4().hex
client_secret_key = uuid.uuid4().hex

database = VuforiaDatabase(
database = CloudDatabase(
server_access_key=server_access_key,
server_secret_key=server_secret_key,
client_access_key=client_access_key,
Expand All @@ -66,7 +66,7 @@ def fixture_mock_vws(
monkeypatch.setenv(name="VWS_CLIENT_SECRET_KEY", value=client_secret_key)
# We use a low processing time so that tests run quickly.
with MockVWS(processing_time_seconds=0.2) as mock:
mock.add_database(database=database)
mock.add_cloud_database(cloud_database=database)
yield


Expand Down
6 changes: 3 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ To write unit tests for code which uses this library, without using your Vuforia
import pathlib

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

from vws import VWS, CloudRecoService

with MockVWS() as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ optional-dependencies.dev = [
"ty==0.0.17",
"types-requests==2.32.4.20260107",
"vulture==2.14",
"vws-python-mock==2026.2.18.2",
"vws-python-mock==2026.2.21",
"vws-test-fixtures==2023.3.5",
"yamlfix==1.19.1",
"zizmor==1.22.0",
Expand Down
14 changes: 7 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@

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

from vws import VWS, CloudRecoService


@pytest.fixture(name="_mock_database")
def fixture_mock_database() -> Generator[VuforiaDatabase]:
"""Yield a mock ``VuforiaDatabase``."""
def fixture_mock_database() -> Generator[CloudDatabase]:
"""Yield a mock ``CloudDatabase``."""
# We use a low processing time so that tests run quickly.
with MockVWS(processing_time_seconds=0.2) as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
yield database


@pytest.fixture
def vws_client(_mock_database: VuforiaDatabase) -> VWS:
def vws_client(_mock_database: CloudDatabase) -> VWS:
"""A VWS client which connects to a mock database."""
return VWS(
server_access_key=_mock_database.server_access_key,
Expand All @@ -32,7 +32,7 @@ def vws_client(_mock_database: VuforiaDatabase) -> VWS:


@pytest.fixture
def cloud_reco_client(_mock_database: VuforiaDatabase) -> CloudRecoService:
def cloud_reco_client(_mock_database: CloudDatabase) -> CloudRecoService:
"""A ``CloudRecoService`` client which connects to a mock database."""
return CloudRecoService(
client_access_key=_mock_database.client_access_key,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_cloud_reco_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest
from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.states import States

from vws import CloudRecoService
Expand Down Expand Up @@ -85,13 +85,13 @@ def test_authentication_failure(
key
exists but the client secret key is incorrect.
"""
database = VuforiaDatabase()
database = CloudDatabase()
cloud_reco_client = CloudRecoService(
client_access_key=database.client_access_key,
client_secret_key=uuid.uuid4().hex,
)
with MockVWS() as mock:
mock.add_database(database=database)
mock.add_cloud_database(cloud_database=database)

with pytest.raises(
expected_exception=AuthenticationFailureError
Expand All @@ -108,9 +108,9 @@ def test_inactive_project(
An ``InactiveProject`` exception is raised when querying an inactive
database.
"""
database = VuforiaDatabase(state=States.PROJECT_INACTIVE)
database = CloudDatabase(state=States.PROJECT_INACTIVE)
with MockVWS() as mock:
mock.add_database(database=database)
mock.add_cloud_database(cloud_database=database)
cloud_reco_client = CloudRecoService(
client_access_key=database.client_access_key,
client_secret_key=database.client_secret_key,
Expand Down
14 changes: 7 additions & 7 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests
from freezegun import freeze_time
from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

from vws import VWS, CloudRecoService
from vws.include_target_data import CloudRecoIncludeTargetData
Expand Down Expand Up @@ -75,8 +75,8 @@ def test_default_timeout(
)[1],
) as mock,
):
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
cloud_reco_client = CloudRecoService(
client_access_key=database.client_access_key,
client_secret_key=database.client_secret_key,
Expand Down Expand Up @@ -129,8 +129,8 @@ def test_custom_timeout(
)[1],
) as mock,
):
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
cloud_reco_client = CloudRecoService(
client_access_key=database.client_access_key,
client_secret_key=database.client_secret_key,
Expand Down Expand Up @@ -160,8 +160,8 @@ def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None:
"""
base_vwq_url = "http://example.com"
with MockVWS(base_vwq_url=base_vwq_url) as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down
26 changes: 13 additions & 13 deletions tests/test_vws.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import requests
from freezegun import freeze_time
from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase

from vws import VWS, CloudRecoService
from vws.exceptions.custom_exceptions import TargetProcessingTimeoutError
Expand Down Expand Up @@ -122,8 +122,8 @@ def test_default_timeout(
)[1],
) as mock,
):
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down Expand Up @@ -187,8 +187,8 @@ def test_custom_timeout(
)[1],
) as mock,
):
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down Expand Up @@ -228,8 +228,8 @@ def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None:
"""
base_vws_url = "http://example.com"
with MockVWS(base_vws_url=base_vws_url) as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down Expand Up @@ -489,8 +489,8 @@ def test_default_seconds_between_requests(
) -> None:
"""By default, 0.2 seconds are waited between polling requests."""
with MockVWS(processing_time_seconds=0.5) as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down Expand Up @@ -541,8 +541,8 @@ def test_custom_seconds_between_requests(
requests.
"""
with MockVWS(processing_time_seconds=0.5) as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down Expand Up @@ -589,8 +589,8 @@ def test_custom_seconds_between_requests(
def test_custom_timeout(image: io.BytesIO | BinaryIO) -> None:
"""It is possible to set a maximum timeout."""
with MockVWS(processing_time_seconds=0.5) as mock:
database = VuforiaDatabase()
mock.add_database(database=database)
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_vws_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest
from freezegun import freeze_time
from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from mock_vws.database import CloudDatabase
from mock_vws.states import States

from vws import VWS
Expand Down Expand Up @@ -175,9 +175,9 @@ def test_project_inactive(
inactive
database.
"""
database = VuforiaDatabase(state=States.PROJECT_INACTIVE)
database = CloudDatabase(state=States.PROJECT_INACTIVE)
with MockVWS() as mock:
mock.add_database(database=database)
mock.add_cloud_database(cloud_database=database)
vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=database.server_secret_key,
Expand Down Expand Up @@ -286,15 +286,15 @@ def test_authentication_failure(
exists but the server secret key is incorrect, or when a client key is
incorrect.
"""
database = VuforiaDatabase()
database = CloudDatabase()

vws_client = VWS(
server_access_key=database.server_access_key,
server_secret_key=uuid.uuid4().hex,
)

with MockVWS() as mock:
mock.add_database(database=database)
mock.add_cloud_database(cloud_database=database)

with pytest.raises(
expected_exception=AuthenticationFailureError
Expand Down