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
23 changes: 2 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@ This is tested on Python 3.12+.
Usage
-----

.. invisible-code-block: python

from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase

mock = MockVWS(real_http=False)
database = VuforiaDatabase(
server_access_key='my_access_key',
server_secret_key='my_secret_key',
client_access_key='my_access_key',
client_secret_key='my_secret_key',
)
mock.add_database(database=database)
mock.__enter__()

.. code-block:: python

from urllib.parse import urljoin
Expand All @@ -44,8 +29,8 @@ Usage
method = 'GET'
date = rfc_1123_date()
authorization_header = authorization_header(
access_key='my_access_key',
secret_key='my_secret_key',
access_key='[server-access-key]',
secret_key='[server-secret-key]',
method=method,
content=content,
content_type='',
Expand All @@ -64,10 +49,6 @@ Usage

assert response.status_code == 200, response.text

.. invisible-code-block: python

mock.__exit__()

Full Documentation
------------------

Expand Down
26 changes: 25 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
"""Setup for Sybil."""
"""Setup for test suite."""

from collections.abc import Generator
from doctest import ELLIPSIS

import pytest
from beartype import beartype
from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase
from sybil import Sybil
from sybil.parsers.rest import (
CaptureParser,
DocTestParser,
PythonCodeBlockParser,
)


@pytest.fixture
def mock_vws() -> Generator[None, None, None]:
"""
Yield a mock VWS.

The keys used here match the keys in the documentation.
"""
database = VuforiaDatabase(
server_access_key="[server-access-key]",
server_secret_key="[server-secret-key]",
client_access_key="[client-access-key]",
client_secret_key="[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)
yield


sybil_obj = Sybil(
parsers=[
DocTestParser(optionflags=ELLIPSIS),
PythonCodeBlockParser(),
CaptureParser(),
],
patterns=["*.rst", "*.py"],
fixtures=["mock_vws"],
)

pytest_collect_file = sybil_obj.pytest()
Expand Down
23 changes: 2 additions & 21 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@ This is tested on Python 3.12+.
Example usage
-------------

.. invisible-code-block: python

from mock_vws import MockVWS
from mock_vws.database import VuforiaDatabase

mock = MockVWS(real_http=False)
database = VuforiaDatabase(
server_access_key='my_access_key',
server_secret_key='my_secret_key',
client_access_key='my_access_key',
client_secret_key='my_secret_key',
)
mock.add_database(database=database)
mock.__enter__()

.. code-block:: python

from urllib.parse import urljoin
Expand All @@ -40,8 +25,8 @@ Example usage
method = 'GET'
date = rfc_1123_date()
authorization_header = authorization_header(
access_key='my_access_key',
secret_key='my_secret_key',
access_key='[server-access-key]',
secret_key='[server-secret-key]',
method=method,
content=content,
content_type='',
Expand All @@ -60,10 +45,6 @@ Example usage

assert response.status_code == 200, response.text

.. invisible-code-block: python

mock.__exit__()

Reference
---------

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ lint.ignore = [
"S101",
]

lint.per-file-ignores."conftest.py" = [
# Allow hardcoded secrets in tests.
"S106",
]

# Do not automatically remove commented out code.
# We comment out code during development, and with VSCode auto-save, this code
# is sometimes annoyingly removed.
Expand Down