Commit 862f75e2 authored by Xavier Calabia's avatar Xavier Calabia

finished all tests, attempted to manage static files

parent dec64e5d
Pipeline #958 failed with stages
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
<title>Detail - Cloud</title> <title>Detail - Cloud</title>
</head> </head>
<body> <body>
<img src="./cloud.png" style="width: 10vw;" /> {% load staticfiles %}
<img src="{% static 'hero/cloud.png' %}" style="width: 10vw;" />
<h1>Detail - Cloud</h1> <h1>Detail - Cloud</h1>
<dl> <dl>
<dt>Health Points</dt><dd>600</dd> <dt>Health Points</dt><dd>600</dd>
......
...@@ -5,4 +5,16 @@ from django.test import TestCase ...@@ -5,4 +5,16 @@ from django.test import TestCase
class HomePageTest(TestCase): class HomePageTest(TestCase):
def test_redirects_to_heros_template(self): def test_redirects_to_heros_template(self):
response = self.client.get('') response = self.client.get('')
self.assertRedirects(response, '/heroes') self.assertRedirects(response, '/heroes', status_code=301)
def test_heroes_page_uses_heroes_template(self):
response = self.client.get('/heroes')
self.assertTemplateUsed(response, 'heroes.html')
def test_hero_detail_pages_use_hero_templates(self):
response = self.client.get('/hero/cloud')
self.assertTemplateUsed(response, 'hero/detail_cloud.html')
response = self.client.get('/hero/sunflowey')
self.assertTemplateUsed(response, 'hero/detail_sunflowey.html')
response = self.client.get('/hero/jester')
self.assertTemplateUsed(response, 'hero/detail_jester.html')
...@@ -5,8 +5,8 @@ def heroes_page(request): ...@@ -5,8 +5,8 @@ def heroes_page(request):
return render(request, 'heroes.html') return render(request, 'heroes.html')
def redirect_to_heroes_page(request): def redirect_to_heroes_page(request):
return redirect('/heroes') return redirect('/heroes', permanent=True)
def cloud_info_page(request): def cloud_info_page(request):
return render(request, 'hero/detail_cloud.html') return render(request, 'hero/detail_cloud.html')
......
...@@ -122,4 +122,7 @@ USE_TZ = True ...@@ -122,4 +122,7 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/ # https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = 'templates/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "templates"),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment