Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
Добавил healthcheck адрес (#4) (#11)
Browse files Browse the repository at this point in the history
* Add healthcheck uri (#4)

* Add pytest-django

* Fix tests

* Add healthcheck tests
  • Loading branch information
cofob committed Feb 20, 2022
1 parent 9392325 commit 628c2bf
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
10 changes: 8 additions & 2 deletions autodonate/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from autodonate.views import healthcheck


urlpatterns = [path("admin/", admin.site.urls)]
urlpatterns = [
path("admin/", admin.site.urls),
path("api/health", healthcheck, name="healthcheck"),
]


default_imports = settings.CONFIG.get(
Expand All @@ -43,4 +47,6 @@
if settings.CONFIG.get("DEBUG", True) and settings.CONFIG.get(
"DEBUG_STATICFILES_SERVER", True
):
urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns + static(
settings.STATIC_URL, document_root=settings.STATIC_ROOT
)
5 changes: 5 additions & 0 deletions autodonate/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.http.response import HttpResponse


def healthcheck(request):
return HttpResponse(b"ok")
29 changes: 24 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ safety = "^1.10"
pytest = "^7.0"
pytest-cov = "^3.0"
pytest-randomly = "^3.11"
pytest-django = "^4.5.2"

sphinx = "^4.4"
sphinx-autodoc-typehints = "^1.17"
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ addopts =
--cov-report=xml
--cov-branch

DJANGO_SETTINGS_MODULE = autodonate.settings


[mypy]
# mypy configurations: http://bit.ly/2zEl9WI
Expand Down
3 changes: 2 additions & 1 deletion tests/models/test_payments.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from autodonate.lib.models import *
from os import system
import pytest


@pytest.mark.django_db(transaction=True)
def test_donation():
i = Item(
currency=0,
Expand Down
2 changes: 2 additions & 0 deletions tests/views/test_healthcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_heath(client):
assert client.get("/api/health").content == b"ok"

0 comments on commit 628c2bf

Please sign in to comment.