To run the example do the following steps:
$ mkdir bonos
$ cd bonos/Tested with:
$ python -V
Python 3.5.3
$ python -V
Python 3.8.11Should work with any python version > 3.5.3
Create the virtual environment
$ python3 -m venv venvActivate the virtual environment
$ . venv/bin/activateUpgrade pip and install wheel
$ pip install --upgrade pip
$ pip install wheelClone the git repository
$ git clone https://github.com/jboadas/testbonosInstall libraries of the example
$ cd testbonos/
$ pip install -r requirements.txt Create the database
$ python manage.py migrateRun tests
$ python manage.py testCreate admin user
python manage.py createsuperuser --email admin@example.com --username adminRun the development server
$ python manage.py runserverServer will be available at: http://127.0.0.1:8000/
We can access the api using the Django interactive API explorer
Or using curl commands on the terminal:
View users
curl -H 'Accept: application/json; indent=4' -u admin:password123 http://127.0.0.1:8000/users/View bonds
curl -H 'Accept: application/json; indent=4' -u admin:password123 http://127.0.0.1:8000/bonos/Bond view detail
curl -H 'Accept: application/json; indent=4' -u admin:password123 http://127.0.0.1:8000/bonos/4/Publish bond to sell
curl -H 'Accept: application/json; indent=4' -u admin:password123 -F 'bono_name=ADMDOS' -F 'bono_number=5000' -F 'bono_price=9999.99' http://127.0.0.1:8000/bonos/Buy bond (sell user/buy user need to be differents)
curl -H 'Accept: application/json; indent=4' -u admin:password123 http://127.0.0.1:8000/bonos/4/comprabono/Get bond USD price
curl -H 'Accept: application/json; indent=4' -u admin:password123 http://127.0.0.1:8000/bonos/4/preciousd/