[Clients] - Write Failing DB Tests for CRUD Operations #98

Closed
opened 2025-11-03 17:38:09 +00:00 by GFMpt13 · 0 comments
GFMpt13 commented 2025-11-03 17:38:09 +00:00 (Migrated from github.com)

Following TDD, we must write tests before implementation. These tests will fail, as the interface methods are empty.

Tasks:

  • Set up the pytest file (e.g., tests/test_client_repo.py).
  • Create database fixtures (e.g., a test database, a sample client fixture).
  • Write a test for test_create_client_success.
  • Write a test for test_create_client_duplicate_nif_fails (to test the unique index).
  • Write a test for test_create_client_missing_required_fields (validates Pydantic schema enforcement).
  • Write a test for test_create_client_invalid_email (tests email format validation).
  • Write a test for test_get_client_by_id_success.
  • Write a test for test_get_client_by_id_not_found.
  • Write a test for test_get_client_by_id_invalid_id_format.
  • Write a test for test_get_all_clients_success.
  • Write a test for test_get_all_clients_empty_collection.
  • Write a test for test_get_client_by_nif_success.
  • Write a test for test_get_client_by_nif_not_found.
  • Write a test for test_update_client_success.
  • Write a test for test_update_client_not_found.
  • Write a test for test_update_client_partial_fields.
  • Write a test for test_update_client_address.
  • Write a test for test_update_client_nif_duplicate_fails.
  • Write a test for test_delete_client_success.
  • Write a test for test_client_with_optional_fields_null.
  • Write a test for test_client_nif_indexed_uniquely.
  • Run pytest and confirm all new tests fail as expected.
Following TDD, we must write tests *before* implementation. These tests will fail, as the interface methods are empty. **Tasks:** - [x] Set up the `pytest` file (e.g., `tests/test_client_repo.py`). - [x] Create database fixtures (e.g., a test database, a sample `client` fixture). - [x] Write a test for `test_create_client_success`. - [x] Write a test for `test_create_client_duplicate_nif_fails` (to test the unique index). - [x] Write a test for `test_create_client_missing_required_fields` (validates Pydantic schema enforcement). - [x] Write a test for `test_create_client_invalid_email` (tests email format validation). - [x] Write a test for `test_get_client_by_id_success`. - [x] Write a test for `test_get_client_by_id_not_found`. - [x] Write a test for `test_get_client_by_id_invalid_id_format`. - [x] Write a test for `test_get_all_clients_success`. - [x] Write a test for `test_get_all_clients_empty_collection`. - [x] Write a test for `test_get_client_by_nif_success`. - [x] Write a test for `test_get_client_by_nif_not_found`. - [x] Write a test for `test_update_client_success`. - [x] Write a test for `test_update_client_not_found`. - [x] Write a test for `test_update_client_partial_fields`. - [x] Write a test for `test_update_client_address`. - [x] Write a test for `test_update_client_nif_duplicate_fails`. - [x] Write a test for `test_delete_client_success`. - [x] Write a test for `test_client_with_optional_fields_null`. - [x] Write a test for `test_client_nif_indexed_uniquely`. - [x] Run `pytest` and confirm all new tests fail as expected.
Sign in to join this conversation.
No description provided.