本文整理汇总了Python中richard.videos.tests.speaker函数的典型用法代码示例。如果您正苦于以下问题:Python speaker函数的具体用法?Python speaker怎么用?Python speaker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了speaker函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_sitemap
def test_sitemap(self):
"""Test for the sitemap.xml"""
category(save=True)
speaker(save=True)
video(save=True)
resp = self.client.get('/sitemap.xml')
eq_(resp.status_code, 200)
开发者ID:SmallsLIVE,项目名称:richard,代码行数:8,代码来源:test_views.py
示例2: test_get_speakers_list
def test_get_speakers_list(self):
"""Test that a list of speakers can be retrieved."""
speaker(name=u"Guido van Rossum", save=True)
speaker(name=u"Raymond Hettinger", save=True)
resp = self.client.get("/api/v2/speaker/", {"format": "json"})
eq_(resp.status_code, 200)
content = json.loads(smart_text(resp.content))
eq_(len(content["results"]), 2)
names = set([result["name"] for result in content["results"]])
eq_(names, set([u"Guido van Rossum", u"Raymond Hettinger"]))
开发者ID:B-Rich,项目名称:richard,代码行数:11,代码来源:test_api.py
示例3: test_get_speakers_list
def test_get_speakers_list(self):
"""Test that a list of speakers can be retrieved."""
speaker(name=u'Guido van Rossum', save=True)
speaker(name=u'Raymond Hettinger', save=True)
resp = self.client.get('/api/v2/speaker/',
{'format': 'json'})
eq_(resp.status_code, 200)
content = json.loads(smart_text(resp.content))
eq_(len(content['results']), 2)
names = set([result['name'] for result in content['results']])
eq_(names, set([u'Guido van Rossum', u'Raymond Hettinger']))
开发者ID:burakguven,项目名称:richard,代码行数:12,代码来源:test_api.py
示例4: test_speaker_list_character
def test_speaker_list_character(self):
"""
Test the view of the listing of all speakers whose names start
with certain character.
"""
s1 = speaker(name=u'Another Speaker', save=True)
s2 = speaker(name=u'Random Speaker', save=True)
url = reverse('videos-speaker-list')
data = {'character': 'r'}
resp = self.client.get(url, data)
eq_(resp.status_code, 200)
self.assertTemplateUsed(resp, 'videos/speaker_list.html')
assert s1.name not in resp.content
assert s2.name in resp.content
开发者ID:squiddy,项目名称:richard,代码行数:16,代码来源:test_views.py
示例5: test_post_video_with_urls
def test_post_video_with_urls(self):
"""Test that authenticated user can create videos."""
cat = category(save=True)
person = speaker(save=True)
tag1 = tag(save=True)
tag2 = tag(save=True)
lang = language(save=True)
data = {'title': 'Creating delicious APIs for Django apps since 2010.',
'category': '/api/v1/category/%d/' % cat.pk,
'speakers': ['/api/v1/speaker/%d/' % person.pk],
'tags': ['/api/v1/tag/%d/' % tag1.pk,
'/api/v1/tag/%d/' % tag2.pk],
'language': lang.name,
'state': Video.STATE_LIVE}
resp = self.auth_post('/api/v1/video/', json.dumps(data),
content_type='application/json')
eq_(resp.status_code, 201)
# Get the created video
resp = self.auth_get(resp['Location'], {'format': 'json'})
eq_(resp.status_code, 200)
eq_(json.loads(resp.content)['title'], data['title'])
# Verify the data
vid = Video.objects.get(title=data['title'])
eq_(vid.title, data['title'])
eq_(list(vid.speakers.values_list('name', flat=True)), [person.name])
eq_(sorted(vid.tags.values_list('tag', flat=True)),
sorted([tag1.tag, tag2.tag]))
eq_(vid.language.name, lang.name)
开发者ID:goldenboy,项目名称:richard,代码行数:32,代码来源:test_api.py
示例6: test_get_speaker
def test_get_speaker(self):
"""Test that a speaker can be retrieved."""
s = speaker(save=True)
resp = self.client.get("/api/v1/speaker/%d/" % s.pk, {"format": "json"})
eq_(resp.status_code, 200)
eq_(json.loads(resp.content)["name"], s.name)
开发者ID:pombredanne,项目名称:richard,代码行数:7,代码来源:test_api.py
示例7: test_post_video_with_urls
def test_post_video_with_urls(self):
"""Test that authenticated user can create videos."""
cat = category(save=True)
person = speaker(save=True)
tag1 = tag(save=True)
tag2 = tag(save=True)
lang = language(save=True)
data = {
"title": "Creating delicious APIs for Django apps since 2010.",
"category": "/api/v1/category/%d/" % cat.pk,
"speakers": ["/api/v1/speaker/%d/" % person.pk],
"tags": ["/api/v1/tag/%d/" % tag1.pk, "/api/v1/tag/%d/" % tag2.pk],
"language": lang.name,
"state": Video.STATE_LIVE,
}
resp = self.auth_post("/api/v1/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 201)
# Get the created video
resp = self.auth_get(resp["Location"], {"format": "json"})
eq_(resp.status_code, 200)
eq_(json.loads(resp.content)["title"], data["title"])
# Verify the data
vid = Video.objects.get(title=data["title"])
eq_(vid.title, data["title"])
eq_(list(vid.speakers.values_list("name", flat=True)), [person.name])
eq_(sorted(vid.tags.values_list("tag", flat=True)), sorted([tag1.tag, tag2.tag]))
eq_(vid.language.name, lang.name)
开发者ID:pombredanne,项目名称:richard,代码行数:31,代码来源:test_api.py
示例8: test_speaker_list_empty_character
def test_speaker_list_empty_character(self):
"""
Test the view of the listing of all speakers given a empty
`character` GET parameter. It should fallback to showing the
speakers starting from the lowest possible character.
"""
s1 = speaker(name=u'Random Speaker', save=True)
s2 = speaker(name=u'Another Speaker', save=True)
url = reverse('videos-speaker-list')
data = {'character': ''}
resp = self.client.get(url, data)
eq_(resp.status_code, 200)
self.assertTemplateUsed(resp, 'videos/speaker_list.html')
self.assertNotContains(resp, s1.name)
self.assertContains(resp, s2.name)
开发者ID:B-Rich,项目名称:richard,代码行数:17,代码来源:test_views.py
示例9: test_speaker_list_not_string_character
def test_speaker_list_not_string_character(self):
"""
Test the view of the listing of all speakers giving a invalid
character argument. The view should fallback to showing the
speakers starting from the lowest possible character.
"""
s1 = speaker(name=u'Random Speaker', save=True)
s2 = speaker(name=u'Another Speaker', save=True)
url = reverse('videos-speaker-list')
data = {'character': 42}
resp = self.client.get(url, data)
eq_(resp.status_code, 200)
self.assertTemplateUsed(resp, 'videos/speaker_list.html')
assert s1.name not in resp.content
assert s2.name in resp.content
开发者ID:squiddy,项目名称:richard,代码行数:17,代码来源:test_views.py
示例10: test_active_video_speaker_page
def test_active_video_speaker_page(self):
"""Active video should show up on it's speaker's page."""
s = speaker(save=True)
vid = video(state=Video.STATE_LIVE, save=True)
vid.speakers.add(s)
speaker_url = s.get_absolute_url()
resp = self.client.get(speaker_url)
assert vid.title in resp.content
开发者ID:squiddy,项目名称:richard,代码行数:10,代码来源:test_views.py
示例11: test_inactive_video_speaker_page
def test_inactive_video_speaker_page(self):
"""Inactive video should not show up on it's speaker's page."""
s = speaker(save=True)
vid = video(save=True)
vid.speakers.add(s)
speaker_url = s.get_absolute_url()
resp = self.client.get(speaker_url)
assert vid.title not in resp.content
开发者ID:squiddy,项目名称:richard,代码行数:10,代码来源:test_views.py
示例12: test_speaker_feed
def test_speaker_feed(self):
"""Tests for Speaker rss feed"""
spk = speaker(save=True)
# Speaker feed is accessible
resp = self.client.get(reverse("videos-speaker-feed", kwargs={"speaker_id": spk.id, "slug": spk.slug}))
eq_(resp.status_code, 200)
# Speaker feed returns 404, invalid speaker_id.
resp = self.client.get(reverse("videos-speaker-feed", kwargs={"speaker_id": 50, "slug": "fake-slug"}))
eq_(resp.status_code, 404)
开发者ID:CarlFK,项目名称:richard,代码行数:12,代码来源:test_feeds.py
示例13: test_speaker_urls
def test_speaker_urls(self):
"""Test the view of a speaker."""
spe = speaker(name=u'Random Speaker', save=True)
cases = [
spe.get_absolute_url(), # returns the URL with pk and slug
u'/speaker/%s/%s/' % (spe.id, spe.slug), # with slug and /
u'/speaker/%s/%s' % (spe.id, spe.slug), # with slug and no /
u'/speaker/%s/' % spe.id, # no slug and /
u'/speaker/%s' % spe.id, # no slug and no /
]
for url in cases:
resp = self.client.get(url)
eq_(resp.status_code, 200)
self.assertTemplateUsed(resp, 'videos/speaker.html')
开发者ID:squiddy,项目名称:richard,代码行数:16,代码来源:test_views.py
示例14: test_post_with_speaker_url
def test_post_with_speaker_url(self):
"""Test that you can post videos with url speakers"""
cat = category(save=True)
speaker1 = speaker(save=True)
data = {"title": "test1", "category": "/api/v1/category/%d/" % cat.pk, "state": Video.STATE_DRAFT}
# Post the video using /api/v1/speaker/xx.
data.update({"speakers": ["/api/v1/speaker/%d/" % speaker1.pk]})
resp = self.auth_post("/api/v1/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 201)
# Get the created video
resp = self.auth_get(resp["Location"], {"format": "json"})
# Verify the tag
vid = Video.objects.get(title=data["title"])
eq_(vid.speakers.values_list("name", flat=True)[0], speaker1.name)
开发者ID:pombredanne,项目名称:richard,代码行数:19,代码来源:test_api.py
示例15: test_get_video_data
def test_get_video_data(self):
cat = category(title=u"Foo Title", save=True)
vid = video(title=u"Foo Bar", category=cat, state=Video.STATE_LIVE, save=True)
t = tag(tag=u"tag", save=True)
vid.tags = [t]
s = speaker(name=u"Jim", save=True)
vid.speakers = [s]
resp = self.client.get("/api/v2/video/%d/" % vid.pk, {"format": "json"})
eq_(resp.status_code, 200)
content = json.loads(resp.content)
eq_(content["title"], vid.title)
eq_(content["slug"], "foo-bar")
# This should be the category title--not api url
eq_(content["category"], cat.title)
# This should be the tag--not api url
eq_(content["tags"], [t.tag])
# This should be the speaker name--not api url
eq_(content["speakers"], [s.name])
开发者ID:paepke,项目名称:richard,代码行数:19,代码来源:test_api.py
示例16: test_videos_by_speaker
def test_videos_by_speaker(self):
speaker1 = speaker(name="webber", save=True)
v1 = video(state=Video.STATE_LIVE, title=u"Foo1", save=True)
v1.speakers = [speaker1]
v1.save()
v2 = video(state=Video.STATE_LIVE, title=u"Foo2", save=True)
v2.speakers = [speaker1]
v2.save()
video(state=Video.STATE_LIVE, title=u"Foo3", save=True)
# Filter by full name.
resp = self.auth_get("/api/v2/video/?speaker=webber", content_type="application/json")
data = json.loads(resp.content)
eq_(len(data["results"]), 2)
# Filter by partial name.
resp = self.auth_get("/api/v2/video/?speaker=web", content_type="application/json")
data = json.loads(resp.content)
eq_(len(data["results"]), 2)
开发者ID:paepke,项目名称:richard,代码行数:21,代码来源:test_api.py
示例17: test_get_video_data
def test_get_video_data(self):
cat = category(title=u'Foo Title', save=True)
vid = video(title=u'Foo Bar', category=cat, state=Video.STATE_LIVE,
save=True)
t = tag(tag=u'tag', save=True)
vid.tags = [t]
s = speaker(name=u'Jim', save=True)
vid.speakers = [s]
resp = self.client.get('/api/v2/video/%d/' % vid.pk,
{'format': 'json'})
eq_(resp.status_code, 200)
content = json.loads(smart_text(resp.content))
eq_(content['title'], vid.title)
eq_(content['slug'], 'foo-bar')
# This should be the category title--not api url
eq_(content['category'], cat.title)
# This should be the tag--not api url
eq_(content['tags'], [t.tag])
# This should be the speaker name--not api url
eq_(content['speakers'], [s.name])
开发者ID:kjjjjj,项目名称:richard,代码行数:21,代码来源:test_api.py
示例18: test_videos_by_speaker
def test_videos_by_speaker(self):
speaker1 = speaker(name='webber', save=True)
v1 = video(state=Video.STATE_LIVE, title=u'Foo1', save=True)
v1.speakers = [speaker1]
v1.save()
v2 = video(state=Video.STATE_LIVE, title=u'Foo2', save=True)
v2.speakers = [speaker1]
v2.save()
video(state=Video.STATE_LIVE, title=u'Foo3', save=True)
# Filter by full name.
resp = self.auth_get('/api/v2/video/?speaker=webber',
content_type='application/json')
data = json.loads(smart_text(resp.content))
eq_(len(data['results']), 2)
# Filter by partial name.
resp = self.auth_get('/api/v2/video/?speaker=web',
content_type='application/json')
data = json.loads(smart_text(resp.content))
eq_(len(data['results']), 2)
开发者ID:kjjjjj,项目名称:richard,代码行数:23,代码来源:test_api.py
示例19: generate_sampledata
def generate_sampledata(options):
pycon2011 = category(
title=u"Pycon 2011",
slug=u"pycon-2011",
description=u"PyCon 2011 in Atlanta, GA",
url=u"http://us.pycon.org/2011/home/",
save=True,
)
pycon2012 = category(
title=u"Pycon 2012",
slug=u"pycon-2012",
description=u"PyCon 2011 in Santa Clara, CA",
url=u"http://us.pycon.org/2012/",
save=True,
)
sp1 = speaker(name=u"Jessica McKellar", save=True)
sp2 = speaker(name=u"Asheesh Laroia", save=True)
sp3 = speaker(name=u"Jacob Kaplan-Moss", save=True)
tag1 = tag(tag=u"documentation", save=True)
tag2 = tag(tag=u"sphinx", save=True)
v = video(
state=Video.STATE_LIVE,
category=pycon2011,
title=u"Writing great documentation",
summary=dedent(
"""\
Writing great documentation
Presented by Jacob Kaplan-Moss
"""
),
description=dedent(
"""\
This talk looks at tips, tools, and techniques you can
use to produce great technical documentation.
"""
),
copyright_text=u"CC-SA-NC 3.0",
recorded=date(2011, 3, 11),
updated=datetime(2011, 3, 14, 3, 47, 59),
source_url=u"http://blip.tv/file/4881071",
video_mp4_url=(
u"http://05d2db1380b6504cc981-8cbed8cf7e3a131cd8f1c3e383d10041"
u".r93.cf2.rackcdn.com/pycon-us-2011/"
u"403_writing-great-documentation.mp4"
),
thumbnail_url=(u"http://a.images.blip.tv/" u"Pycon-PyCon2011WritingGreatDocumentation902.png"),
save=True,
)
v.speakers.add(sp3)
v.tags.add(tag1, tag2)
v = video(
state=Video.STATE_LIVE,
category=pycon2012,
title=dedent(
"""\
Diversity in practice: How the Boston Python User Group grew
to 1700 people and over 15% women
"""
),
summary=dedent(
u"""\
How do you bring more women into programming communities with
long-term, measurable results? In this talk we'll analyze our
successful effort, the Boston Python Workshop, which brought over
200 women into Boston's Python community this year.
"""
),
recorded=date(2012, 3, 11),
updated=datetime(2012, 3, 13, 16, 15, 17),
source_url=u"https://www.youtube.com/watch?v=QrITN6GZDu4",
embed=dedent(
"""\
<object width="425" height="344">
<param name="movie"
value="http://www.youtube.com/v/QrITN6GZDu4&hl=en&fs=1">
<param name="allowFullScreen" value="true">
<param name="allowscriptaccess" value="always">
<embed src="http://www.youtube.com/v/QrITN6GZDu4&hl=en&fs=1"
allowscriptaccess="always" height="344"
width="425" allowfullscreen="true"
type="application/x-shockwave-flash"></embed>
</object>
"""
),
thumbnail_url=u"http://img.youtube.com/vi/QrITN6GZDu4/hqdefault.jpg",
save=True,
)
v.speakers.add(sp1, sp2)
v = video(
state=Video.STATE_DRAFT,
category=pycon2012,
#.........这里部分代码省略.........
开发者ID:raviushukla,项目名称:richard,代码行数:101,代码来源:sampledata.py
示例20: generate_sampledata
def generate_sampledata(options):
conference = category_kind(name=u'Conference', save=True)
pycon2011 = category(name=u'PyCon', title=u'Pycon 2011', slug=u'pycon-2011',
description=u'PyCon 2011 in Atlanta, GA',
kind=conference, url=u'http://us.pycon.org/2011/home/',
save=True)
pycon2012 = category(name=u'PyCon', title=u'Pycon 2012', slug=u'pycon-2012',
description=u'PyCon 2011 in Santa Clara, CA',
kind=conference, url=u'http://us.pycon.org/2012/',
save=True)
jm = speaker(name=u'Jessica McKellar', save=True)
al = speaker(name=u'Asheesh Laroia', save=True)
jkm = speaker(name=u'Jacob Kaplan-Moss', save=True)
tag1 = tag(tag=u'documentation', save=True)
tag2 = tag(tag=u'sphinx', save=True)
v = video(
state=Video.STATE_LIVE, category=pycon2011,
title=u'Writing great documentation',
summary=u'<p>Writing great documentation</p>'
u'<p>Presented by Jacob Kaplan-Moss</p>',
description=u'<p>This talk looks at tips, tools, and techniques you can'
u'use to produce great technical documentation.</p>',
copyright_text=u'Creative Commons Attribution-NonCommercial-ShareAlike 3.0',
recorded=date(2011, 3, 11),
updated=datetime(2011, 3, 14, 3, 47, 59),
source_url=u'http://blip.tv/file/4881071',
video_mp4_url=u'http://blip.tv/file/get/Pycon-PyCon2011WritingGreatDocumentation191.mp4',
video_ogv_length=158578172,
video_ogv_url=u'http://blip.tv/file/get/Pycon-PyCon2011WritingGreatDocumentation312.ogv',
thumbnail_url=u'http://a.images.blip.tv/Pycon-PyCon2011WritingGreatDocumentation902.png',
save=True)
v.speakers.add(jkm)
v.tags.add(tag1, tag2)
v = video(
state=Video.STATE_LIVE, category=pycon2012,
title=u'Diversity in practice: How the Boston Python User Group grew to '
u'1700 people and over 15% women',
summary=u"""
<p>How do you bring more women into programming communities with
long-term, measurable results? In this talk we'll analyze our
successful effort, the Boston Python Workshop, which brought over
200 women into Boston's Python community this year.</p>""",
recorded=date(2012, 3, 11),
updated=datetime(2012, 3, 13, 16, 15, 17),
source_url=u'https://www.youtube.com/watch?v=QrITN6GZDu4',
embed=u'''
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/QrITN6GZDu4&hl=en&fs=1">
<param name="allowFullScreen" value="true">
<param name="allowscriptaccess" value="always">
<embed src="http://www.youtube.com/v/QrITN6GZDu4&hl=en&fs=1" allowscriptaccess="always" height="344" width="425" allowfullscreen="true" type="application/x-shockwave-flash"></embed>
</object>''',
thumbnail_url=u'http://img.youtube.com/vi/QrITN6GZDu4/hqdefault.jpg',
save=True)
v.speakers.add(jm, al)
开发者ID:strogo,项目名称:richard,代码行数:65,代码来源:sampledata.py
注:本文中的richard.videos.tests.speaker函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论