sdlc-hub/tests/conftest.py
Andrey Epifancev b9f5a24512 Хаб: таблица project, схема v4 и миграция base_jql в проекты (#61)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 20:14:23 +04:00

34 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Общие фикстуры тестов. Соединения SQLite, открытые тестом, закрываются после него — в тестах нет
ResourceWarning «unclosed database» (hub-hygiene-d, решение 14; M-9/O-4 #4)."""
import pytest
from jira_hub import db, projects
@pytest.fixture
def open_db():
"""Фабрика соединений: open_db() — база в памяти, open_db(path) — файл. Все закрываются после теста."""
opened = []
def make(path=":memory:"):
conn = db.connect(path)
opened.append(conn)
return conn
yield make
for conn in opened:
conn.close()
@pytest.fixture
def add_project():
"""add_project(conn, label="AWPCA", name=None, board_id=4216, board_type="scrum") -> dict: завести проект."""
def make(conn, label="AWPCA", name=None, board_id=4216, board_type="scrum"):
if name is None:
name = projects.LEGACY_NAME if label == projects.LEGACY_LABEL else label
projects.create(conn, label, name, board_id)
if board_id is not None and board_type is not None:
projects.record_board_types(conn, {str(board_id): board_type})
return projects.get(conn, label)
return make