Metadata-Version: 2.1
Name: whitesmith
Version: 5.0.0
Summary: Testing toolbox for blacksmith
Author-Email: Guillaume Gauvrit <guillaume@gauvr.it>
License: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Testing :: Mocking
Project-URL: Homepage, https://github.com/mardiros/whitesmith
Project-URL: Documentation, https://github.com/mardiros/whitesmith/blob/main/README.rst
Project-URL: Repository, https://github.com/mardiros/whitesmith.git
Project-URL: Issues, https://github.com/mardiros/whitesmith/issues
Project-URL: Changelog, https://github.com/mardiros/whitesmith/blob/main/CHANGELOG.rst
Requires-Python: >=3.10
Requires-Dist: Jinja2<4,>=3.1.2
Requires-Dist: blacksmith<6,>=5.0.0
Requires-Dist: polyfactory<3,>=2.14.0
Requires-Dist: pydantic<3,>=2.6.0
Requires-Dist: venusian<4,>=3.1.1
Description-Content-Type: text/x-rst

Whitesmith
==========

Test helper for blacksmith resources.

.. image:: https://github.com/mardiros/whitesmith/actions/workflows/tests.yml/badge.svg
   :target: https://github.com/mardiros/whitesmith/actions/workflows/tests.yml
   :alt: Continuous Integration

.. image:: https://codecov.io/gh/mardiros/whitesmith/graph/badge.svg?token=V1W7W6YWNN
   :target: https://codecov.io/gh/mardiros/whitesmith
   :alt: Coverage


Motivation
----------

While using blacksmith, resources are declared using pydantic, and, while testing,
we never do http calls.

Whitesmith is a helper that create pytest fixtures for blacksmith resources and
generate handlers for tests.


Usage
-----

Generating fixtures
~~~~~~~~~~~~~~~~~~~

::

  whitesmith generate -m my_package.resources --out-dir tests/


The commande above will generate a folder ``tests/whitesmith`` containing
handlers for all the api call with a default implementation.


.. note::
    | If you run the command again, the command does not overrite generated files.
    | To generate newer version, use the ``--overwrite`` flag.


Those fixtures can be adapted to get the result you want,
they must be present in a whitesmith_handlers directory inside the tests suite.


Using the fixtures
~~~~~~~~~~~~~~~~~~

The whitesmith package provide three pytest fixtures that can be used in the testsuite.

The sync_blacksmith_client, async_blacksmith_client can be used to get
a blacksmith client instance that use the installed fixtures from the generated
directory.

Both actually consume the undelying fixtures ``whitesmith_router`` is a generated
fixture that contains all the routes contained in the ``whitesmith_handlers`` directory.
