Firstly, clone the repository:
git clone https://github.com/CrazyProger1/TestTask-dZENcode
Change directory to server:
cd ./TestTask-dZENcode/server/
Use docker-compose
:
docker-compose -f compose.dev.yaml up
Create superuser:
docker-compose -f compose.dev.yaml run --entrypoint "python manage.py createsuperuser" web
See swagger docs.
Supported entities:
Where pk
- comment id
Supported events:
comments.create
- create commentcomments.read
- get paginated comment listcomments.replies.read
- get paginated list of comment-replies
Create comment schema:
{
"type": "comments.create",
"data": {
"text": "comment text",
// required, comment text
"reply_to": null
// by default, parent comment id
}
}
Successful response schema:
{
"type": "comments.create",
"success": true,
"data": {
"id": 0,
"likes_count": 0,
"dislikes_count": 0,
"text": "test comment",
"created_at": "datatime",
"has_attachment": false,
"user": 0,
"reply_to": null
}
}
Read comments schema:
{
"type": "comments.read",
"data": {
"order_by": [
"-created_at"
// by default, order by creation date
],
"filters": {
"user": 0,
// filter by user id
"created_at": "",
// filter by creation date
"has_attachment": false
// filter by attachments
},
"limit": 25,
// by default, pagination limit
"offset": 0
// by default, pagination offset
}
}
Successful response schema:
{
"type": "comments.read",
"success": true,
"data": {
"count": 0,
// all results count
"results": [
// paginated results
{
"id": 0,
"likes_count": 0,
"dislikes_count": 0,
"text": "test comment",
"created_at": "datatime",
"has_attachment": false,
"user": 0,
"reply_to": null
}
]
}
}
Read replies schema:
{
"type": "comments.replies.read",
"data": {
"order_by": [
"-created_at"
// by default, order by creation date
],
"filters": {
"reply_to": 0,
// filter by parent comment id
"user": 0,
// filter by user id
"created_at": "",
// filter by creation date
"has_attachment": false
// filter by attachments,
},
"limit": 25,
// by default, pagination limit
"offset": 0
// by default, pagination offset
}
}
Successful response schema:
{
"type": "comments.replies.read",
"success": true,
"data": {
"count": 0,
// all results count
"results": [
// paginated results
{
"id": 0,
"likes_count": 0,
"dislikes_count": 0,
"text": "test comment",
"created_at": "datatime",
"has_attachment": false,
"user": 0,
"reply_to": 0
}
]
}
}
Using docker-compose
:
docker-compose -f compose.dev.yaml run --entrypoint "python manage.py test" web
OR
Note: you need to have all requirements installed & environment variables specified (in development.env).
Using terminal:
python mange.py test
# or using Make
make test
make coverage-report