本文整理汇总了Python中devmo.tests.LocalizingClient.get方法的典型用法代码示例。如果您正苦于以下问题:Python LocalizingClient.get方法的具体用法?Python LocalizingClient.get怎么用?Python LocalizingClient.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类devmo.tests.LocalizingClient
的用法示例。
在下文中一共展示了LocalizingClient.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SocialAccountConnectionsTests
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
class SocialAccountConnectionsTests(test_utils.TestCase):
fixtures = ['test_users.json']
def setUp(self):
self.client = LocalizingClient()
def test_account_connections_page_requires_signin(self):
url = reverse('socialaccount_connections')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
ok_(len(r.redirect_chain) > 0)
ok_('Sign In' in r.content)
def test_account_connections_page(self):
u = User.objects.get(username='testuser')
self.client.login(username=u.username, password=TESTUSER_PASSWORD)
url = reverse('socialaccount_connections')
r = self.client.get(url)
test_strings = ['Disconnect', 'Connect a new account', 'Edit profile']
eq_(200, r.status_code)
for test_string in test_strings:
ok_(test_string in r.content,
msg="Expected %s in content" % test_string)
示例2: AccountEmailTests
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
class AccountEmailTests(test_utils.TestCase):
fixtures = ['test_users.json']
def setUp(self):
self.client = LocalizingClient()
def test_account_email_page_requires_signin(self):
url = reverse('account_email')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
ok_(len(r.redirect_chain) > 0)
ok_('Sign In' in r.content)
def test_account_email_page(self):
u = User.objects.get(username='testuser')
self.client.login(username=u.username, password=TESTUSER_PASSWORD)
url = reverse('account_email')
r = self.client.get(url)
test_strings = ['Make Primary', 'Re-send Verification', 'Remove',
'Add Email', 'Edit profile']
eq_(200, r.status_code)
for test_string in test_strings:
ok_(test_string in r.content)
示例3: DemoListViewsTest
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.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.")
示例4: EventsViewsTest
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
class EventsViewsTest(test_utils.TestCase):
fixtures = ['calendar.json']
def setUp(self):
self.client = LocalizingClient()
calendar_reload()
def test_events(self):
url = reverse('events')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_events_map_flag(self):
url = reverse('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)
示例5: LandingViewsTest
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.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_promote_buttons(self):
url = reverse('landing.views.promote_buttons')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
示例6: HomeTests
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.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_('ga(\'create' 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_('ga(\'create' in r.content)
示例7: ViewTests
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
class ViewTests(TestCase):
fixtures = ['test_users.json', 'wiki/documents.json']
def setUp(self):
self.client = LocalizingClient()
def mk_request(self, user=None, ip='192.168.123.123',
user_agent='FakeBrowser 1.0'):
request = HttpRequest()
request.user = user and user or AnonymousUser()
request.method = 'GET'
request.META['REMOTE_ADDR'] = ip
request.META['HTTP_USER_AGENT'] = user_agent
return request
def test_flagged_view(self):
request = self.mk_request()
objects_to_flag = [
{'obj': save_valid_submission(),
'flag_type': 'notworking',
'explanation': 'I am not good at computer.'},
{'obj': Document.objects.get(pk=4),
'flag_type': 'bad',
'explanation': 'This is in fact not a pipe.'},
{'obj': Document.objects.get(pk=8),
'flag_type': 'unneeded',
'explanation': 'Camels are for Perl, not Python.'},
]
for o in objects_to_flag:
flag, created = ContentFlag.objects.flag(request=request,
object=o['obj'],
flag_type=o['flag_type'],
explanation=o['explanation'])
resp = self.client.get(reverse('contentflagging.flagged'))
eq_(200, resp.status_code)
示例8: ViewTests
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
class ViewTests(TestCase):
fixtures = ["test_users.json", "wiki/documents.json"]
def setUp(self):
self.client = LocalizingClient()
def mk_request(self, user=None, ip="192.168.123.123", user_agent="FakeBrowser 1.0"):
request = HttpRequest()
request.user = user and user or AnonymousUser()
request.method = "GET"
request.META["REMOTE_ADDR"] = ip
request.META["HTTP_USER_AGENT"] = user_agent
return request
def test_flagged_view(self):
request = self.mk_request()
objects_to_flag = [
{"obj": save_valid_submission(), "flag_type": "notworking", "explanation": "I am not good at computer."},
{"obj": Document.objects.get(pk=4), "flag_type": "bad", "explanation": "This is in fact not a pipe."},
{
"obj": Document.objects.get(pk=8),
"flag_type": "unneeded",
"explanation": "Camels are for Perl, not Python.",
},
]
for o in objects_to_flag:
flag, created = ContentFlag.objects.flag(
request=request, object=o["obj"], flag_type=o["flag_type"], explanation=o["explanation"]
)
resp = self.client.get(reverse("contentflagging.flagged"))
eq_(200, resp.status_code)
示例9: test_breadcrumb
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.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])
示例10: test_ban_middleware
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.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')
示例11: LandingViewsTest
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.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_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)
示例12: test_404_already_logged_in
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
def test_404_already_logged_in(self):
"""The login buttons should not display on the 404 page when the user is logged in"""
client = LocalizingClient()
# View page as a logged in user
client.login(username='testuser',
password='testpass')
response = client.get('/something-doesnt-exist', follow=True)
doc = pq(response.content)
login_block = doc.find('.socialaccount_providers')
eq_(len(login_block), 0)
eq_(404, response.status_code)
client.logout()
示例13: test_ban_permission
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
def test_ban_permission(self):
"""The ban permission controls access to the ban view."""
client = LocalizingClient()
admin = User.objects.get(username='admin')
testuser = User.objects.get(username='testuser')
# testuser doesn't have ban permission, can't ban.
client.login(username='testuser',
password='testpass')
ban_url = reverse('users.ban_user',
kwargs={'user_id': admin.id})
resp = client.get(ban_url)
eq_(302, resp.status_code)
ok_(settings.LOGIN_URL in resp['Location'])
client.logout()
# admin has ban permission, can ban.
client.login(username='admin',
password='testpass')
ban_url = reverse('users.ban_user',
kwargs={'user_id': testuser.id})
resp = client.get(ban_url)
eq_(200, resp.status_code)
示例14: LandingViewsTest
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.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_promote_buttons(self):
url = reverse('landing.views.promote_buttons')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_contribute_json(self):
# using the non-localizing client here as contribute.json
# is not-localizable
client = Client()
r = client.get(reverse('contribute_json'))
eq_(200, r.status_code)
ok_('application/json' in r['Content-Type'])
示例15: LearnViewsTest
# 需要导入模块: from devmo.tests import LocalizingClient [as 别名]
# 或者: from devmo.tests.LocalizingClient import get [as 别名]
class LearnViewsTest(test_utils.TestCase):
def setUp(self):
self.client = LocalizingClient()
def test_learn(self):
url = reverse('landing.views.learn')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_learn_html(self):
url = reverse('landing.views.learn_html')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_learn_css(self):
url = reverse('landing.views.learn_css')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
def test_learn_javascript(self):
url = reverse('landing.views.learn_javascript')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)