Initial commit

This commit is contained in:
2021-03-23 21:25:45 +01:00
commit 46bb3be3ca
23 changed files with 516 additions and 0 deletions

View File

3
web/palindromes/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
web/palindromes/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class PalindromesConfig(AppConfig):
name = 'palindromes'

View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

19
web/palindromes/tests.py Normal file
View File

@ -0,0 +1,19 @@
from django.urls import resolve
from django.test import TestCase
from django.http import HttpRequest
from palindromes.views import caculate_palindromes
class HomePageTest(TestCase):
def test_root_url_resolves_to_calculate_palindrome_view(self):
found = resolve('/')
self.assertEqual(found.func, caculate_palindromes)
def test_home_page_returns_correct_html(self):
request = HttpRequest()
response = caculate_palindromes(request)
html = response.content.decode('utf8')
self.assertTrue(html.startswith('<html>'))
self.assertIn('<title>Palindromes!</title>', html)
self.assertTrue(html.endswith('</html>'))

5
web/palindromes/views.py Normal file
View File

@ -0,0 +1,5 @@
from django.http import HttpResponse
def caculate_palindromes(request):
return HttpResponse('<html><title>Palindromes!</title></html>')