Update tests
This commit is contained in:
parent
f7c0080838
commit
332b5446c6
4 changed files with 30 additions and 9 deletions
|
@ -1,13 +1,14 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
import os.path
|
import os.path
|
||||||
from django_dbq.models import Job
|
|
||||||
from . import jobs
|
from . import jobs
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
PATH = os.path.dirname(os.path.abspath(__file__))
|
PATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
MockJob = namedtuple('MockJob', {'workspace': {}})
|
|
||||||
|
MockJob = namedtuple('MockJob', {'workspace': {}})
|
||||||
|
|
||||||
|
|
||||||
class WorkerTestCase(TestCase):
|
class WorkerTestCase(TestCase):
|
||||||
def test_email_error(self):
|
def test_email_error(self):
|
||||||
|
|
19
project/pages/tests.py
Normal file
19
project/pages/tests.py
Normal 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)
|
|
@ -1,5 +1,5 @@
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import url
|
||||||
from .views import page_view, index_view, AboutView
|
from .views import page_view, AboutView
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
import os.path
|
import os.path
|
||||||
|
from django.views.generic import FormView
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse, Http404
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from .utils import get_context, parse_content, get_title_from_markdown
|
from .utils import get_context, parse_content, get_title_from_markdown
|
||||||
|
from project.common.forms import ContactForm
|
||||||
|
|
||||||
|
|
||||||
def page_view(request, path):
|
def page_view(request, path):
|
||||||
template = None
|
template = None
|
||||||
|
if path.endswith('/'):
|
||||||
|
path = path[:-1]
|
||||||
|
|
||||||
if os.path.isdir(os.path.join(settings.BASE_DIR, 'templates', path)):
|
if os.path.isdir(os.path.join(settings.BASE_DIR, 'templates', path)):
|
||||||
path = os.path.join(path, 'index')
|
path = os.path.join(path, 'index')
|
||||||
for extension in ['md', 'html']:
|
for extension in ['md', 'html']:
|
||||||
|
@ -27,10 +32,6 @@ def page_view(request, path):
|
||||||
return HttpResponse(parsed_content)
|
return HttpResponse(parsed_content)
|
||||||
|
|
||||||
|
|
||||||
def index_view(request):
|
|
||||||
return page_view(request, 'index')
|
|
||||||
|
|
||||||
|
|
||||||
class AboutView(FormView):
|
class AboutView(FormView):
|
||||||
template_name = 'about/index.html'
|
template_name = 'about/index.html'
|
||||||
success_url = '/about/?sent'
|
success_url = '/about/?sent'
|
||||||
|
|
Reference in a new issue