Metadata-Version: 2.4
Name: yandex-taxi-testsuite
Version: 0.4.7
Summary: Yandex.Taxi Testsuite Package
Home-page: https://github.com/yandex/yandex-taxi-testsuite
License: MIT
Project-URL: Bug Tracker, https://github.com/yandex/yandex-taxi-testsuite/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: packaging
Requires-Dist: PyYAML>=3.13
Requires-Dist: aiohttp>=3.5.4
Requires-Dist: yarl!=1.6,>=1.4.2
Requires-Dist: py>=1.10
Requires-Dist: pytest-aiohttp>=0.3.0
Requires-Dist: pytest-asyncio!=0.22.*,!=0.23.*,!=0.24.*
Requires-Dist: pytest>=4.5.0
Requires-Dist: python-dateutil>=2.7.3
Requires-Dist: cached-property>=1.5.1
Provides-Extra: mongodb
Requires-Dist: pymongo>=3.7.1; extra == "mongodb"
Provides-Extra: postgresql
Requires-Dist: psycopg2>=2.7.5; extra == "postgresql"
Requires-Dist: yandex-pgmigrate; extra == "postgresql"
Provides-Extra: postgresql-binary
Requires-Dist: psycopg2-binary>=2.7.5; extra == "postgresql-binary"
Provides-Extra: clickhouse
Requires-Dist: clickhouse-driver>=0.2.0; extra == "clickhouse"
Provides-Extra: redis
Requires-Dist: python-redis>=0.2.1; extra == "redis"
Requires-Dist: redis>=2.10.6; extra == "redis"
Provides-Extra: mysql
Requires-Dist: PyMySQL>=0.9.2; extra == "mysql"
Provides-Extra: rabbitmq
Requires-Dist: aio-pika>=8.1.0; extra == "rabbitmq"
Provides-Extra: kafka
Requires-Dist: aiokafka>=0.9.0; extra == "kafka"
Provides-Extra: protobuf
Requires-Dist: protobuf>=4.22.5; extra == "protobuf"
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist

Yandex Taxi Testsuite
=====================

.. image:: https://badge.fury.io/py/yandex-taxi-testsuite.svg
    :target: https://pypi.python.org/pypi/yandex-taxi-testsuite
.. image:: https://github.com/yandex/yandex-taxi-testsuite/actions/workflows/ci.yml/badge.svg?branch=develop
    :target: https://github.com/yandex/yandex-taxi-testsuite/actions/workflows/ci.yml?branch=develop
.. image:: https://github.com/yandex/yandex-taxi-testsuite/actions/workflows/macos-ci.yml/badge.svg?branch=develop
    :target: https://github.com/yandex/yandex-taxi-testsuite/actions/workflows/macos-ci.yml?branch=develop


What is testsuite
-----------------

Testsuite is a microservice-oriented test framework written in Python based on
pytest_.

Testsuite is written and supported by Yandex.Taxi_, and is used to test
Yandex.Taxi microservices written in C++ and Python.

The principal suggested approach to testing - although not the only one - is
black box, when the service is tested through http calls.

Direct read and write access from test to database is supported to enable
precondition setup and result assertions.

Installation
------------

Installation using pip_:

.. code-block:: sh

   pip3 install yandex-taxi-testsuite

   # testsuite with mongodb support
   pip3 install yandex-taxi-testsuite[mongodb]

   # testsuite with postgresql support
   pip3 install yandex-taxi-testsuite[postgresql]
   pip3 install yandex-taxi-testsuite[postgresql-binary]

   # testsuite with redis support
   pip3 install yandex-taxi-testsuite[redis]

   # testsuite with mysql support
   pip3 install yandex-taxi-testsuite[mysql]

   # testsuite with clickhouse support
   pip3 install yandex-taxi-testsuite[clickhouse]

   # testsuite with rabbitmq support
   pip3 install yandex-taxi-testsuite[rabbitmq]

   # testsuite with kafka support
   pip3 install yandex-taxi-testsuite[kafka]

   # testsuite with protobuf support
   pip3 install yandex-taxi-testsuite[protobuf]

Supported databases
-------------------

Out-of-the-box testsuite supports the following databases:

* PostgreSQL
* MongoDB
* Redis/Valkey
* MySQL/MariaDB 10+
* ClickHouse
* RabbitMQ

Supported operating systems
---------------------------

Testsuite runs on GNU/Linux and macOS operating systems.

Principle of operation
----------------------

Testsuite sets up the environment for the service being tested:

* Testsuite starts any required databases (postgresql, mongo, redis).
* Before each test, testsuite fills the database with test data.
* Testsuite starts its own web server (mockserver), which mimics (mocks)
  microservices other than the one being tested.

Testsuite starts the microservice being tested in a separate process.

Testsuite then runs tests.

A test performs http requests to the service and verifies that the requests
were processed properly.

A test may check the results of an http call by looking directly into the
service's database.

A test may check whether the service has made calls to external services,
as well as the order of calls and the data that was sent and received.

A test may check the internal state of the service as represented by the data
the service sent to the test with the testpoint mechanism.

Source code
-----------

Testsuite open-source edition code is available
`here <https://github.com/yandex/yandex-taxi-testsuite>`_.

Documentation
-------------

For full documentation, including installation, tutorials,
please see https://yandex.github.io/yandex-taxi-testsuite/.

Running testsuite
-----------------

self-tests:

.. code-block:: sh

   pytest3 ./tests

tests of example services:

.. code-block:: sh

   cd docs/examples && make

Development
-----------

Setup virtual env
~~~~~~~~~~~~~~~~~

In order to test your modifications it's useful to run testsuite inside
virtualenv. Use the following command to create developer's venv:

.. code-block:: sh

   make setup-dev-venv

Virtualenv will be created in `.venv-dev` directory.

Code format and linters
~~~~~~~~~~~~~~~~~~~~~~~

Auto format source code:

.. code-block:: sh

   make venv-format

Run linters:

.. code-block:: sh

   make venv-check-linters
   make venv-check-mypy

You can also add pre-commit hook which will run ruff and linters for you:

.. code-block:: sh

   make install-pre-commit-hooks

Running tests
~~~~~~~~~~~~~

You can run tests using Makefile:

.. code-block:: sh

   make venv-tests

Or directly using pytest:

.. code-block:: sh

   make setup-dev-venv                  # Setup virtual env first
   . .venv-dev/bin/activate             # Activate virtualenv
   pytest -vv tests/plugins/mockserver  # Finally run pytest

Building documentation
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: sh

   make build-docs

Contributing
~~~~~~~~~~~~

* Fork project
* Write code in your own branch
* Test your code
* Run linters and code formatters
* Add new changelog_ entry
* Create pull request on github

.. _Yandex.Taxi: https://taxi.yandex.com/company/
.. _pytest: https://pytest.org/
.. _pip: https://pypi.org/project/yandex-taxi-testsuite/
.. _changelog: https://github.com/yandex/yandex-taxi-testsuite/tree/develop/docs/changelog.rst
