Skip to content

Commit 89a935a

Browse files
committed
add basic view/endpoint
1 parent 2129f25 commit 89a935a

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

intbot/core/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
from django.shortcuts import render
1+
from django.http import JsonResponse
22

3-
# Create your views here.
3+
def index(request):
4+
return JsonResponse({"hello": "world"})

intbot/intbot/urls.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
"""
2-
URL configuration for intbot project.
3-
4-
The `urlpatterns` list routes URLs to views. For more information please see:
5-
https://docs.djangoproject.com/en/5.1/topics/http/urls/
6-
Examples:
7-
Function views
8-
1. Add an import: from my_app import views
9-
2. Add a URL to urlpatterns: path('', views.home, name='home')
10-
Class-based views
11-
1. Add an import: from other_app.views import Home
12-
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
13-
Including another URLconf
14-
1. Import the include() function: from django.urls import include, path
15-
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16-
"""
171
from django.contrib import admin
182
from django.urls import path
193

4+
from core.views import index
5+
206
urlpatterns = [
217
path('admin/', admin.site.urls),
8+
path('', index),
229
]

intbot/tests/test_basic.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
"""
22
This file is currently used to test the test harness.
33
4-
It checks whether the tests are running, can access databse, etc
4+
It checks whether the tests
5+
* are running
6+
* can access databse
7+
* can reach the views
8+
* can authenticate,
9+
* etc
10+
511
"""
612

713
from django.contrib.auth.models import User
@@ -14,3 +20,11 @@ def test_database_sanity_check():
1420

1521
assert u.id
1622
assert u.username == "Poirot"
23+
24+
25+
def test_http_sanity_check(client):
26+
response = client.get("/")
27+
28+
assert response.status_code == 200
29+
assert response["Content-Type"] == "application/json"
30+
assert response.json()["hello"] == "world"

0 commit comments

Comments
 (0)