First, you just have to create a virtual environment and install dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Once that's done, you'll need to run migrations locally and create a super user:
python manage.py migrate
python manage.py createsuperuser
Use "moe" for the username and "password" for the password.
python manage.py runserver
Once the application is running:
- Visit http://localhost:8000/devices/123123 -- you should see a "Device not found" message.
- Run the following CURL command:
curl -X POST http://localhost:8000/devices/send \
-u moe:password \
-H "Content-Type: application/json" \
-d '{"fCnt": 100, "data": "AQ==", "devEUI": "123123"}'
- Refresh the page at http://localhost:8000/devices/123123 and you will see a single payload, and the device in a "passing" state.
- Run the following CURL command:
curl -X POST http://localhost:8000/devices/send \
-u moe:password \
-H "Content-Type: application/json" \
-d '{"fCnt": 101, "data": "AA==", "devEUI": "123123"}'
- Refresh the page at http://localhost:8000/devices/123123 and you will see a second payload, and the device in a "failing" state.
- You can repeat any of the above CURL commands to test that the uniqueness of
fCnt
is honored. You should receive a 400 status code.