Add unit tests for content upload validation schemas
Issue Summary
Write unit tests for Pydantic models that validate uploads of text, audio, video, and image files to ensure proper field validation and edge case handling.
Problem Statement
Current validation schemas handle different media types and fields but are not tested. Missing test coverage could allow invalid uploads, security issues, or incorrect field formats. Users or the system may receive invalid data, which can break endpoints.
Impact:
Invalid files could bypass validation. API endpoints may fail or produce inconsistent data.
Reproduction:
Any file submission with invalid fields (e.g., wrong MIME type, too short title, invalid coordinates) currently may not be properly tested.
Proposed Solution
Implement unit tests for each validation class: TextContentValidation AudioContentValidation VideoContentValidation ImageContentValidation BatchUploadValidation FileHashValidation ChunkedUploadValidation RecordUpdateValidation Use pytest and pytest-raises to check validation errors. Test happy paths, edge cases, and boundary values for each field.
Test-Driven Development
Acceptance Criteria
Scenario 1: Valid text content upload
Given a text file with title >= 8 chars, description >= 32 chars, text content >= 50 chars When the TextContentValidation model is instantiated Then no validation error should occur
Scenario 2: Invalid audio file upload
Given an audio file with unsupported MIME type or duration < 10 seconds When the AudioFileValidation model is instantiated Then a ValueError should be raised with appropriate message
Scenario 3: Batch upload exceeding limits
Given a list of uploads > 50 items When the BatchUploadValidation model is instantiated Then a ValueError should be raised indicating max batch size exceeded
### Test Cases
| Test ID | Test Description | Precondition | Test Steps | Expected Result | Priority |
| ------- | ------------------------------------ | ------------------------------------------------- | ------------------------------------------- | -------------------------- | -------- |
| TC-001 | TextContentValidation happy path | Valid text fields | 1. Create model instance 2. Validate fields | No error | High |
| TC-002 | TextContentValidation short text | Text <50 chars | 1. Create model instance | ValueError for text length | High |
| TC-003 | AudioFileValidation invalid MIME | Unsupported MIME | 1. Create model instance | ValueError for MIME | High |
| TC-004 | AudioFileValidation invalid duration | duration <10s | 1. Create model instance | ValueError for duration | High |
| TC-005 | BatchUploadValidation max limit | 51 uploads | 1. Create model instance | ValueError for max items | Medium |
| TC-006 | FileHashValidation invalid hash | Non-hex string | 1. Create model instance | ValueError for hash format | High |
| TC-007 | RecordUpdateValidation others rights | ReleaseRights=others without creator/source_label | 1. Create model instance | ValueError | High |
### Unit Test Requirements
| Module | Class/Function | Test Cases |
| ------------------- | ------------------------ | -------------- |
| `upload_schemas.py` | `TextContentValidation` | TC-001, TC-002 |
| `upload_schemas.py` | `AudioFileValidation` | TC-003, TC-004 |
| `upload_schemas.py` | `BatchUploadValidation` | TC-005 |
| `upload_schemas.py` | `FileHashValidation` | TC-006 |
| `upload_schemas.py` | `RecordUpdateValidation` | TC-007 |
**Test Assertions Required:**
- [ ] Renders correctly with initial state
- [ ] Handles user input correctly
- [ ] Validates input and shows errors
- [ ] Calls API with correct payload
- [ ] Handles loading state
- [ ] Handles success response
- [ ] Handles error response
- [ ] Updates UI state appropriately
### Automated Testing
**Unit Tests:**
- [x] Component render tests
- [x] User interaction tests
- [x] API integration tests
- [x] Error handling tests
**Integration Tests (if applicable):**
- [x] Multi-component interaction tests
- [x] Route navigation tests
### Test Data Requirements
<!--
Define any test data needed:
- Mock API responses
- Test user accounts
- Sample form data
-->
```typescript
// Example mock data
const mockTestData = {
// Add required test data structure
}
Definition of Done
-
Acceptance criteria met (all Given-When-Then scenarios pass) -
All test cases executed and passing -
Unit tests written and passing (minimum coverage: __%) -
Manual testing completed -
Code reviewed and approved -
UI matches design specifications (if applicable) -
Responsive on all required viewport sizes -
Accessibility checks passed (aria labels, keyboard navigation) -
No console errors or warnings -
TypeScript types defined (no any) -
ESLint/Prettier checks pass -
Documentation updated (if applicable) -
i18n strings externalized (no hardcoded text)
--