This commit is contained in:
Paul Craciunoiu 2011-02-23 16:11:51 -08:00
Родитель 4d9aae8e76
Коммит 9ae7975462
2 изменённых файлов: 81 добавлений и 3 удалений

Просмотреть файл

@ -17,9 +17,9 @@ from questions.models import Question, Answer, QuestionVote
from questions.tests import TestCaseBase, TaggingTestCaseBase, tags_eq
from questions.views import UNAPPROVED_TAG, NO_TAG
from questions.tasks import cache_top_contributors
from sumo.urlresolvers import reverse
from sumo.helpers import urlparams
from sumo.tests import get, post, attrs_eq
from sumo.urlresolvers import reverse
from upload.models import ImageAttachment
from users.models import RegistrationProfile
@ -1013,8 +1013,8 @@ class AAQTemplateTestCase(TestCaseBase):
'ff_version': '3.6.6',
'os': 'Intel Mac OS X 10.6',
'plugins': '* Shockwave Flash 10.1 r53',
'useragent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X ' +
'10.6; en-US; rv:1.9.2.6) Gecko/20100625 ' +
'useragent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X '
'10.6; en-US; rv:1.9.2.6) Gecko/20100625 '
'Firefox/3.6.6'}
def setUp(self):

Просмотреть файл

@ -0,0 +1,78 @@
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
import mock
from nose.tools import eq_
from questions.models import Question
from sumo.helpers import urlparams
from sumo.urlresolvers import reverse
from sumo.tests import MobileTestCase, LocalizingClient
class MobileAAQTests(MobileTestCase):
fixtures = ['users.json', 'questions.json']
data = {'title': 'A test question',
'content': 'I have this question that I hope...',
'sites_affected': 'http://example.com',
'ff_version': '3.6.6',
'os': 'Intel Mac OS X 10.6',
'plugins': '* Shockwave Flash 10.1 r53',
'useragent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X '
'10.6; en-US; rv:1.9.2.6) Gecko/20100625 '
'Firefox/3.6.6'}
def setUp(self):
self.client = LocalizingClient()
super(MobileAAQTests, self).setUp()
def _new_question(self, post_it=False):
"""Post a new question and return the response."""
url = urlparams(reverse('questions.new_question'),
product='desktop', category='d1',
search='A test question', showform=1)
if post_it:
return self.client.post(url, self.data, follow=True)
return self.client.get(url, follow=True)
def test_logged_out(self):
"""New question is posted through mobile."""
response = self._new_question()
eq_(200, response.status_code)
self.assertTemplateUsed(response,
'questions/mobile/new_question_login.html')
@mock.patch_object(Site.objects, 'get_current')
def test_logged_in_get(self, get_current):
"""New question is posted through mobile."""
get_current.return_value.domain = 'testserver'
self.client.login(username='jsocol', password='testpass')
response = self._new_question()
eq_(200, response.status_code)
self.assertTemplateUsed(response,
'questions/mobile/new_question.html')
@mock.patch_object(Site.objects, 'get_current')
def test_logged_in_post(self, get_current):
"""New question is posted through mobile."""
get_current.return_value.domain = 'testserver'
self.client.login(username='jsocol', password='testpass')
response = self._new_question(post_it=True)
eq_(200, response.status_code)
assert Question.objects.filter(title='A test question')
@mock.patch_object(Site.objects, 'get_current')
def test_aaq_new_question_inactive(self, get_current):
"""New question is posted through mobile."""
get_current.return_value.domain = 'testserver'
# Log in first.
self.client.login(username='jsocol', password='testpass')
# Then become inactive.
u = User.objects.get(username='jsocol')
u.is_active = False
u.save()
response = self._new_question(post_it=True)
eq_(200, response.status_code)
self.assertTemplateUsed(response,
'questions/mobile/confirm_email.html')