本文整理汇总了Python中sumo.tests.LocalizingClient.get方法的典型用法代码示例。如果您正苦于以下问题:Python LocalizingClient.get方法的具体用法?Python LocalizingClient.get怎么用?Python LocalizingClient.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sumo.tests.LocalizingClient
的用法示例。
在下文中一共展示了LocalizingClient.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kumawiki_waffle_flag
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_kumawiki_waffle_flag(self):
# Turn off the new wiki for everyone
self.kumawiki_flag.everyone = False
self.kumawiki_flag.save()
client = LocalizingClient()
resp = client.get(reverse('wiki.all_documents'))
eq_(404, resp.status_code)
resp = client.get(reverse('docs'))
page = pq(resp.content)
eq_(0, page.find('#kumawiki_preview').length)
client.login(username='admin', password='testpass')
# Turn on the wiki for just superusers, ignore everyone else
self.kumawiki_flag.superusers = True
self.kumawiki_flag.everyone = None
self.kumawiki_flag.save()
resp = client.get(reverse('wiki.all_documents'))
eq_(200, resp.status_code)
resp = client.get(reverse('docs'))
page = pq(resp.content)
eq_(1, page.find('#kumawiki_preview').length)
示例2: LandingViewsTest
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
class LandingViewsTest(test_utils.TestCase):
fixtures = ['test_data.json', ]
def setUp(self):
self.client = LocalizingClient()
def test_home(self):
url = reverse('landing.views.home')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_mozilla(self):
url = reverse('landing.views.mozilla')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_web(self):
url = reverse('landing.views.web')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_search(self):
raise SkipTest('Search test disabled until we switch to kuma wiki')
url = reverse('landing.views.search')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_promote_buttons(self):
url = reverse('landing.views.promote_buttons')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
示例3: EventsViewsTest
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
class EventsViewsTest(test_utils.TestCase):
fixtures = ["devmo_calendar.json"]
def setUp(self):
self.client = LocalizingClient()
devmo_calendar_reload()
def test_events(self):
url = reverse("devmo.views.events")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_events_map_flag(self):
url = reverse("devmo.views.events")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_([], doc.find("#map_canvas"))
ok_("maps.google.com" not in r.content)
events_map_flag = Flag.objects.create(name="events_map", everyone=True)
events_map_flag.save()
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_(1, len(doc.find("#map_canvas")))
ok_("maps.google.com" in r.content)
示例4: HomeTests
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
class HomeTests(test_utils.TestCase):
def setUp(self):
self.client = LocalizingClient()
def test_social_promo(self):
url = reverse('landing.views.home')
aurora_promo, social_promo = get_promos(self.client, url)
ok_(aurora_promo)
ok_(not social_promo)
Switch.objects.create(name="social_promo", active=True)
aurora_promo, social_promo = get_promos(self.client, url)
ok_(not aurora_promo)
ok_(social_promo)
def test_google_analytics(self):
url = reverse('landing.views.home')
constance.config.GOOGLE_ANALYTICS_ACCOUNT = ''
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
ok_('var _gaq' not in r.content)
constance.config.GOOGLE_ANALYTICS_ACCOUNT = 'UA-99999999-9'
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
ok_('var _gaq' in r.content)
示例5: LandingViewsTest
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
class LandingViewsTest(test_utils.TestCase):
fixtures = ["test_data.json"]
def setUp(self):
self.client = LocalizingClient()
def test_home(self):
url = reverse("landing.views.home")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
dev_mdc_link = doc.find("a#dev-mdc-link")
ok_(dev_mdc_link)
def test_mozilla(self):
url = reverse("landing.views.mozilla")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_web(self):
url = reverse("landing.views.web")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_search(self):
raise SkipTest("Search test disabled until we switch to kuma wiki")
url = reverse("landing.views.search")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_promote_buttons(self):
url = reverse("landing.views.promote_buttons")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
示例6: DemoListViewsTest
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
class DemoListViewsTest(test_utils.TestCase):
fixtures = ['test_users.json']
def setUp(self):
self.user, self.admin_user, self.other_user = make_users()
self.client = LocalizingClient()
def test_all_demos_includes_hidden_for_staff(self):
build_submission(self.user)
build_hidden_submission(self.user)
r = self.client.get(reverse('demos_all'))
count = pq(r.content)('h2.count').text()
eq_(count, "1 Demo")
self.client.login(username=self.admin_user.username,
password='admint_tester')
r = self.client.get(reverse('demos_all'))
count = pq(r.content)('h2.count').text()
eq_(count, "2 Demos")
@attr('bug882709')
def test_search_view(self):
try:
self.client.get(reverse('demos_search'))
except:
self.fail("Search should not ISE.")
示例7: test_json_callback_validation
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_json_callback_validation(self):
"""Various json callbacks -- validation"""
c = LocalizingClient()
q = 'bookmarks'
format = 'json'
callbacks = (
('callback', 200),
('validCallback', 200),
('obj.method', 200),
('obj.someMethod', 200),
('arr[1]', 200),
('arr[12]', 200),
("alert('xss');foo", 400),
("eval('nastycode')", 400),
("someFunc()", 400),
('x', 200),
('x123', 200),
('$', 200),
('_func', 200),
('"></script><script>alert(\'xss\')</script>', 400),
('">', 400),
('var x=something;foo', 400),
('var x=', 400),
)
for callback, status in callbacks:
response = c.get(reverse('search'), {
'q': q,
'format': format,
'callback': callback,
})
eq_(response['Content-Type'], 'application/x-javascript')
eq_(response.status_code, status)
示例8: test_raw_section_source
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_raw_section_source(self):
"""The raw source for a document section can be requested"""
client = LocalizingClient()
client.login(username='admin', password='testpass')
d, r = doc_rev("""
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
""")
expected = """
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
"""
response = client.get('%s?section=s2&raw=true' %
reverse('wiki.document', args=[d.slug]))
eq_(normalize_html(expected),
normalize_html(response.content))
示例9: test_raw_with_editing_links_source
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_raw_with_editing_links_source(self):
"""The raw source for a document can be requested, with section editing
links"""
client = LocalizingClient()
client.login(username='admin', password='testpass')
d, r = doc_rev("""
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
""")
expected = """
<h1 id="s1"><a class="edit-section" data-section-id="s1" data-section-src-url="/en-US/docs/%(slug)s?raw=true&section=s1" href="/en-US/docs/%(slug)s$edit?section=s1&edit_links=true" title="Edit section">Edit</a>Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2"><a class="edit-section" data-section-id="s2" data-section-src-url="/en-US/docs/%(slug)s?raw=true&section=s2" href="/en-US/docs/%(slug)s$edit?section=s2&edit_links=true" title="Edit section">Edit</a>Head 2</h1>
<p>test</p>
<p>test</p>
<h1 id="s3"><a class="edit-section" data-section-id="s3" data-section-src-url="/en-US/docs/%(slug)s?raw=true&section=s3" href="/en-US/docs/%(slug)s$edit?section=s3&edit_links=true" title="Edit section">Edit</a>Head 3</h1>
<p>test</p>
<p>test</p>
""" % {'slug': d.slug}
response = client.get('%s?raw=true&edit_links=true' %
reverse('wiki.document', args=[d.slug]))
eq_(normalize_html(expected),
normalize_html(response.content))
示例10: test_review_tags
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_review_tags(self):
client = LocalizingClient()
client.login(username='admin', password='testpass')
data = new_document_data()
data.update({'review_tags':['editorial']})
response = client.post(reverse('wiki.new_document'), data)
doc = Document.objects.get(slug="a-test-article")
combos = (
([], 0, 0, 0, 0),
(['technical',], 1, 1, 0, 0),
(['editorial',], 0, 0, 1, 1),
(['technical', 'editorial',], 1, 1, 1, 1),
)
for tags, a, b, c, d in combos:
# Edit the page and set the tags for this test
data.update({ 'form': 'rev', 'review_tags': tags })
response = client.post(reverse('wiki.edit_document', args=[doc.slug]), data)
response = client.get(reverse('docs.views.docs'))
page = pq(response.content)
# Check for the section itself, and then the doc
eq_(a, page('div#review-technical').length)
eq_(b, page("div#review-technical ul li h4 a:contains('%s')" %
doc.title).length)
eq_(c, page('div#review-editorial').length)
eq_(d, page("div#review-editorial ul li h4 a:contains('%s')" %
doc.title).length)
示例11: ProfileViewsTest
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
class ProfileViewsTest(TestCase):
fixtures = ['test_users.json']
def setUp(self):
self.old_debug = settings.DEBUG
settings.DEBUG = True
self.client = LocalizingClient()
self.client.logout()
def tearDown(self):
settings.DEBUG = self.old_debug
@attr('docs_activity')
@attr('bug715923')
@patch('devmo.models.UserDocsActivityFeed.fetch_user_feed')
def test_bug715923_feed_parsing_errors(self, fetch_user_feed):
fetch_user_feed.return_value = """
THIS IS NOT EVEN XML, SO BROKEN
"""
try:
profile = UserProfile.objects.get(user__username='testuser')
user = profile.user
url = reverse('devmo.views.profile_view',
args=(user.username,))
r = self.client.get(url, follow=True)
pq(r.content)
except Exception, e:
raise e
ok_(False, "There should be no exception %s" % e)
示例12: HomeTests
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
class HomeTests(test_utils.TestCase):
def setUp(self):
self.client = LocalizingClient()
def test_google_analytics(self):
url = reverse('landing.views.home')
with override_constance_settings(GOOGLE_ANALYTICS_ACCOUNT='0'):
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
ok_('var _gaq' not in r.content)
with override_constance_settings(GOOGLE_ANALYTICS_ACCOUNT='UA-99999999-9'):
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
ok_('var _gaq' in r.content)
示例13: test_json_format
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_json_format(self):
"""JSON without callback should return application/json"""
c = LocalizingClient()
response = c.get(reverse('search'), {
'q': 'bookmarks',
'format': 'json',
})
eq_(response['Content-Type'], 'application/json')
示例14: test_ban_middleware
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_ban_middleware(self):
"""Ban middleware functions correctly."""
client = LocalizingClient()
client.login(username='testuser', password='testpass')
resp = client.get('/')
self.assertTemplateNotUsed(resp, 'users/user_banned.html')
admin = User.objects.get(username='admin')
testuser = User.objects.get(username='testuser')
ban = UserBan(user=testuser, by=admin,
reason='Banned by unit test.',
is_active=True)
ban.save()
resp = client.get('/')
self.assertTemplateUsed(resp, 'users/user_banned.html')
示例15: test_breadcrumb
# 需要导入模块: from sumo.tests import LocalizingClient [as 别名]
# 或者: from sumo.tests.LocalizingClient import get [as 别名]
def test_breadcrumb():
"""Make sure breadcrumb links start with /."""
c = LocalizingClient()
response = c.get(reverse("search"))
doc = pq(response.content)
href = doc(".breadcrumbs a")[0]
eq_("/", href.attrib["href"][0])