chore(): removed tests directory to reduce confusion
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
# Lotty Tests
|
|
||||||
|
|
||||||
There is `unit` and `e2e` tests available, `unit` tests are placed all around `backend` service folder and `e2e` tests placed [here](./e2e/).
|
|
||||||
|
|
||||||
## Running unit tests
|
|
||||||
|
|
||||||
### Backend service
|
|
||||||
|
|
||||||
See [services/backend/README.md](../src/backend/README.md#testing).
|
|
||||||
|
|
||||||
## Unit tests coverage
|
|
||||||
|
|
||||||
### Backend service
|
|
||||||
|
|
||||||
TODO()
|
|
||||||
|
|
||||||
## Running e2e tests
|
|
||||||
|
|
||||||
See [tests/e2e/README.md](./e2e/README.md).
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Below all environment variables and default values
|
|
||||||
|
|
||||||
BACKEND_BASE_URL=http://127.0.0.1:13240
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
# 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/
|
|
||||||
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/
|
|
||||||
cover/
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
*.pot
|
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
db.sqlite3-journal
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# PyBuilder
|
|
||||||
.pybuilder/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
|
||||||
.ipynb_checkpoints
|
|
||||||
|
|
||||||
# IPython
|
|
||||||
profile_default/
|
|
||||||
ipython_config.py
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
|
||||||
# intended to run in multiple environments; otherwise, check them in:
|
|
||||||
.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
|
|
||||||
|
|
||||||
# UV
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
||||||
# commonly ignored for libraries.
|
|
||||||
uv.lock
|
|
||||||
|
|
||||||
# poetry
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
||||||
# commonly ignored for libraries.
|
|
||||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
||||||
poetry.lock
|
|
||||||
|
|
||||||
# pdm
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
||||||
#pdm.lock
|
|
||||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
||||||
# in version control.
|
|
||||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
||||||
.pdm.toml
|
|
||||||
.pdm-python
|
|
||||||
.pdm-build/
|
|
||||||
|
|
||||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
||||||
__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/
|
|
||||||
|
|
||||||
# pytype static type analyzer
|
|
||||||
.pytype/
|
|
||||||
|
|
||||||
# Cython debug symbols
|
|
||||||
cython_debug/
|
|
||||||
|
|
||||||
# PyCharm
|
|
||||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# PyPI configuration file
|
|
||||||
.pypirc
|
|
||||||
|
|
||||||
# Ruff files
|
|
||||||
.ruff_cache
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# E2E tests for Lotty
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Ensure you have the following installed on your system:
|
|
||||||
|
|
||||||
- [Python](https://www.python.org/) (>=3.10,<3.14)
|
|
||||||
- [uv](https://docs.astral.sh/uv/) (latest version recommended)
|
|
||||||
- [Docker](https://www.docker.com/) (latest version recommended)
|
|
||||||
- [Docker compose](https://docs.docker.com/compose/) (latest version recommended)
|
|
||||||
|
|
||||||
## Warning
|
|
||||||
|
|
||||||
Please note that containers will use ports from 13240 to 13248, so there is must be no listeners on this ports range.
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
### Clone the project
|
|
||||||
|
|
||||||
### Go to the project directory
|
|
||||||
|
|
||||||
### Install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
uv sync --no-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
### Customize environment (optional)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp .env.template .env
|
|
||||||
```
|
|
||||||
|
|
||||||
And setup env vars according to your needs.
|
|
||||||
|
|
||||||
### Run tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
uv run pytest .
|
|
||||||
```
|
|
||||||
|
|
||||||
### Results
|
|
||||||
|
|
||||||
You will see something like `n passed in Ns`
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import time
|
|
||||||
from collections.abc import Generator
|
|
||||||
|
|
||||||
import httpx
|
|
||||||
import pytest
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
BACKEND_BASE_URL = os.getenv("BACKEND_BASE_URL", "http://127.0.0.1:13240")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session", autouse=True)
|
|
||||||
def docker_compose() -> Generator[None]:
|
|
||||||
# btw, this is just in case you've forgotten to shut down compose :)
|
|
||||||
subprocess.run(
|
|
||||||
executable="docker",
|
|
||||||
args=[
|
|
||||||
"docker",
|
|
||||||
"compose",
|
|
||||||
"--profile",
|
|
||||||
"loadtest",
|
|
||||||
"--profile",
|
|
||||||
"minio",
|
|
||||||
"--profile",
|
|
||||||
"observability",
|
|
||||||
"--profile",
|
|
||||||
"proxy",
|
|
||||||
"--profile",
|
|
||||||
"telegram_bot",
|
|
||||||
"down",
|
|
||||||
],
|
|
||||||
check=True,
|
|
||||||
)
|
|
||||||
subprocess.run(
|
|
||||||
executable="docker",
|
|
||||||
args=[
|
|
||||||
"docker",
|
|
||||||
"compose",
|
|
||||||
"--project-name",
|
|
||||||
"template-testing",
|
|
||||||
"--profile",
|
|
||||||
"minio",
|
|
||||||
"up",
|
|
||||||
"-d",
|
|
||||||
"--build",
|
|
||||||
"--force-recreate",
|
|
||||||
"--remove-orphans",
|
|
||||||
],
|
|
||||||
check=True,
|
|
||||||
)
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
yield
|
|
||||||
|
|
||||||
subprocess.run(
|
|
||||||
executable="docker",
|
|
||||||
args=[
|
|
||||||
"docker",
|
|
||||||
"compose",
|
|
||||||
"--project-name",
|
|
||||||
"template-testing",
|
|
||||||
"--profile",
|
|
||||||
"minio",
|
|
||||||
"down",
|
|
||||||
"-v",
|
|
||||||
],
|
|
||||||
check=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
|
||||||
def client() -> Generator[httpx.Client]:
|
|
||||||
with httpx.Client(base_url=BACKEND_BASE_URL, timeout=10.0) as client:
|
|
||||||
yield client
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
|
|
||||||
items.sort(key=lambda item: "test_health" not in item.nodeid)
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env just --justfile
|
|
||||||
|
|
||||||
[group('help')]
|
|
||||||
[private]
|
|
||||||
default:
|
|
||||||
@ just --list --list-heading $'justfile manual page:\n'
|
|
||||||
|
|
||||||
# show help
|
|
||||||
[group('help')]
|
|
||||||
help: default
|
|
||||||
|
|
||||||
style:
|
|
||||||
just format
|
|
||||||
just lint
|
|
||||||
just mypy
|
|
||||||
|
|
||||||
check:
|
|
||||||
just style
|
|
||||||
|
|
||||||
# lints codebase using golangci-lint
|
|
||||||
[group('lint')]
|
|
||||||
lint:
|
|
||||||
@ uv run ruff check .
|
|
||||||
|
|
||||||
# lints and fixes codebase using ruff
|
|
||||||
[group('lint')]
|
|
||||||
fix:
|
|
||||||
@ uv run ruff check . --fix
|
|
||||||
|
|
||||||
# formats codebase using ruff
|
|
||||||
[group('lint')]
|
|
||||||
format:
|
|
||||||
@ uv run ruff format .
|
|
||||||
|
|
||||||
alias fmt := format
|
|
||||||
|
|
||||||
# lints codebase using mypy
|
|
||||||
[group('lint')]
|
|
||||||
mypy:
|
|
||||||
@ uv run mypy .
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
[project]
|
|
||||||
dependencies = ["httpx>=0.28.1", "pytest>=8.3.4", "python-dotenv>=1.0.1"]
|
|
||||||
name = "lotty-tests-e2e"
|
|
||||||
readme = "README.md"
|
|
||||||
requires-python = ">=3.10,<3.14"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[dependency-groups]
|
|
||||||
dev = ["ruff"]
|
|
||||||
|
|
||||||
[tool.ruff]
|
|
||||||
builtins = []
|
|
||||||
cache-dir = ".ruff_cache"
|
|
||||||
exclude = [
|
|
||||||
".bzr",
|
|
||||||
".direnv",
|
|
||||||
".eggs",
|
|
||||||
".git",
|
|
||||||
".git-rewrite",
|
|
||||||
".hg",
|
|
||||||
".mypy_cache",
|
|
||||||
".nox",
|
|
||||||
".pants.d",
|
|
||||||
".pytype",
|
|
||||||
".ruff_cache",
|
|
||||||
".svn",
|
|
||||||
".tox",
|
|
||||||
".venv",
|
|
||||||
"__pypackages__",
|
|
||||||
"_build",
|
|
||||||
"buck-out",
|
|
||||||
"dist",
|
|
||||||
"migrations",
|
|
||||||
"node_modules",
|
|
||||||
"venv",
|
|
||||||
]
|
|
||||||
extend-exclude = []
|
|
||||||
extend-include = []
|
|
||||||
fix = false
|
|
||||||
fix-only = false
|
|
||||||
force-exclude = true
|
|
||||||
include = ["**/pyproject.toml", "*.ipynb", "*.py", "*.pyi"]
|
|
||||||
indent-width = 4
|
|
||||||
line-length = 79
|
|
||||||
namespace-packages = []
|
|
||||||
output-format = "full"
|
|
||||||
preview = false
|
|
||||||
required-version = ">=0.8.4"
|
|
||||||
respect-gitignore = true
|
|
||||||
show-fixes = true
|
|
||||||
src = [".", "src"]
|
|
||||||
target-version = "py310"
|
|
||||||
unsafe-fixes = false
|
|
||||||
|
|
||||||
[tool.ruff.analyze]
|
|
||||||
detect-string-imports = true
|
|
||||||
direction = "Dependencies"
|
|
||||||
exclude = []
|
|
||||||
include-dependencies = {}
|
|
||||||
preview = false
|
|
||||||
|
|
||||||
[tool.ruff.format]
|
|
||||||
docstring-code-format = true
|
|
||||||
docstring-code-line-length = 79
|
|
||||||
exclude = []
|
|
||||||
indent-style = "space"
|
|
||||||
line-ending = "lf"
|
|
||||||
preview = false
|
|
||||||
quote-style = "double"
|
|
||||||
skip-magic-trailing-comma = false
|
|
||||||
|
|
||||||
[tool.ruff.lint]
|
|
||||||
allowed-confusables = ["ℹ"]
|
|
||||||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
||||||
exclude = ["tests.py"]
|
|
||||||
explicit-preview-rules = false
|
|
||||||
extend-fixable = []
|
|
||||||
extend-per-file-ignores = {}
|
|
||||||
extend-safe-fixes = []
|
|
||||||
extend-select = []
|
|
||||||
extend-unsafe-fixes = []
|
|
||||||
external = []
|
|
||||||
fixable = ["ALL"]
|
|
||||||
ignore = ["ANN401", "ARG", "COM812", "D", "FBT001", "FBT002", "N813", "S101"]
|
|
||||||
logger-objects = []
|
|
||||||
per-file-ignores = {}
|
|
||||||
preview = false
|
|
||||||
select = ["ALL"]
|
|
||||||
task-tags = ["FIXME", "HACK", "TODO", "WORKOUT"]
|
|
||||||
typing-modules = []
|
|
||||||
unfixable = []
|
|
||||||
|
|
||||||
[tool.ruff.lint.pylint]
|
|
||||||
max-args = 6
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[pytest]
|
|
||||||
log_cli = true
|
|
||||||
log_level = INFO
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import logging
|
|
||||||
from http import HTTPStatus as status
|
|
||||||
|
|
||||||
from httpx import Client
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def test_healthcheck(client: Client) -> None:
|
|
||||||
response = client.get("/ready?format=json")
|
|
||||||
assert response.status_code == status.OK
|
|
||||||
|
|
||||||
response_data = response.json()
|
|
||||||
|
|
||||||
unhealthy_services = [
|
|
||||||
service
|
|
||||||
for service, status in response_data.items()
|
|
||||||
if status != "OK"
|
|
||||||
]
|
|
||||||
|
|
||||||
for service in unhealthy_services:
|
|
||||||
logger.error(
|
|
||||||
"Service %s unhealthy: %s", service, response_data[service]
|
|
||||||
)
|
|
||||||
|
|
||||||
assert not unhealthy_services, (
|
|
||||||
f"Some services are unhealthy: {', '.join(unhealthy_services)}"
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user