本文整理汇总了Python中soapbox.models.Message类的典型用法代码示例。如果您正苦于以下问题:Python Message类的具体用法?Python Message怎么用?Python Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_message_with_url_is_link
def test_message_with_url_is_link(self):
m = Message(message="Go to http://bit.ly/sample-demo", is_global=True,
is_active=True, url="/")
m.save()
ok_('Go to <a href="http://bit.ly/sample-demo">'
'http://bit.ly/sample-demo</a>' in
soapbox_messages(get_soapbox_messages("/")))
示例2: test_subsection_message
def test_subsection_message(self):
m = Message(message='Search down', is_global=False, is_active=True,
url='/search')
m.save()
assert 0 == len(get_soapbox_messages('/'))
assert 0 == len(get_soapbox_messages('/docs'))
assert 0 == len(get_soapbox_messages('/en-US/docs'))
assert m.message == get_soapbox_messages('/en-US/search')[0].message
assert m.message == get_soapbox_messages('/de/search')[0].message
示例3: test_subsection_message
def test_subsection_message(self):
m = Message(message="Derby", is_global=False, is_active=True,
url="/demos/devderby")
m.save()
eq_(0, len(get_soapbox_messages("/")))
eq_(0, len(get_soapbox_messages("/demos")))
eq_(0, len(get_soapbox_messages("/en-US/demos")))
eq_(m.message, get_soapbox_messages(
"/en-US/demos/devderby")[0].message)
eq_(m.message, get_soapbox_messages("/de/demos/devderby")[0].message)
示例4: test_inactive
def test_inactive(self):
m = Message(message="Demos", is_global=False, is_active=False, url="/demos/")
m.save()
url = reverse("demos")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_([], doc.find("div.global-notice"))
示例5: test_global_home
def test_global_home(self):
m = Message(message='Global', is_global=True, is_active=True, url='/')
m.save()
url = reverse('home')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_(m.message, doc.find('div.global-notice').text())
示例6: test_inactive
def test_inactive(self):
m = Message(message='Search', is_global=False, is_active=False,
url='/search/')
m.save()
url = reverse('search')
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_([], doc.find('div.global-notice'))
示例7: test_global_home
def test_global_home(self):
m = Message(message="Global", is_global=True, is_active=True, url="/")
m.save()
url = reverse("home")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_(m.message, doc.find("div.global-notice").text())
url = reverse("demos")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_(m.message, doc.find("div.global-notice").text())
示例8: test_subsection
def test_subsection(self):
m = Message(message="Events", is_global=False, is_active=True, url="/events/")
m.save()
url = reverse("events")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_(m.message, doc.find("div.global-notice").text())
url = reverse("home")
r = self.client.get(url, follow=True)
eq_(200, r.status_code)
doc = pq(r.content)
eq_([], doc.find("div.global-notice"))
示例9: test_global_message
def test_global_message(self):
m = Message(message="Global", is_global=True, is_active=True, url="/")
m.save()
eq_(m.message, get_soapbox_messages("/")[0].message)
eq_(m.message, get_soapbox_messages("/en-US/")[0].message)
eq_(m.message, get_soapbox_messages("/fr/demos/")[0].message)
示例10: test_message_with_url_is_link
def test_message_with_url_is_link(self):
m = Message(message='Go to http://bit.ly/sample-demo', is_global=True,
is_active=True, url='/')
m.save()
assert 'Go to <a href="http://bit.ly/sample-demo" rel="noopener">' \
'http://bit.ly/sample-demo</a>' in soapbox_messages(get_soapbox_messages('/'))
示例11: test_global_message
def test_global_message(self):
m = Message(message='Global', is_global=True, is_active=True, url='/')
m.save()
assert m.message == get_soapbox_messages('/')[0].message
assert m.message == get_soapbox_messages('/en-US/')[0].message