mutheujoy / MISSING-PERSONS-DATABASE-2024-KENYA-FINANCE-BILL-PROTESTS-

AI-powered platform for tracking missing Kenyans during the 2024 #RejectFinanceBill2024 protests in Kenya
Other
87 stars 50 forks source link

OperationalError: no such table: missing_person in SQLite Database during Testing #29

Closed Dovineowuor closed 1 month ago

Dovineowuor commented 1 month ago

Issue Title: OperationalError: no such table: missing_person in SQLite Database during Testing

Description:

During testing, the SQLite database is encountering an OperationalError indicating that the missing_person table does not exist. This error occurs when executing SQL commands that interact with this table, leading to failures in test cases.

Error Trace:

sqlite3.OperationalError: no such table: missing_person
[SQL: INSERT INTO missing_person (name, nickname, gender, x_handle_full, x_handle, status, holding_location, last_known_location, photo_url, security_organ, time_taken, time_taken_formatted, notes, released_on, age, occupation, contact_info) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('Emily Clark', 'Em', 'Female', 'N/A', 'N/A', 'Missing', 'N/A', 'N/A', None, 'N/A', None, None, 'N/A', 'N/A', None, None, 'emily.clark@example.com')]

Test Cases Affected:

Steps to Reproduce:

  1. Run tests that interact with the missing_person table.
  2. Observe the sqlite3.OperationalError indicating that the table does not exist.

Expected Behavior:

The missing_person table should be present in the SQLite database, allowing the tests to execute SQL commands without encountering errors.

Actual Behavior:

The missing_person table is missing, causing SQL operations to fail and resulting in test failures.

Possible Causes:

Suggested Solutions:

  1. Verify that the missing_person table is correctly defined in the SQLAlchemy models.
  2. Ensure that database migrations are applied, if applicable.
  3. Check the test setup code to confirm that the database schema is initialized before running tests.
  4. Ensure that db.create_all() is called in the test setup if using an in-memory SQLite database.
  5. Review test database configuration and initialization to ensure consistency with the application schema.