本文整理汇总了Python中richard.videos.tests.video函数的典型用法代码示例。如果您正苦于以下问题:Python video函数的具体用法?Python video怎么用?Python video使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了video函数的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_all_videos_for_admins
def test_all_videos_for_admins(self):
"""Test that admins can see all videos."""
video(state=Video.STATE_LIVE, title=u"Foo", save=True)
video(state=Video.STATE_DRAFT, title=u"Bar", save=True)
resp = self.auth_get("/api/v2/video/", content_type="application/json")
data = json.loads(resp.content)
eq_(len(data["results"]), 2)
开发者ID:paepke,项目名称:richard,代码行数:9,代码来源:test_api.py
示例3: test_all_videos_for_admins
def test_all_videos_for_admins(self):
"""Test that admins can see all videos."""
video(state=Video.STATE_LIVE, title=u'Foo', save=True)
video(state=Video.STATE_DRAFT, title=u'Bar', save=True)
resp = self.auth_get('/api/v2/video/',
content_type='application/json')
data = json.loads(smart_text(resp.content))
eq_(len(data['results']), 2)
开发者ID:kjjjjj,项目名称:richard,代码行数:10,代码来源:test_api.py
示例4: test_only_live_videos_for_anonymous_users
def test_only_live_videos_for_anonymous_users(self):
"""Test that not authenticated users can't see draft videos."""
vid_live = video(state=Video.STATE_LIVE, title=u"Foo", save=True)
video(state=Video.STATE_DRAFT, title=u"Bar", save=True)
resp = self.client.get("/api/v2/video/", content_type="application/json")
data = json.loads(resp.content)
eq_(len(data["results"]), 1)
eq_(data["results"][0]["title"], vid_live.title)
开发者ID:paepke,项目名称:richard,代码行数:10,代码来源:test_api.py
示例5: test_only_live_videos_for_anonymous_users
def test_only_live_videos_for_anonymous_users(self):
"""Test that not authenticated users can't see draft videos."""
vid_live = video(state=Video.STATE_LIVE, title=u'Foo', save=True)
video(state=Video.STATE_DRAFT, title=u'Bar', save=True)
resp = self.client.get('/api/v2/video/',
content_type='application/json')
data = json.loads(smart_text(resp.content))
eq_(len(data['results']), 1)
eq_(data['results'][0]['title'], vid_live.title)
开发者ID:kjjjjj,项目名称:richard,代码行数:11,代码来源:test_api.py
示例6: test_post_with_used_slug
def test_post_with_used_slug(self):
"""Test that an already used slug kicks up a 400."""
cat = category(save=True)
video(title='test1', slug='test1', save=True)
data = {'title': 'test1',
'category': '/api/v1/category/%d/' % cat.pk,
'state': Video.STATE_DRAFT,
'slug': 'test1'}
resp = self.auth_post('/api/v1/video/', json.dumps(data),
content_type='application/json')
eq_(resp.status_code, 400)
开发者ID:asfaltboy,项目名称:richard,代码行数:13,代码来源:test_api.py
示例7: test_videos_by_tag
def test_videos_by_tag(self):
tag1 = tag(tag="boat", save=True)
v1 = video(state=Video.STATE_LIVE, title=u"Foo1", save=True)
v1.tags = [tag1]
v1.save()
v2 = video(state=Video.STATE_LIVE, title=u"Foo2", save=True)
v2.tags = [tag1]
v2.save()
video(state=Video.STATE_LIVE, title=u"Foo3", save=True)
resp = self.auth_get("/api/v2/video/?tag=boat", content_type="application/json")
data = json.loads(resp.content)
eq_(len(data["results"]), 2)
开发者ID:paepke,项目名称:richard,代码行数:14,代码来源:test_api.py
示例8: test_post_with_used_slug
def test_post_with_used_slug(self):
"""Test that an already used slug kicks up a 400."""
cat = category(save=True)
video(title="test1", slug="test1", save=True)
data = {
"title": "test1",
"category": "/api/v1/category/%d/" % cat.pk,
"state": Video.STATE_DRAFT,
"slug": "test1",
}
resp = self.auth_post("/api/v1/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 400)
开发者ID:pombredanne,项目名称:richard,代码行数:14,代码来源:test_api.py
示例9: test_videos_by_tag
def test_videos_by_tag(self):
tag1 = tag(tag='boat', save=True)
v1 = video(state=Video.STATE_LIVE, title=u'Foo1', save=True)
v1.tags = [tag1]
v1.save()
v2 = video(state=Video.STATE_LIVE, title=u'Foo2', save=True)
v2.tags = [tag1]
v2.save()
video(state=Video.STATE_LIVE, title=u'Foo3', save=True)
resp = self.auth_get('/api/v2/video/?tag=boat',
content_type='application/json')
data = json.loads(smart_text(resp.content))
eq_(len(data['results']), 2)
开发者ID:kjjjjj,项目名称:richard,代码行数:15,代码来源:test_api.py
示例10: test_post_with_used_slug
def test_post_with_used_slug(self):
"""Test that already used slug creates second video with new slug."""
cat = category(save=True)
lang = language(save=True)
video(title='test1', slug='test1', save=True)
data = {'title': 'test1',
'category': cat.title,
'language': lang.name,
'state': Video.STATE_DRAFT,
'slug': 'test1'}
resp = self.auth_post('/api/v2/video/', json.dumps(data),
content_type='application/json')
eq_(resp.status_code, 201)
开发者ID:kjjjjj,项目名称:richard,代码行数:15,代码来源:test_api.py
示例11: test_put
def test_put(self):
"""Test that passing in an id, but no slug with a PUT works."""
cat = category(save=True)
lang = language(save=True)
vid = video(title='test1', save=True)
data = {'id': vid.pk,
'title': vid.title,
'category': cat.title,
'language': lang.name,
'speakers': ['Guido'],
'tags': ['foo'],
'state': Video.STATE_DRAFT}
resp = self.auth_put('/api/v2/video/%d/' % vid.pk,
json.dumps(data),
content_type='application/json')
eq_(resp.status_code, 200)
# Get the video from the db and compare data.
vid = Video.objects.get(pk=vid.pk)
eq_(vid.title, u'test1')
eq_(vid.slug, u'test1')
eq_(list(vid.speakers.values_list('name', flat=True)), ['Guido'])
eq_(list(vid.tags.values_list('tag', flat=True)), ['foo'])
开发者ID:kjjjjj,项目名称:richard,代码行数:25,代码来源:test_api.py
示例12: test_put
def test_put(self):
"""Test that passing in an id, but no slug with a PUT works."""
cat = category(save=True)
lang = language(save=True)
vid = video(title="test1", save=True)
data = {
"id": vid.pk,
"title": vid.title,
"category": cat.title,
"language": lang.name,
"speakers": ["Guido"],
"tags": ["foo"],
"state": Video.STATE_DRAFT,
}
resp = self.auth_put("/api/v2/video/%d/" % vid.pk, json.dumps(data), content_type="application/json")
eq_(resp.status_code, 200)
# Get the video from the db and compare data.
vid = Video.objects.get(pk=vid.pk)
eq_(vid.title, u"test1")
eq_(vid.slug, u"test1")
eq_(list(vid.speakers.values_list("name", flat=True)), ["Guido"])
eq_(list(vid.tags.values_list("tag", flat=True)), ["foo"])
开发者ID:paepke,项目名称:richard,代码行数:25,代码来源:test_api.py
示例13: test_post_with_used_slug
def test_post_with_used_slug(self):
"""Test that already used slug creates second video with new slug."""
cat = category(save=True)
lang = language(save=True)
video(title="test1", slug="test1", save=True)
data = {
"title": "test1",
"category": cat.title,
"language": lang.name,
"state": Video.STATE_DRAFT,
"slug": "test1",
}
resp = self.auth_post("/api/v2/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 201)
开发者ID:paepke,项目名称:richard,代码行数:16,代码来源:test_api.py
示例14: test_inactive_video_category_page
def test_inactive_video_category_page(self):
"""Inactive video should not show up on category page."""
vid = video(save=True)
category_url = vid.category.get_absolute_url()
resp = self.client.get(category_url)
assert vid.title not in resp.content
开发者ID:squiddy,项目名称:richard,代码行数:8,代码来源:test_views.py
示例15: test_active_video_category_page
def test_active_video_category_page(self):
"""Active video should shows up on category page."""
vid = video(state=Video.STATE_LIVE, save=True)
category_url = vid.category.get_absolute_url()
resp = self.client.get(category_url)
assert vid.title in resp.content
开发者ID:squiddy,项目名称:richard,代码行数:8,代码来源:test_views.py
示例16: test_inactive_video_category_page
def test_inactive_video_category_page(self):
"""Inactive video should not show up on category page."""
vid = video(save=True)
category_url = vid.category.get_absolute_url()
resp = self.client.get(category_url)
self.assertNotContains(resp, vid.title)
开发者ID:B-Rich,项目名称:richard,代码行数:8,代码来源:test_views.py
示例17: test_related_url
def test_related_url(self):
"""Related urls should show up on the page."""
v = video(save=True)
rurl = related_url(video_id=v.id, url=u'http://example.com/foo',
description=u'Example related url',
save=True)
resp = self.client.get(v.get_absolute_url())
assert rurl.description in resp.content
开发者ID:SmallsLIVE,项目名称:richard,代码行数:9,代码来源:test_views.py
示例18: test_api_disabled
def test_api_disabled(self):
"""Test that disabled api kicks up 404"""
if settings.API:
raise SkipTest
vid = video(state=Video.STATE_LIVE, save=True)
# anonymous user
resp = self.client.get('/api/v1/video/%d/' % vid.pk, {'format': 'json'})
eq_(resp.status_code, 404)
开发者ID:goldenboy,项目名称:richard,代码行数:10,代码来源:test_api.py
示例19: 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
示例20: test_category_feed
def test_category_feed(self):
"""Tests for Category rss feed"""
# Test that only categories with live videos are included.
feed = CategoryFeed()
cat = category(save=True)
video(category=cat, save=True)
v2 = video(category=cat, save=True)
# No live videos, no category in feed
eq_(len(feed.items()), 0)
# At least one video is live, category is included
v2.state = Video.STATE_LIVE
v2.save()
eq_([x.pk for x in feed.items()], [cat.pk])
# Category feed description_template exists.
found_tpl = True
try:
get_template(feed.description_template)
except TemplateDoesNotExist:
found_tpl = False
eq_(found_tpl, True)
# Category list feeds is accessible.
resp = self.client.get(reverse('videos-category-feed'))
eq_(resp.status_code, 200)
# Category videos feed is accessible.
resp = self.client.get(
reverse(
'videos-category-videos-feed',
kwargs={'category_id': cat.id, 'slug': cat.slug}))
eq_(resp.status_code, 200)
# Category videos feed returns 404, invalid category_id.
resp = self.client.get(
reverse(
'videos-category-videos-feed',
kwargs={'category_id': 50, 'slug': 'fake-slug'}))
eq_(resp.status_code, 404)
开发者ID:SmallsLIVE,项目名称:richard,代码行数:43,代码来源:test_feeds.py
注:本文中的richard.videos.tests.video函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论