1
Fork 0

Update tests

This commit is contained in:
Jake Howard 2016-04-05 22:37:37 +01:00
parent f7c0080838
commit 332b5446c6
4 changed files with 30 additions and 9 deletions

View file

@ -1,14 +1,15 @@
from django.test import TestCase
from django.core.urlresolvers import reverse
import os.path
from django_dbq.models import Job
from . import jobs
from collections import namedtuple
PATH = os.path.dirname(os.path.abspath(__file__))
MockJob = namedtuple('MockJob', {'workspace': {}})
class WorkerTestCase(TestCase):
def test_email_error(self):
data = {

19
project/pages/tests.py Normal file
View file

@ -0,0 +1,19 @@
from django.test import TestCase
from django.conf import settings
import os.path
from glob import glob
class PagesTestCase(TestCase):
def setUp(self):
directories = glob(os.path.join(settings.BASE_DIR, 'templates') + '/**/*.*')
self.urls = []
for directory in directories:
if 'email' in directory or 'blog' in directory:
continue
self.urls.append(directory.replace(os.path.join(settings.BASE_DIR, 'templates'), '').split('.')[0].replace('index', ''))
def test_pages_accessable(self):
for path in self.urls:
response = self.client.get(path)
self.assertEqual(response.status_code, 200)

View file

@ -1,5 +1,5 @@
from django.conf.urls import include, url
from .views import page_view, index_view, AboutView
from django.conf.urls import url
from .views import page_view, AboutView
urlpatterns = [

View file

@ -1,12 +1,17 @@
import os.path
from django.views.generic import FormView
from django.conf import settings
from django.http import HttpResponse, Http404
from django.template.loader import get_template
from .utils import get_context, parse_content, get_title_from_markdown
from project.common.forms import ContactForm
def page_view(request, path):
template = None
if path.endswith('/'):
path = path[:-1]
if os.path.isdir(os.path.join(settings.BASE_DIR, 'templates', path)):
path = os.path.join(path, 'index')
for extension in ['md', 'html']:
@ -27,10 +32,6 @@ def page_view(request, path):
return HttpResponse(parsed_content)
def index_view(request):
return page_view(request, 'index')
class AboutView(FormView):
template_name = 'about/index.html'
success_url = '/about/?sent'