File tree Expand file tree Collapse file tree 3 files changed +21
-19
lines changed Expand file tree Collapse file tree 3 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 1
- from django .shortcuts import render
1
+ from django .http import JsonResponse
2
2
3
- # Create your views here.
3
+ def index (request ):
4
+ return JsonResponse ({"hello" : "world" })
Original file line number Diff line number Diff line change 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
- """
17
1
from django .contrib import admin
18
2
from django .urls import path
19
3
4
+ from core .views import index
5
+
20
6
urlpatterns = [
21
7
path ('admin/' , admin .site .urls ),
8
+ path ('' , index ),
22
9
]
Original file line number Diff line number Diff line change 1
1
"""
2
2
This file is currently used to test the test harness.
3
3
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
+
5
11
"""
6
12
7
13
from django .contrib .auth .models import User
@@ -14,3 +20,11 @@ def test_database_sanity_check():
14
20
15
21
assert u .id
16
22
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"
You can’t perform that action at this time.
0 commit comments