本文整理汇总了Python中sumo.tests.LocalizingClient类的典型用法代码示例。如果您正苦于以下问题:Python LocalizingClient类的具体用法?Python LocalizingClient怎么用?Python LocalizingClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocalizingClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: ProfileViewsTest
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)
开发者ID:LucianU,项目名称:kuma,代码行数:29,代码来源:test_views.py
示例2: HomeTests
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)
开发者ID:JorgenJuel,项目名称:kuma,代码行数:29,代码来源:test_templates.py
示例3: test_json_callback_validation
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)
开发者ID:GPHemsley,项目名称:kuma,代码行数:34,代码来源:test_json.py
示例4: test_invalid_reserved_term_slug
def test_invalid_reserved_term_slug(self):
"""Slugs should not collide with reserved URL patterns"""
client = LocalizingClient()
client.login(username='admin', password='testpass')
data = new_document_data()
# TODO: This is info derived from urls.py, but unsure how to DRY it
reserved_slugs = (
'ckeditor_config.js',
'watch-ready-for-review',
'unwatch-ready-for-review',
'watch-approved',
'unwatch-approved',
'.json',
'new',
'all',
'preview-wiki-content',
'category/10',
'needs-review/technical',
'needs-review/',
'feeds/atom/all/',
'feeds/atom/needs-review/technical',
'feeds/atom/needs-review/',
'tag/tasty-pie'
)
for term in reserved_slugs:
data['title'] = 'invalid with %s' % term
data['slug'] = term
response = client.post(reverse('wiki.new_document'), data)
self.assertContains(response, 'The slug provided is not valid.')
开发者ID:pmclanahan,项目名称:kuma,代码行数:31,代码来源:test_views.py
示例5: AppsViewsTest
class AppsViewsTest(test_utils.TestCase):
def setUp(self):
self.client = LocalizingClient()
@patch('landing.views.basket.subscribe')
def test_apps_subscription(self, subscribe):
subscribe.return_value = True
url = reverse('landing.views.apps_newsletter')
r = self.client.post(url,
{'format': 'html',
'email': '[email protected]',
'agree': 'checked'},
follow=True)
eq_(200, r.status_code)
# assert thank you message
self.assertContains(r, 'Thank you')
eq_(1, subscribe.call_count)
@patch('landing.views.basket.subscribe')
def test_apps_subscription_bad_values(self, subscribe):
subscribe.return_value = True
url = reverse('landing.views.apps_newsletter')
r = self.client.post(url, {'format': 1, 'email': 'nope'})
eq_(200, r.status_code)
# assert error
self.assertContains(r, 'Enter a valid e-mail address.')
self.assertContains(r, 'Select a valid choice.')
self.assertContains(r, 'You must agree to the privacy policy.')
开发者ID:coblan,项目名称:kuma,代码行数:30,代码来源:test_views.py
示例6: LandingViewsTest
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)
开发者ID:Arveti,项目名称:kuma,代码行数:31,代码来源:test_views.py
示例7: EventsViewsTest
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)
开发者ID:Edinunzio,项目名称:kuma,代码行数:29,代码来源:test_views.py
示例8: test_raw_section_source
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))
开发者ID:pmclanahan,项目名称:kuma,代码行数:26,代码来源:test_views.py
示例9: test_raw_with_editing_links_source
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))
开发者ID:pmclanahan,项目名称:kuma,代码行数:33,代码来源:test_views.py
示例10: ReminderEmailTestCase
class ReminderEmailTestCase(TestCase):
fixtures = ['test_users.json']
def setUp(self):
self.client = LocalizingClient()
@mock.patch_object(Site.objects, 'get_current')
def test_reminder_email(self, get_current):
"""Should send simple email reminder to user."""
get_current.return_value.domain = 'dev.mo.org'
response = self.client.post(reverse('users.send_email_reminder'),
{'username': 'testuser'},
follow=True)
eq_(200, response.status_code)
eq_(1, len(mail.outbox))
email = mail.outbox[0]
assert email.subject.find('Email Address Reminder') == 0
assert 'testuser' in email.body
@mock.patch_object(Site.objects, 'get_current')
def test_unknown_user_no_email_sent(self, get_current):
"""Should send simple email reminder to user."""
get_current.return_value.domain = 'dev.mo.org'
response = self.client.post(reverse('users.send_email_reminder'),
{'username': 'testuser404'},
follow=True)
eq_(200, response.status_code)
eq_(0, len(mail.outbox))
开发者ID:kaiquewdev,项目名称:kuma,代码行数:30,代码来源:test_views.py
示例11: LandingViewsTest
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)
开发者ID:J0WI,项目名称:kuma,代码行数:35,代码来源:test_views.py
示例12: test_json_format
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')
开发者ID:GPHemsley,项目名称:kuma,代码行数:8,代码来源:test_json.py
示例13: test_breadcrumb
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])
开发者ID:bowmasters,项目名称:kitsune,代码行数:8,代码来源:test_templates.py
示例14: UploadImageTestCase
class UploadImageTestCase(TestCase):
fixtures = ['users.json', 'questions.json']
def setUp(self):
super(UploadImageTestCase, self).setUp()
self.client = LocalizingClient()
self.client.login(username='pcraciunoiu', password='testpass')
def tearDown(self):
ImageAttachment.objects.all().delete()
super(UploadImageTestCase, self).tearDown()
def test_model_invalid(self):
"""Specifying an invalid model returns 400."""
r = post(self.client, 'upload.up_image_async', {'image': ''},
args=['invalid.model', 123])
eq_(400, r.status_code)
json_r = json.loads(r.content)
eq_('error', json_r['status'])
eq_('Model does not exist.', json_r['message'])
def test_object_notexist(self):
"""Upload nothing returns 404 error and html content."""
r = post(self.client, 'upload.up_image_async', {'image': ''},
args=['questions.Question', 123])
eq_(404, r.status_code)
json_r = json.loads(r.content)
eq_('error', json_r['status'])
eq_('Object does not exist.', json_r['message'])
def test_empty_image(self):
"""Upload nothing returns 400 error and json content."""
r = post(self.client, 'upload.up_image_async', {'image': ''},
args=['questions.Question', 1])
eq_(400, r.status_code)
json_r = json.loads(r.content)
eq_('error', json_r['status'])
eq_('Invalid or no image received.', json_r['message'])
def test_basic(self):
"""Uploading an image works."""
# TODO: posting a valid image through the test client uploads it
raise SkipTest
def test_invalid_image(self):
"""Make sure invalid files are not accepted as images."""
f = open('apps/upload/__init__.py', 'rb')
r = post(self.client, 'upload.up_image_async', {'image': f},
args=['questions.Question', 1])
f.close()
eq_(400, r.status_code)
json_r = json.loads(r.content)
eq_('error', json_r['status'])
eq_('Invalid or no image received.', json_r['message'])
开发者ID:sgarrity,项目名称:kitsune,代码行数:58,代码来源:__init__.py
示例15: test_json_empty_query
def test_json_empty_query(self):
"""Empty query returns JSON format"""
c = LocalizingClient()
# Test with flags for advanced search or not
a_types = (0, 1, 2)
for a in a_types:
response = c.get(reverse('search'), {
'format': 'json', 'a': a,
})
eq_(response['Content-Type'], 'application/json')
开发者ID:GPHemsley,项目名称:kuma,代码行数:11,代码来源:test_json.py
示例16: test_invalid_slug
def test_invalid_slug(self):
"""Slugs cannot contain /."""
client = LocalizingClient()
client.login(username='admin', password='testpass')
data = new_document_data()
data['slug'] = 'inva/lid'
response = client.post(reverse('wiki.new_document'), data)
self.assertContains(response, 'The slug provided is not valid.')
data['slug'] = 'valid'
response = client.post(reverse('wiki.new_document'), data)
self.assertRedirects(response, reverse('wiki.document_revisions',
args=[data['slug']],
locale='en-US'))
开发者ID:fwenzel,项目名称:kitsune,代码行数:14,代码来源:test_views.py
示例17: GalleryUploadTestCase
class GalleryUploadTestCase(TestCase):
fixtures = ["users.json"]
def setUp(self):
super(GalleryUploadTestCase, self).setUp()
self.client = LocalizingClient()
self.client.login(username="pcraciunoiu", password="testpass")
self.u = User.objects.get(username="pcraciunoiu")
def tearDown(self):
Image.objects.all().delete()
Video.objects.all().delete()
super(GalleryUploadTestCase, self).tearDown()
def test_image_draft_shows(self):
"""The image draft is loaded for this user."""
image(title=get_draft_title(self.u), creator=self.u)
response = get(self.client, "gallery.gallery", args=["image"])
eq_(200, response.status_code)
doc = pq(response.content)
assert doc(".image-preview img").attr("src").endswith("098f6b.jpg")
eq_(1, doc(".image-preview img").length)
def test_video_draft_shows(self):
"""The video draft is loaded for this user."""
video(title=get_draft_title(self.u), creator=self.u)
response = get(self.client, "gallery.gallery", args=["image"])
eq_(200, response.status_code)
doc = pq(response.content)
# Preview for all 3 video formats: flv, ogv, webm
eq_(3, doc("ul li.video-preview").length)
def test_image_draft_post(self):
"""Posting to the page saves the field values for the image draft."""
image(title=get_draft_title(self.u), creator=self.u)
response = post(self.client, "gallery.gallery", {"description": "??", "title": "test"}, args=["image"])
eq_(200, response.status_code)
doc = pq(response.content)
# Preview for all 3 video formats: flv, ogv, webm
eq_("??", doc("#gallery-upload-modal textarea").html())
eq_("test", doc('#gallery-upload-modal input[name="title"]').val())
def test_video_draft_post(self):
"""Posting to the page saves the field values for the video draft."""
video(title=get_draft_title(self.u), creator=self.u)
response = post(self.client, "gallery.gallery", {"title": "zTestz"}, args=["image"])
eq_(200, response.status_code)
doc = pq(response.content)
# Preview for all 3 video formats: flv, ogv, webm
eq_("zTestz", doc('#gallery-upload-modal input[name="title"]').val())
开发者ID:rtanglao,项目名称:kitsune,代码行数:50,代码来源:test_templates.py
示例18: test_retitling_ignored_for_iframe
def test_retitling_ignored_for_iframe(self):
"""When the title of an article is edited in an iframe, the change is
ignored."""
client = LocalizingClient()
client.login(username='admin', password='testpass')
new_title = 'Some New Title'
d, r = doc_rev()
old_title = d.title
data = new_document_data()
data.update({'title': new_title,
'slug': d.slug,
'form': 'rev'})
client.post('%s?iframe=1' % reverse('wiki.edit_document', args=[d.slug]), data)
eq_(old_title, Document.uncached.get(slug=d.slug).title)
assert "REDIRECT" not in Document.uncached.get(title=old_title).html
开发者ID:pmclanahan,项目名称:kuma,代码行数:15,代码来源:test_views.py
示例19: test_raw_section_edit
def test_raw_section_edit(self):
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>
""")
replace = """
<h1 id="s2">Replace</h1>
<p>replace</p>
"""
expected = """
<h1 id="s2">Replace</h1>
<p>replace</p>
"""
response = client.post('%s?section=s2&raw=true' %
reverse('wiki.edit_document', args=[d.slug]),
{"form": "rev",
"content": replace},
follow=True)
eq_(normalize_html(expected),
normalize_html(response.content))
expected = """
<h1 id="s1">Head 1</h1>
<p>test</p>
<p>test</p>
<h1 id="s2">Replace</h1>
<p>replace</p>
<h1 id="s3">Head 3</h1>
<p>test</p>
<p>test</p>
"""
response = client.get('%s?raw=true' %
reverse('wiki.document', args=[d.slug]))
eq_(normalize_html(expected),
normalize_html(response.content))
开发者ID:pmclanahan,项目名称:kuma,代码行数:48,代码来源:test_views.py
示例20: HomeTests
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)
开发者ID:Arveti,项目名称:kuma,代码行数:16,代码来源:test_templates.py
注:本文中的sumo.tests.LocalizingClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论