moderator-api / TEST_DATA.md
Mohameddda's picture
Initial commit
1c3fe08
# Feedback Moderation API - Test Data
Test data for the Wasla Feedback Moderation API.
## Configuration
```bash
API_URL="http://127.0.0.1:8000/api/v1/moderate"
API_KEY="your-api-key-here"
```
---
## Health Check
```bash
curl http://127.0.0.1:8000/health
```
**Expected Response:**
```json
{
"status": "ok",
"multilingual_model_loaded": true,
"arabic_model_loaded": true,
"llm_verification_enabled": false
}
```
---
## English Test Cases
### Toxic Examples
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "You are an idiot and your family should leave"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "This product is terrible and I hate everything about it!"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "You are stupid and worthless"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Shut up you moron, nobody cares about your opinion"}'
```
### Clean Examples
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Thank you for the wonderful service"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "I absolutely love this product!"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "The delivery was fast and the quality exceeded my expectations."}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Great customer support, very helpful team."}'
```
---
## Arabic Test Cases
### Toxic Examples (Arabic)
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "أنت حيوان قذر و غبي يجب أن تموت"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "اخرس يا حقير، لا أحد يهتم برأيك"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "أنت غبي جداً ولا تستحق العيش"}'
```
### Clean Examples (Arabic)
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "شكراً لكم على الخدمة الممتازة"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "أعجبني المنتج كثيراً، الجودة ممتازة"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "التوصيل كان سريعاً والخدمة رائعة"}'
```
---
## French Test Cases
### Toxic Examples (French)
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Tu es un sale idiot, je vais te tuer espèce de merde"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Ferme-la, espèce de débile mental"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Tu ne vaux rien, dégage!"}'
```
### Clean Examples (French)
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Merci beaucoup pour votre aide"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Service excellent, je recommande!"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "La livraison était rapide et le produit conforme à la description."}'
```
---
## Italian Test Cases
### Toxic Examples (Italian)
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Sei uno stupido e non vali niente"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Stai zitto, idiota! Nessuno ti vuole qui"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Sei un fallito totale, vattene via"}'
```
### Clean Examples (Italian)
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Grazie mille per il vostro ottimo servizio"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Prodotto eccellente, consegna veloce!"}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Sono molto soddisfatto del servizio clienti."}'
```
---
## Edge Cases
### Short Text
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "ok"}'
```
### Mixed Language
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hello, شكراً for your help"}'
```
### Numbers and Special Characters
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Order #12345 received. Rating: 5/5 stars!"}'
```
### Negative but Non-Toxic Feedback
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "I am disappointed with the late delivery. Please improve."}'
```
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "The product did not meet my expectations. I would like a refund."}'
```
---
## Error Cases
### Missing API Key
```bash
curl -X POST "$API_URL" \
-H "Content-Type: application/json" \
-d '{"text": "test"}'
```
**Expected Response:** `403 Forbidden`
### Invalid API Key
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: wrong-key" \
-H "Content-Type: application/json" \
-d '{"text": "test"}'
```
**Expected Response:** `403 Forbidden`
### Empty Text
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": ""}'
```
**Expected Response:** `422 Unprocessable Entity`
### Text Too Long (>5000 chars)
```bash
curl -X POST "$API_URL" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d "{\"text\": \"$(python -c 'print("x" * 5001)')\"}"
```
**Expected Response:** `422 Unprocessable Entity`
---
## Python Test Script
```python
import requests
API_URL = "http://127.0.0.1:8000/api/v1/moderate"
API_KEY = "your-api-key-here"
test_cases = [
("en", True, "You are an idiot and your family should leave"),
("en", False, "Thank you for the wonderful service"),
("ar", True, "أنت حيوان قذر و غبي يجب أن تموت"),
("ar", False, "شكراً لكم على الخدمة الممتازة"),
("fr", True, "Tu es un sale idiot, je vais te tuer espèce de merde"),
("fr", False, "Merci beaucoup pour votre aide"),
("it", True, "Sei uno stupido e non vali niente"),
("it", False, "Grazie mille per il vostro ottimo servizio"),
]
headers = {"X-API-Key": API_KEY}
for lang, expected_toxic, text in test_cases:
r = requests.post(API_URL, json={"text": text}, headers=headers)
data = r.json()
flag = "FAIL" if data["has_bad_words"] != expected_toxic else "PASS"
print(f"[{flag}] {lang.upper()} - Expected toxic={expected_toxic}, Got: {data}")
```
---
## Expected Response Format
```json
{
"has_bad_words": true,
"confidence": 0.9812,
"label": "toxic",
"detected_language": "en",
"llm_verified": false
}
```
| Field | Type | Description |
|-------|------|-------------|
| `has_bad_words` | boolean | True if text is toxic (above threshold) |
| `confidence` | float | Toxicity probability (0.0 - 1.0) |
| `label` | string | Raw model label (`toxic`/`not_toxic` or `HATE`/`NON_HATE`) |
| `detected_language` | string | ISO 639-1 code (`en`, `ar`, `fr`, `it`, `unknown`) |
| `llm_verified` | boolean | True if LLM verification was used |