test : add unit tests for Database.connection property error path

Abierto
#2,272 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

  • #2277 de @tmdeveloper007 — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python, sqlite
Área
database, testing

Línea de trabajo

Read backend/secuscan/database.py and inspect the Database connection property and initialization state. Then review nearby unit test conventions before creating testing/backend/unit/test_database.py; use --noconftest and an in-memory SQLite path. Done means the tests cover the disconnected error and message, plus the specified state before and after connect().

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary of What Needs to be Done:
Add unit tests for the Database.connection property error path in backend/secuscan/database.py. When the database is not connected, accessing the .connection property should raise a RuntimeError with a clear message.

Changes that Need to be Made:
Create testing/backend/unit/test_database.py (standalone unit tests) covering:

  1. Database(db_path=":memory:").connection raises RuntimeError when not connected
  2. The RuntimeError message is descriptive and actionable
  3. Database._connection is None before connect()
  4. Database._connection is set after connect()
  5. Database._in_transaction is False initially

Note: Use an in-memory SQLite database (":memory:") path to avoid file system dependencies. The test should NOT require a real database file.

Import from backend.secuscan.database import Database directly. Use --noconftest for local runs.

Impact that it would Provide:

  • Reliability: Documents the expected error behavior when database is used before connection
  • Testing: Covers an entirely untested module (database.py)
  • Maintainability: Provides a clear contract for Database initialization state

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Lenguaje dominante
Python
Estrellas
36
Forks
234
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de utksh1/SecuScan

Todos los issues de utksh1/SecuScan

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.