-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 683a1ec
Showing
23 changed files
with
822 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* @timuram | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: pip | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
time: "00:00" | ||
open-pull-requests-limit: 10 | ||
groups: | ||
python-packages: | ||
patterns: | ||
- "*" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: weekly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: [ 'v*' ] | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
make deps | ||
- name: Lint | ||
run: | | ||
make lint | ||
- name: Tests | ||
run: | | ||
make test | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
needs: test | ||
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/pytest-service/ | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: | ||
python -m pip install -U pip wheel twine build | ||
- name: Make dists | ||
run: | ||
python -m build | ||
- name: Check dists | ||
run: | ||
twine check dist/* | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.idea/ | ||
.git_old |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## v0.0.2 (2024-18-06) | ||
|
||
* Add `redis` service | ||
|
||
|
||
## v0.0.1 (2024-05-11) | ||
|
||
* First version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Timur Ozheghin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
all: deps lint test | ||
|
||
deps: | ||
@python3 -m pip install --upgrade pip && pip3 install -r requirements-dev.txt | ||
|
||
black: | ||
@black --line-length 120 pytest_service tests | ||
|
||
isort: | ||
@isort --line-length 120 --use-parentheses --multi-line 3 --combine-as --trailing-comma pytest_service tests | ||
|
||
flake8: | ||
@flake8 --max-line-length 120 --ignore C901,C812,E203,E704 --extend-ignore W503 pytest_service tests | ||
|
||
pyright: | ||
@pyright pytest_service tests | ||
|
||
lint: black isort flake8 pyright | ||
|
||
test: | ||
@python3 -m pytest -vv --rootdir tests . | ||
|
||
pyenv: | ||
echo pytest_service > .python-version && pyenv install -s 3.11.1 && pyenv virtualenv -f 3.11.1 pytest_service | ||
|
||
pyenv-delete: | ||
pyenv virtualenv-delete -f pytest_service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# pytest-service | ||
|
||
Inspired by [pytest-pg](https://pypi.org/project/pytest-pg/) but with `MongoDB` onboard | ||
|
||
### How to use | ||
|
||
#### Postgres | ||
|
||
```python | ||
@pytest.fixture(scope="session") | ||
def pg_14_local() -> Iterator: | ||
with pytest_service.PGService("postgres:14.4-alpine").run() as pg: | ||
yield pg | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def init_env(pg_14_local: pytest_service.PG) -> None: | ||
if not pg_14_local: | ||
return | ||
os.environ["POSTGRES_DBNAME"] = pg_14_local.database | ||
os.environ["POSTGRES_USER"] = pg_14_local.user | ||
os.environ["POSTGRES_PASSWORD"] = pg_14_local.password | ||
os.environ["POSTGRES_HOST"] = pg_14_local.host | ||
os.environ["POSTGRES_PORT"] = str(pg_14_local.port) | ||
|
||
``` | ||
|
||
#### MongoDB | ||
|
||
```python | ||
@pytest.fixture(scope="session") | ||
def mongo_6_local() -> Iterator: | ||
with pytest_service.MongoDBService("mongo:6").run() as mongo: | ||
yield mongo | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def init_env(mongo_6_local: pytest_service.Mongo) -> None: | ||
if not mongo_6_local: | ||
return | ||
os.environ["MONGODB_CONNECTION_STRING"] = mongo_6_local.connection_string | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[build-system] | ||
requires = ["setuptools>=68.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "pytest_service" | ||
dynamic = ["version"] | ||
requires-python = ">=3.10" | ||
dependencies = [ | ||
"pytest>=6.0.0", | ||
"docker>=6.1.0", | ||
"requests<2.33.0", | ||
] | ||
classifiers = [ | ||
"License :: OSI Approved :: MIT License", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Operating System :: OS Independent", | ||
"Development Status :: 5 - Production/Stable", | ||
"Framework :: Pytest" | ||
] | ||
license = { file = "LICENSE" } | ||
readme = "README.md" | ||
|
||
[project.urls] | ||
homepage = "https://github.com/anna-money/pytest-service" | ||
changelog = "https://github.com/anna-money/pytest-service/blob/master/CHANGELOG.md" | ||
|
||
[project.entry-points.pytest11] | ||
pytest_service = "pytest_service" | ||
|
||
[tool.setuptools] | ||
packages = ["pytest_service"] | ||
|
||
[tool.setuptools.package-data] | ||
pytest_service = ["py.typed", "VERSION"] | ||
|
||
[tool.setuptools.dynamic] | ||
version = { file = ["pytest_service/VERSION"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.2 |
Oops, something went wrong.