forked from mozilla/kitsune
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Craciunoiu
committed
Feb 24, 2011
1 parent
4d9aae8
commit 9ae7975
Showing
2 changed files
with
81 additions
and
3 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 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,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') |