Open
Description
Description:
The test TestOutputEngine.test_output_json2
is failing with a sqlite3.OperationalError
indicating that the cve_severity
table does not exist in the database. First noticed here
Steps to Reproduce:
- Set up the environment and install dependencies.
- Run the test suite using the command:
pytest test/test_output_engine.py
- Observe the failure in
TestOutputEngine.test_output_json2
.
Expected Behavior:
The test should pass, and the output_json2
function should successfully retrieve the count of CVE entries from the cve_severity
table.
Actual Behavior:
The test fails with the following error:
sqlite3.OperationalError: no such table: cve_severity
Error Log:
================================================= FAILURES =================================================
____________________________________ TestOutputEngine.test_output_json2 ____________________________________
self = <test.test_output_engine.TestOutputEngine testMethod=test_output_json2>
def test_output_json2(self):
"""Test formatting output as JSON2"""
> output_json2(
self.MOCK_OUTPUT,
None,
datetime.today(),
self.mock_file,
0,
self.MOCK_ORGANIZED_PARAMETERS,
metrics=True,
)
test/test_output_engine.py:1074:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cve_bin_tool/output_engine/json_output.py:116: in output_json2
"total_entries": db_entries_count(),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def db_entries_count():
"""
Retrieves the count of CVE entries from the database grouped by data source.
Returns:
dict: A dictionary containing the count of CVE entries for each data source.
"""
instance = CVEDB()
cursor = instance.db_open_and_get_cursor()
cve_entries_check = "SELECT data_source, COUNT(*) as number FROM cve_severity GROUP BY data_source ORDER BY number DESC"
> cursor.execute(cve_entries_check)
E sqlite3.OperationalError: no such table: cve_severity
cve_bin_tool/output_engine/json_output.py:54: OperationalError
Additional Context:
This issue might be related to the database initialization or migration process. It would be helpful to check if the database schema is up-to-date and if all necessary migrations have been applied or the test might be missing a fixture or setup step to create the required table.
Environment:
- Python Version: 3.11.0rc1
- Operating System: Linux
- Dependencies: pytest-8.3.4