diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-05-29 23:52:33 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-05-29 23:52:33 -0400 |
commit | 714311f3d883c6589d278e3e2a05bd1583e4b96d (patch) | |
tree | 5f6e11a0fc94f7b0072b47ee60eab1f8a4007541 | |
parent | 43e656cd594ee1debbdae924e0badd1b51066f63 (diff) | |
download | askbot-714311f3d883c6589d278e3e2a05bd1583e4b96d.tar.gz askbot-714311f3d883c6589d278e3e2a05bd1583e4b96d.tar.bz2 askbot-714311f3d883c6589d278e3e2a05bd1583e4b96d.zip |
added some more unit tests on reader urls
-rw-r--r-- | forum/tests.py | 61 | ||||
-rw-r--r-- | forum/urls.py | 4 |
2 files changed, 50 insertions, 15 deletions
diff --git a/forum/tests.py b/forum/tests.py index 72dd4b98..8419dd86 100644 --- a/forum/tests.py +++ b/forum/tests.py @@ -5,9 +5,10 @@ import datetime from django.core.urlresolvers import reverse class AnonymousVisitorTests(TestCase): - fixtures = ['forum/fixtures/dump1.json',] + fixtures = ['forum/fixtures/full_dump.json',] def test_index(self): + #todo: merge this with all reader url tests print 'trying to reverse index' response = self.client.get(reverse('index'), follow=True) self.assertEqual(response.status_code, 200) @@ -19,25 +20,61 @@ class AnonymousVisitorTests(TestCase): print 'index works' def test_reader_urls(self): - def try_url(url_name, status_code, template = None, kwargs={}): + #todo: test redirects better + def try_url( + url_name, status_code=200, template=None, + kwargs={}, redirect_url=None, follow=False + ): url = reverse(url_name, kwargs = kwargs) print 'getting url %s' % url - r = self.client.get(url) + r = self.client.get(url, follow=follow) + if hasattr(self.client, 'redirect_chain'): + print self.client.redirect_chain self.assertEqual(r.status_code, status_code) if template: #asuming that there is more than one template self.assertEqual(r.template[0].name, template) - print 'entering try urls' - try_url('sitemap', 200) - try_url('about', 200, template='about.html') - try_url('privacy', 200, template='privacy.html') - try_url('logout', 200, template='logout.html') - try_url('user_signin', 200, template='authopenid/signin.html') + try_url('sitemap') + try_url('about', template='about.html') + try_url('privacy', template='privacy.html') + try_url('logout', template='logout.html') + try_url('user_signin', template='authopenid/signin.html') + try_url('tags', template='tags.html') + try_url('badges', template='badges.html') try_url( 'answer_revisions', - 200, template='revisions_answer.html', kwargs={'id':38} ) - print 'urls are fine' - + try_url( + 'questions', + template='questions.html' + ) + try_url( + 'question', + kwargs={'id':1}, + ) + try_url( + 'question', + kwargs={'id':2}, + ) + try_url( + 'question', + kwargs={'id':3}, + ) + try_url( + 'question_revisions', + kwargs={'id':17}, + template='revisions_question.html' + ) + try_url( + 'users', + template='users.html' + ) + try_url( + 'edit_user', + template='authopenid/signin.html', + kwargs={'id':4}, + status_code=200, + follow=True, + ) diff --git a/forum/urls.py b/forum/urls.py index 8274b45b..944732e5 100644 --- a/forum/urls.py +++ b/forum/urls.py @@ -39,7 +39,6 @@ urlpatterns = patterns('', url(r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('revisions/')), app.readers.answer_revisions, name='answer_revisions'), url(r'^%s$' % _('questions/'), app.readers.questions, name='questions'), url(r'^%s%s$' % (_('questions/'), _('ask/')), app.writers.ask, name='ask'), - url(r'^%s%s$' % (_('questions/'), _('unanswered/')), app.readers.unanswered, name='unanswered'), url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('edit/')), app.writers.edit_question, name='edit_question'), url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('close/')), app.commands.close, name='close'), url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('reopen/')), app.commands.reopen, name='reopen'), @@ -59,7 +58,6 @@ urlpatterns = patterns('', #place general question item in the end of other operations url(r'^%s(?P<id>\d+)/' % _('question/'), app.readers.question, name='question'), url(r'^%s$' % _('tags/'), app.readers.tags, name='tags'), - url(r'^%s(?P<tag>[^/]+)/$' % _('tags/'), app.readers.tag, name='tag_questions'), url(r'^%s%s(?P<tag>[^/]+)/$' % (_('mark-tag/'),_('interesting/')), app.commands.mark_tag, \ kwargs={'reason':'good','action':'add'}, \ @@ -75,6 +73,7 @@ urlpatterns = patterns('', url(r'^%s$' % _('users/'),app.users.users, name='users'), url(r'^%s(?P<id>\d+)/$' % _('moderate-user/'), app.users.moderate_user, name='moderate_user'), + #todo: rename as user_edit, b/c that's how template is named url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'), url(r'^%s(?P<id>\d+)/(?P<slug>.+)/$' % _('users/'), app.users.user, name='user_profile'), url(r'^%s$' % _('badges/'),app.meta.badges, name='badges'), @@ -85,7 +84,6 @@ urlpatterns = patterns('', url(r'^%s$' % _('upload/'), app.writers.upload, name='upload'), url(r'^%s$' % _('search/'), app.readers.search, name='search'), url(r'^%s$' % _('feedback/'), app.meta.feedback, name='feedback'), - (r'^%sfb/' % _('account/'), include('fbconnect.urls')), (r'^%s' % _('account/'), include('django_authopenid.urls')), (r'^i18n/', include('django.conf.urls.i18n')), |