to select ↑↓ to navigate
CAMS Biometric Integration

CAMS Biometric Integration

15. Testing the Integration

15.0 End-to-End Test

The simplest test is a live punch:

  1. Ensure configuration is complete (AuthToken, Callback URL, Employee biometric ID mapping, Shift Assignment)
  2. Have a registered employee punch the device
  3. Within 10 seconds, navigate to HR > Employee Checkin and check for a new record

15.1 Manual API Testing with curl

You can simulate a CAMS callback using curl to verify your endpoint is reachable:

curl -X POST \
  https://yoursite.erpnext.com/api/method/navari_cams_biometric.cams_biometric.controllers.cams_call.attendance \
  -H "Content-Type: application/json" \
  -d '{
    "RealTime": {
      "OperationID": "test001",
      "LabelName": "Test Gate",
      "SerialNumber": "TEST123",
      "PunchLog": {
        "Type": "CheckIn",
        "InputType": "Fingerprint",
        "UserId": "EMP-0001",
        "LogTime": "2024-09-17 08:00:00 GMT +0300"
      },
      "AuthToken": "your-auth-token-here",
      "Time": "2024-09-17 05:00:00 GMT +0000"
    }
  }'

Expected response: {"status": "done"}

15.2 Manual API Testing with Postman

  1. Create a new POST request in Postman
  2. URL: https://yoursite.erpnext.com/api/method/navari_cams_biometric.cams_biometric.controllers.cams_call.attendance
  3. Body: raw to JSON
  4. Paste the test JSON (as above)
  5. Send and inspect the response and then check Employee Checkin in FrappeHR

15.3 Unit Tests

The project includes a test suite for cams_call.py. Tests use FrappeTestCase for proper Frappe framework integration. The tests cover:

  • Empty request body handling
  • Invalid JSON input
  • Processing RealTime attendance logs
  • Processing PunchLog batch entries
  • update_last_sync_time() function
  • Integration-style tests that verify actual database insertion of Employee Checkin records

To run tests:

bench --site yoursite.example.com run-tests --app navari_cams_biometric
Last updated 4 days ago
Was this helpful?
Thanks!