+{% endif %}
+
+{% block content %} {% endblock %}
diff --git a/example/urls.py b/example/urls.py
index 5a9bae8..b5bee8e 100644
--- a/example/urls.py
+++ b/example/urls.py
@@ -6,7 +6,7 @@ from django.conf.urls.defaults import *
urlpatterns = patterns('',
# Example:
- # (r'^example/', include('example.foo.urls')),
+ (r'^wiki/', include('markupwiki.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
diff --git a/markupwiki/tests.py b/markupwiki/tests.py
index 3d3a9c7..963b99c 100644
--- a/markupwiki/tests.py
+++ b/markupwiki/tests.py
@@ -125,9 +125,9 @@ class WikifyTests(TestCase):
wikify_markup_wrapper(wrapped_upper_filter))
-class ViewArticleTests(TestCase):
+class ViewTestsBase(TestCase):
- urls = 'markupwiki.urls'
+ urls = 'example.urls'
def setUp(self):
self.admin = User.objects.create_superuser('admin', 'admin@admin.com',
@@ -148,6 +148,8 @@ class ViewArticleTests(TestCase):
author=self.frank,
number=2,
body='this is the final update')
+
+ # article with space in title
self.two_word_article = Article.objects.create(title='two_words',
creator=self.admin)
ArticleVersion.objects.create(article=self.two_word_article,
@@ -155,52 +157,173 @@ class ViewArticleTests(TestCase):
number=0,
body='this article title has a space')
+ # locked article
+ self.locked = Article.objects.create(title='locked', creator=self.admin,
+ status=LOCKED)
+ ArticleVersion.objects.create(article=self.locked, author=self.frank,
+ number=0, body='lockdown')
+
+ # clear cache at start of every test
+ cache.clear()
+
+
+ def login_as_user(self):
+ self.client.login(username='frank', password='password')
+
+ def login_as_admin(self):
+ self.client.login(username='admin', password='password')
+
+
+class ViewArticleTests(ViewTestsBase):
def test_normal(self):
''' test accessing an article without a version specified '''
- resp = self.client.get('/test/')
+ resp = self.client.get('/wiki/test/')
self.assertContains(resp, 'this is the final update')
def test_specific_version(self):
''' test accessing a specific version of an article '''
- resp = self.client.get('/test/history/1/')
+ resp = self.client.get('/wiki/test/history/1/')
self.assertContains(resp, 'this is an update')
def test_name_with_spaces(self):
''' test that a name with spaces is properly converted into a name with underscores '''
- resp = self.client.get('/two words/')
- self.assertRedirects(resp, '/two_words/', status_code=301)
+ resp = self.client.get('/wiki/two words/')
+ self.assertRedirects(resp, '/wiki/two_words/', status_code=301)
def test_redirect(self):
''' test that a 302 is given for any article with a redirect_to '''
redirect = Article.objects.create(title='redirect', creator=self.admin,
redirect_to=self.test_article)
- resp = self.client.get('/redirect/')
- self.assertRedirects(resp, '/test/', status_code=302)
+ resp = self.client.get('/wiki/redirect/')
+ self.assertRedirects(resp, '/wiki/test/', status_code=302)
def test_missing_edit(self):
''' test that a 302 is given to the edit page if CREATE_MISSING_ARTICLE is True '''
views.CREATE_MISSING_ARTICLE = True
- self.client.login(username='frank', password='password')
- resp = self.client.get('/newpage/')
- self.assertRedirects(resp, '/newpage/edit/', status_code=302)
+ self.login_as_user()
+ resp = self.client.get('/wiki/newpage/')
+ self.assertRedirects(resp, '/wiki/newpage/edit/', status_code=302)
def test_missing_404(self):
''' test that a 404 is given if CREATE_MISSING_ARTICLE is False '''
views.CREATE_MISSING_ARTICLE = False
- self.client.login(username='frank', password='password')
- resp = self.client.get('/newpage/')
+ self.login_as_user()
+ resp = self.client.get('/wiki/newpage/')
self.assertContains(resp, '', status_code=404)
def test_staff_forms(self):
''' ensure that only admins can see the admin form '''
# make sure a normal user doesn't see the admin form
- self.client.login(username='frank', password='password')
- resp = self.client.get('/test/')
+ self.login_as_user()
+ resp = self.client.get('/wiki/test/')
self.assertNotContains(resp, '