https://github.com/dhth/usersnack-test-case
https://github.com/dhth/usersnack-test-case
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dhth/usersnack-test-case
- Owner: dhth
- Created: 2020-05-03T23:11:45.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-22T18:58:39.000Z (almost 5 years ago)
- Last Synced: 2025-02-10T08:51:26.675Z (over 1 year ago)
- Language: Python
- Size: 656 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Usersnack
## Tech Stack
- **Django**: Backend
- **Django Rest Framework**: addons for Django
- **Postgres**: Database
## Other tools
- **Pytest**: testing framework
- **Flake8**: Linter
- **Black**: Formatter
## Live app
A live version of the service is running on Heroku here: [https://evening-scrubland-88960.herokuapp.com](https://evening-scrubland-88960.herokuapp.com/api/pizzas/). It might take a few seconds for the service to spin up after a period of inactivity.
## Local setup
- Change permissions on entrypoint.sh
```bash
chmod +x backend/app/entrypoint.sh
```
- Run containers
```
docker-compose up -d
```
## Endpoints
- `/api/pizzas/`
This endpoint is supposed to provide data for the Pizza list view.

```curl
curl --location --request GET 'http://127.0.0.1:8000/api/pizzas/'
```
- `/api/extras/`
This endpoint is supposed to provide data for the extra dropdowns.

```curl
curl --location --request GET 'http://127.0.0.1:8000/api/extras/'
```
- `/api/createorder/`
This endpoint is for creating a new order.
```curl
curl --location --request POST 'http://127.0.0.1:8000/api/createorder/' \
--header 'Content-Type: application/json' \
--data-raw '{
"base_pizza": 1,
"extras": [
{
"extra": 15,
"quantity": 1
},
{
"extra": 16,
"quantity": 5
}
],
"user_name": "Dhruv",
"user_address": "Wien"
}'
```
- `/api/orders//`
This endpoint returns the details of a specific order, including component items, and total price.
```curl
curl --location --request GET 'http://127.0.0.1:8000/api/orders/1'
```
- `/api/orders/`
This endpoint returns all orders.
```curl
curl --location --request GET 'http://127.0.0.1:8000/api/orders/'
```
## Postman
Postman collection containing the above requests can be found under the [postman](postman) directory.
## Tests
```
docker-compose exec backend pytest tests
```
## To Do
- Add Swagger documentation using [drf-yasg](https://github.com/axnsan12/drf-yasg).
- Change `item_type` (in table `FoodItem`) to a relationship instead of CharField. (done to save time).