Name | pytest-budosystems JSON |
Version |
0.3.0
JSON |
| download |
home_page | |
Summary | Budo Systems is a martial arts school management system. This module is the Budo Systems Pytest Plugin. |
upload_time | 2023-05-07 01:02:55 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.9 |
license | |
keywords |
budo systems
test
pytest
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Budo Systems Pytest Suite
=========================
This add-on to the Budo Systems platform creates a standardized test suite
for modules that implement services abstracted in Budo Systems Core
(`project <https://gitlab.com/budosystems/budosystems-core>`_,
`docs <https://budosystems.readthedocs.io/>`_).
This early version only provides a test suite for a ``Repository``. However, you get 21 ready-to-use tests for free to
validate your implementation of a ``Repository``.
Usage
-----
The assumption here is that you're using this package to add tests for an implementation of a feature for Budo Systems.
Step 1. Installation
~~~~~~~~~~~~~~~~~~~~
From your project environment, first you need to install the package. There are several options for this. Here are
but a few examples.
#. Install directly with ``pip``:
|shell|
.. code:: sh
pip install pytest-budosystems
#. Add to ``requirements.txt``, and install using that file:
|unifile| ``requirements.txt``
.. code::
budosystems-core
pytest-budosystems
|shell|
.. code:: sh
pip install -r requirements.txt
#. Add to ``setup.cfg``, and reinstall your project:
|unifile| ``setup.cfg``
.. code:: cfg
[metadata]
name = my-budosystems-project
version = 0.0.2
description = My implementation of a Budo Systems feature.
[options]
python_requires = >= 3.9
packages = find_namespace:
package_dir =
=src
install_requires =
budosystems-core
another-required-package
something-else-needed
[options.packages.find]
where = src
[options.extras_require]
test =
pytest
pytest-budosystems
|shell|
.. code:: sh
pip install -U -e .
Step 2. Add to your test suite
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To use this test suite to test your implementation of a ``budosystems.storage.repository.Repository``, you'll need to
create a test class that inherits from
``budosystems.xtra.pytest_suite.repository.AbstractTestRepository`` and override a few fixture methods.
The only required fixture method is ``repo_class``. It's an abstract method with the following specs:
.. code:: python
@abstractmethod
@fixture(scope="class")
def repo_class(self) -> type[Repository]:
"""Returns the class for the implementation of `Repository` being tested."""
Your testing needs may require you to override some other fixture methods. The two most likely candidates are
``repo_args`` and ``repo_inaccessible``. Here's how they are defined in ``AbstractTestRepository``
.. code:: python
@fixture(scope="class")
def repo_args(self) -> dict[str, Any]:
"""Returns implementation specific arguments to instantiate the implementation of
`Repository` being tested."""
return {}
@fixture(scope="class")
def repo_inaccessible(self, repo_class: type[Repository]) -> Repository:
"""
Returns an instance of the implementation of `Repository` with improper connection.
"""
pytest.skip(f"No 'inaccessible' implementation of {str(repo_class)}")
Minimal Example
+++++++++++++++
A minimal example can be found in the test suite for Budo Systems Core:
|unifile| ``test_dict_repository.py``
.. code:: python
from pytest import fixture
from budosystems.xtra.pytest_suite.repository import AbstractTestRepository
from budosystems.storage.repository import Repository
from budosystems.storage.dict_repository import DictRepository
class TestDictRepository(AbstractTestRepository):
@fixture(scope="class")
def repo_class(self) -> type[Repository]:
return DictRepository
A More Complex Example
++++++++++++++++++++++
An example that overrides all the methods listed above can be found in the test suite for Budo Systems SQLite Storage:
|unifile| ``test_repository.py``
.. code:: python
from pytest import fixture
import sqlite3
from typing import Any
from budosystems.xtra.pytest_suite.repository import AbstractTestRepository
from budosystems.storage.repository import Repository
from budosystems.xtra.sqlite3_storage.repository import SQLite3Repository
class TestSQLite3Repository(AbstractTestRepository):
@fixture(scope="class")
def repo_class(self) -> type[Repository]:
return SQLite3Repository
@fixture(scope="class")
def repo_args(self) -> dict[str, Any]:
return {"con": sqlite3.connect(":memory:")}
@fixture(scope="class")
def repo_inaccessible(self, repo_class: type[Repository]) -> Repository:
con = sqlite3.connect(":memory:")
repo = repo_class(con=con)
con.close()
return repo
Step 3. Test!
~~~~~~~~~~~~~
Run ``pytest`` and get your results.
.. |unishell| unicode:: U+1f41a
.. |unifile| unicode:: U+1f4dd
.. |shell| replace:: |unishell| shell
Raw data
{
"_id": null,
"home_page": "",
"name": "pytest-budosystems",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "Budo Systems,test,pytest",
"author": "",
"author_email": "Jo\u00ebl Larose <joel.larose@budo.systems>",
"download_url": "https://files.pythonhosted.org/packages/a8/d3/01c971ee100ae0306fb1e01cab4b2451e47040fb8283361c5676e80aa296/pytest-budosystems-0.3.0.tar.gz",
"platform": null,
"description": "Budo Systems Pytest Suite\n=========================\n\nThis add-on to the Budo Systems platform creates a standardized test suite\nfor modules that implement services abstracted in Budo Systems Core\n(`project <https://gitlab.com/budosystems/budosystems-core>`_,\n`docs <https://budosystems.readthedocs.io/>`_).\n\nThis early version only provides a test suite for a ``Repository``. However, you get 21 ready-to-use tests for free to\nvalidate your implementation of a ``Repository``.\n\nUsage\n-----\nThe assumption here is that you're using this package to add tests for an implementation of a feature for Budo Systems.\n\nStep 1. Installation\n~~~~~~~~~~~~~~~~~~~~\n\nFrom your project environment, first you need to install the package. There are several options for this. Here are\nbut a few examples.\n\n#. Install directly with ``pip``:\n\n |shell|\n\n .. code:: sh\n\n pip install pytest-budosystems\n\n#. Add to ``requirements.txt``, and install using that file:\n\n |unifile| ``requirements.txt``\n\n .. code::\n\n budosystems-core\n pytest-budosystems\n\n |shell|\n\n .. code:: sh\n\n pip install -r requirements.txt\n\n#. Add to ``setup.cfg``, and reinstall your project:\n\n |unifile| ``setup.cfg``\n\n .. code:: cfg\n\n [metadata]\n name = my-budosystems-project\n version = 0.0.2\n description = My implementation of a Budo Systems feature.\n\n [options]\n python_requires = >= 3.9\n packages = find_namespace:\n package_dir =\n =src\n\n install_requires =\n budosystems-core\n another-required-package\n something-else-needed\n\n [options.packages.find]\n where = src\n\n [options.extras_require]\n test =\n pytest\n pytest-budosystems\n\n |shell|\n\n .. code:: sh\n\n pip install -U -e .\n\nStep 2. Add to your test suite\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTo use this test suite to test your implementation of a ``budosystems.storage.repository.Repository``, you'll need to\ncreate a test class that inherits from\n``budosystems.xtra.pytest_suite.repository.AbstractTestRepository`` and override a few fixture methods.\n\nThe only required fixture method is ``repo_class``. It's an abstract method with the following specs:\n\n.. code:: python\n\n @abstractmethod\n @fixture(scope=\"class\")\n def repo_class(self) -> type[Repository]:\n \"\"\"Returns the class for the implementation of `Repository` being tested.\"\"\"\n\nYour testing needs may require you to override some other fixture methods. The two most likely candidates are\n``repo_args`` and ``repo_inaccessible``. Here's how they are defined in ``AbstractTestRepository``\n\n.. code:: python\n\n @fixture(scope=\"class\")\n def repo_args(self) -> dict[str, Any]:\n \"\"\"Returns implementation specific arguments to instantiate the implementation of\n `Repository` being tested.\"\"\"\n return {}\n\n @fixture(scope=\"class\")\n def repo_inaccessible(self, repo_class: type[Repository]) -> Repository:\n \"\"\"\n Returns an instance of the implementation of `Repository` with improper connection.\n \"\"\"\n pytest.skip(f\"No 'inaccessible' implementation of {str(repo_class)}\")\n\nMinimal Example\n+++++++++++++++\n\nA minimal example can be found in the test suite for Budo Systems Core:\n\n|unifile| ``test_dict_repository.py``\n\n.. code:: python\n\n from pytest import fixture\n from budosystems.xtra.pytest_suite.repository import AbstractTestRepository\n from budosystems.storage.repository import Repository\n from budosystems.storage.dict_repository import DictRepository\n\n class TestDictRepository(AbstractTestRepository):\n\n @fixture(scope=\"class\")\n def repo_class(self) -> type[Repository]:\n return DictRepository\n\nA More Complex Example\n++++++++++++++++++++++\n\nAn example that overrides all the methods listed above can be found in the test suite for Budo Systems SQLite Storage:\n\n|unifile| ``test_repository.py``\n\n.. code:: python\n\n from pytest import fixture\n import sqlite3\n from typing import Any\n\n from budosystems.xtra.pytest_suite.repository import AbstractTestRepository\n from budosystems.storage.repository import Repository\n from budosystems.xtra.sqlite3_storage.repository import SQLite3Repository\n\n class TestSQLite3Repository(AbstractTestRepository):\n\n @fixture(scope=\"class\")\n def repo_class(self) -> type[Repository]:\n return SQLite3Repository\n\n @fixture(scope=\"class\")\n def repo_args(self) -> dict[str, Any]:\n return {\"con\": sqlite3.connect(\":memory:\")}\n\n @fixture(scope=\"class\")\n def repo_inaccessible(self, repo_class: type[Repository]) -> Repository:\n con = sqlite3.connect(\":memory:\")\n repo = repo_class(con=con)\n con.close()\n return repo\n\nStep 3. Test!\n~~~~~~~~~~~~~\n\nRun ``pytest`` and get your results.\n\n.. |unishell| unicode:: U+1f41a\n.. |unifile| unicode:: U+1f4dd\n.. |shell| replace:: |unishell| shell\n",
"bugtrack_url": null,
"license": "",
"summary": "Budo Systems is a martial arts school management system. This module is the Budo Systems Pytest Plugin.",
"version": "0.3.0",
"project_urls": {
"Issue Tracker": "https://gitlab.com/budosystems/pytest-budosystems/-/issues",
"Repository": "https://gitlab.com/budosystems/pytest-budosystems"
},
"split_keywords": [
"budo systems",
"test",
"pytest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1c87693089799be286c99eda142d36ca54cdb62834113557773d8c7ee40e4ce6",
"md5": "c3fdf8e61d1a1b70228fcf02827291e3",
"sha256": "b21063ada4e6a592b64e6dce1ce7f50935a29ed9b63edbb0ec83d987e54a7256"
},
"downloads": -1,
"filename": "pytest_budosystems-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c3fdf8e61d1a1b70228fcf02827291e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 14150,
"upload_time": "2023-05-07T01:02:53",
"upload_time_iso_8601": "2023-05-07T01:02:53.602458Z",
"url": "https://files.pythonhosted.org/packages/1c/87/693089799be286c99eda142d36ca54cdb62834113557773d8c7ee40e4ce6/pytest_budosystems-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a8d301c971ee100ae0306fb1e01cab4b2451e47040fb8283361c5676e80aa296",
"md5": "324a3e31bcb58a9e1c494c31d516811b",
"sha256": "92623a6c0d688f2e689e701fb4cb27e949e7cc736787a51e94af0d83a16a1b71"
},
"downloads": -1,
"filename": "pytest-budosystems-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "324a3e31bcb58a9e1c494c31d516811b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 83103,
"upload_time": "2023-05-07T01:02:55",
"upload_time_iso_8601": "2023-05-07T01:02:55.275483Z",
"url": "https://files.pythonhosted.org/packages/a8/d3/01c971ee100ae0306fb1e01cab4b2451e47040fb8283361c5676e80aa296/pytest-budosystems-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-07 01:02:55",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "budosystems",
"gitlab_project": "pytest-budosystems",
"lcname": "pytest-budosystems"
}