Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started to clean up views and added a test for the submit FAQ view.
- Loading branch information
Showing
8 changed files
with
84 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from __future__ import absolute_import | ||
|
||
from .test_views import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
404 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
import django.test | ||
from django.conf import settings | ||
from ..models import Topic, Question | ||
|
||
class FAQViewTests(django.test.TestCase): | ||
urls = 'faq.urls' | ||
|
||
def setUp(self): | ||
self.topic = Topic.objects.create(name='T', slug='t') | ||
|
||
# Make some test templates available. | ||
self._oldtd = settings.TEMPLATE_DIRS | ||
settings.TEMPLATE_DIRS = [os.path.join(os.path.dirname(__file__), 'templates')] | ||
|
||
def tearDown(self): | ||
settings.TEMPLATE_DIRS = self._oldtd | ||
|
||
def test_submit_faq_view(self): | ||
data = { | ||
'topic': str(self.topic.pk), | ||
'question': 'What is your favorite color?', | ||
'answer': 'Blue. I mean red. I mean *AAAAHHHHH....*', | ||
} | ||
response = self.client.post('/submit/', data) | ||
# self.assertRedirects(response, "/what-is-your-favorite-color/") | ||
self.assert_( | ||
Question.objects.filter(text=data['question']).exists(), | ||
"Expected question object wasn't created." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
from django.conf.urls.defaults import * | ||
from django.contrib import admin | ||
from faq.views import faq_list_by_group, submit_faq | ||
from __future__ import absolute_import | ||
|
||
admin.autodiscover() | ||
from django.conf.urls.defaults import * | ||
from . import views as faq_views | ||
|
||
urlpatterns = patterns('', | ||
|
||
url ( | ||
r'^$', | ||
faq_list_by_group, | ||
name = 'faq', | ||
url(regex = r'^$', | ||
view = faq_views.question_list, | ||
name = 'faq_question_list', | ||
), | ||
url ( | ||
r'^submit_faq/$', | ||
submit_faq, | ||
{'success_url': '/faq/'}, | ||
name = 'submit', | ||
url(regex = r'^submit/$', | ||
view = faq_views.submit_faq, | ||
name = 'faq_submit', | ||
), | ||
) | ||
|
||
url(regex = r'^(?P<slug>[\w-]+)/$', | ||
view = faq_views.question_detail, | ||
name = 'faq_question_detail', | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters