From 59dcea046de9acb37619a95bf3e36573fd5e6b39 Mon Sep 17 00:00:00 2001 From: lpmi-13 Date: Mon, 19 Mar 2018 22:04:23 +0000 Subject: [PATCH] update urls and add test cases --- oxfordpython/tests.py | 17 +++++++++++++++++ oxfordpython/urls.py | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 oxfordpython/tests.py diff --git a/oxfordpython/tests.py b/oxfordpython/tests.py new file mode 100644 index 0000000..d8ed1e3 --- /dev/null +++ b/oxfordpython/tests.py @@ -0,0 +1,17 @@ +from django.test import Client +from django.test import TestCase + +class UrlRouteTests(TestCase): + + def setup(self): + self.client = Client() + + def test_home_page_is_accessible(self): + # tests that '' response is 200 + response = self.client.get('') + self.assertIs(response.status_code, 200) + + def test_admin_page_is_accessible(self): + # tests that 'admin/' response is 200 + response = self.client.get('admin/') + self.assertIs(response.status_code, 200) diff --git a/oxfordpython/urls.py b/oxfordpython/urls.py index 08d2709..8a9c343 100644 --- a/oxfordpython/urls.py +++ b/oxfordpython/urls.py @@ -1,9 +1,9 @@ -from django.conf.urls import url +from django.urls import path from django.contrib import admin from .main import views as main_views urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'^$', main_views.HomeView.as_view(), name='home'), + path('admin/', admin.site.urls), + path('', main_views.HomeView.as_view(), name='home'), ]