Browse Source

Add empty home view, register it in urls, test

Benoît Hubert 7 years ago
parent
commit
2e2165403d
3 changed files with 11 additions and 3 deletions
  1. 3 0
      movielib/urls.py
  2. 6 3
      movies/tests.py
  3. 2 0
      movies/views.py

+ 3 - 0
movielib/urls.py

@@ -15,7 +15,10 @@ Including another URLconf
 """
 from django.contrib import admin
 from django.urls import path
+from django.conf.urls import url
+from movies import views
 
 urlpatterns = [
     path('admin/', admin.site.urls),
+    url(r'^$', views.home_page, name='home'),
 ]

+ 6 - 3
movies/tests.py

@@ -1,6 +1,9 @@
+from django.urls import resolve
 from django.test import TestCase
+from movies.views import home_page
 
-class SmokeTest(TestCase):
+class HomePageTest(TestCase):
 
-    def test_bad_maths(self):
-        self.assertEqual(1 + 1, 3)
+    def test_root_url_resolves_to_home_page_view(self):
+        found = resolve('/')
+        self.assertEqual(found.func, home_page)

+ 2 - 0
movies/views.py

@@ -1,3 +1,5 @@
 from django.shortcuts import render
 
 # Create your views here.
+def home_page():
+    pass