Tracking Service Tests
Overview
Integration tests for the tracking-service, covering positions, events, and geofences against a live service and database.
Running Tests
[!IMPORTANT] The
tracking-serviceanddb-persistercontainers must be running to ensure database tables are created.
# 1. Start services (creates tables)
make up tracking db-persister
# 2. Run tests
make test tracking
Test Flows
| Test Class | Description |
|---|---|
| TestHealth | |
test_health_check | Verify service is healthy (200 OK). |
| TestPositionFlow | Lifecycle & Permissions |
test_position_tracking_lifecycle | 1. Insert: Add mock positions (past & present). 2. Latest: Verify GET /positions returns latest.3. History: Verify GET /positions?from=... returns range.4. Security: Verify other user cannot access. 5. Delete: Verify owner can delete history. 6. Verify: Confirm deletion. |
| TestEventFlow | Events & Filtering |
test_event_lifecycle | 1. Insert: Add deviceOnline/deviceOffline events.2. List: Verify all events returned. 3. Filter: Verify type=deviceOffline filtering.4. Get: Verify single event retrieval. 5. 404: Verify nonexistent event checks. |
| TestGeofenceFlow | CRUD & Validation |
test_geofence_crud | 1. Create: Create valid CIRCLE geofence.2. List: Verify created geofence appears. 3. Update: Modify name. 4. Delete: Remove geofence. 5. Validation: Verify invalid WKT returns 400. |
Helper Functions
| Function | Type | Description |
|---|---|---|
create_user | DB | Create user directly in users table. |
create_device_for_user | DB | Create device & owner link in devices/user_device. |
insert_position | DB | Insert mock GPS data into positions. |
insert_event | DB | Insert mock event into events. |
get_positions | API | GET /positions/ details or history. |
list_events | API | GET /events/ with filters. |
create_geofence | API | POST /geofences/ with WKT. |
Permissions Tested
| Operation | Owner | Shared User | Other User |
|---|---|---|---|
| View Latest Position | ✅ | ✅ (if enabled) | ❌ |
| View Position History | ✅ | ✅ (if enabled) | ❌ |
| Delete Position History | ✅ | ❌ | ❌ |
| View Events | ✅ | ✅ (if enabled) | ❌ |
| Manage Geofences | ✅ | ❌ | ❌ |