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

オープン
#2,272 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

  • #2277 @tmdeveloper007 による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python, sqlite
領域
database, testing

調査の方向性

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().

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
36
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

utksh1/SecuScan のほかの issue

utksh1/SecuScan の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。