Skip to content

Commit

Permalink
✅ added urls tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanitsky committed Jun 14, 2020
1 parent c99ccb3 commit 2c6b4e7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
1 change: 0 additions & 1 deletion github_webhooks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "github_webhooks.apps.GitHubWebhooksAppConfig"
5 changes: 0 additions & 5 deletions github_webhooks/apps.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from github_webhooks import urls

urlpatterns = [
path("github/", include(urls, namespace="github")),
path("github/webhook/receive/", include(urls, namespace="github-webhook"), name="receive"),
]
3 changes: 3 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
SECRET_KEY = "fake-key"
ROOT_URLCONF = "tests.test_app.urls"
INSTALLED_APPS = (
"github_webhooks",
)
6 changes: 6 additions & 0 deletions tests/test_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import reverse, resolve


def test_receive_url():
assert reverse("github-webhook:receive") == "/github/webhook/receive/"
assert resolve("/github/webhook/receive/").view_name == "github-webhook:receive"
10 changes: 5 additions & 5 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.test import Client
from django.urls import reverse
from django.test import RequestFactory
from github_webhooks import views


def test_github_webhook_view(client: Client):
url = reverse("github:receive")
response = client.post(url)
def test_github_webhook_view(rf: RequestFactory):
request = rf.post("/fake-url/")
response = views.GitHubWebhookView().post(request)

assert response.status_code == 200

0 comments on commit 2c6b4e7

Please sign in to comment.