本文整理汇总了Python中richard.videos.tests.category函数的典型用法代码示例。如果您正苦于以下问题:Python category函数的具体用法?Python category怎么用?Python category使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了category函数的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_videos_by_category
def test_videos_by_category(self):
cat1 = category(slug="pycon-us-2014", save=True)
cat2 = category(slug="scipy-2013", save=True)
video(state=Video.STATE_LIVE, title=u"Foo1", category=cat1, save=True)
video(state=Video.STATE_LIVE, title=u"Foo2", category=cat1, save=True)
video(state=Video.STATE_LIVE, title=u"Foo3", category=cat2, save=True)
resp = self.auth_get("/api/v2/video/?category=pycon-us-2014", content_type="application/json")
data = json.loads(smart_text(resp.content))
eq_(len(data["results"]), 2)
开发者ID:B-Rich,项目名称:richard,代码行数:11,代码来源:test_api.py
示例3: 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
示例4: test_get_category
def test_get_category(self):
"""Test that a category can be retrieved."""
cat = category(save=True)
resp = self.client.get('/api/v1/category/%d/' % cat.pk, {'format': 'json'})
eq_(resp.status_code, 200)
eq_(json.loads(resp.content)['name'], cat.name)
开发者ID:goldenboy,项目名称:richard,代码行数:7,代码来源:test_api.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_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
示例7: test_create_and_update_video
def test_create_and_update_video(self):
cat = category(save=True)
lang = language(name=u'English 2', save=True)
ret = richardapi.create_video(
self.api_url,
auth_token=self.token.key,
video_data={
'title': 'Test video create and update',
'language': lang.name,
'category': cat.title,
'state': richardapi.STATE_DRAFT,
'speakers': ['Jimmy'],
'tags': ['foo'],
})
video = Video.objects.get(title='Test video create and update')
eq_(video.title, ret['title'])
eq_(video.state, ret['state'])
eq_(video.id, ret['id'])
ret['title'] = 'Video Test'
ret = richardapi.update_video(
self.api_url,
auth_token=self.token.key,
video_id=ret['id'],
video_data=ret
)
video = Video.objects.get(title='Video Test')
eq_(video.title, ret['title'])
开发者ID:muhammadazwa,项目名称:richard,代码行数:32,代码来源:test_steve_and_api.py
示例8: test_post_video_not_authenticated
def test_post_video_not_authenticated(self):
"""Test that not authenticated users can't write."""
cat = category(save=True)
data = {"title": "Creating delicious APIs since 2010.", "category": cat.title, "state": Video.STATE_LIVE}
resp = self.client.post("/api/v2/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 401)
开发者ID:paepke,项目名称:richard,代码行数:7,代码来源:test_api.py
示例9: test_post_video
def test_post_video(self):
"""Test that authenticated user can create videos."""
cat = category(save=True)
data = {'title': 'Creating delicious APIs for Django apps since 2010.',
'category': '/api/v1/category/%d/' % cat.pk,
'speakers': ['Guido'],
'tags': ['django', 'api'],
'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'])
vid = Video.objects.get(title=data['title'])
eq_(vid.title, data['title'])
eq_(vid.slug, u'creating-delicious-apis-for-django-apps-since-201')
eq_(list(vid.speakers.values_list('name', flat=True)), ['Guido'])
eq_(sorted(vid.tags.values_list('tag', flat=True)),
[u'api', u'django'])
开发者ID:asfaltboy,项目名称:richard,代码行数:25,代码来源:test_api.py
示例10: test_post_with_tag_name
def test_post_with_tag_name(self):
"""Test that you can post video with url tags or real tags"""
cat = category(save=True)
data = {'title': 'test1',
'category': '/api/v1/category/%d/' % cat.pk,
'state': Video.STATE_DRAFT}
footag = u'footag'
data.update(
{
'title': 'test2',
'tags': [footag],
})
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.tags.values_list('tag', flat=True)[0], footag)
开发者ID:ekaputra07,项目名称:richard,代码行数:25,代码来源:test_api.py
示例11: test_post_with_speaker_name
def test_post_with_speaker_name(self):
"""Test that you can post videos with speaker names"""
cat = category(save=True)
fooperson = u'Carl'
data = {'title': 'test1',
'category': '/api/v1/category/%d/' % cat.pk,
'state': Video.STATE_DRAFT}
data.update(
{
'title': 'test2',
'speakers': [fooperson],
})
resp = self.auth_post('/api/v1/video/', json.dumps(data),
content_type='application/json')
print resp.content
eq_(resp.status_code, 201)
# Get the created video
resp = self.auth_get(resp['Location'], {'format': 'json'})
# Verify the speaker
vid = Video.objects.get(title=data['title'])
eq_(vid.speakers.values_list('name', flat=True)[0], fooperson)
开发者ID:ekaputra07,项目名称:richard,代码行数:25,代码来源:test_api.py
示例12: 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
示例13: test_post_with_category_title
def test_post_with_category_title(self):
"""Test that a category title works"""
cat = category(title="testcat", save=True)
data = {"title": "test1", "category": cat.title, "state": Video.STATE_DRAFT}
resp = self.auth_post("/api/v1/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 201)
开发者ID:pombredanne,项目名称:richard,代码行数:8,代码来源:test_api.py
示例14: test_post_with_bad_state
def test_post_with_bad_state(self):
"""Test that a bad state is rejected"""
cat = category(save=True)
data = {"title": "test1", "category": cat.title, "state": 0}
resp = self.auth_post("/api/v2/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 400)
开发者ID:paepke,项目名称:richard,代码行数:8,代码来源:test_api.py
示例15: test_post_with_bad_language
def test_post_with_bad_language(self):
"""Test that a bad state is rejected"""
cat = category(title="testcat", save=True)
data = {"title": "test1", "category": cat.title, "state": Video.STATE_DRAFT, "language": "lolcats"}
resp = self.auth_post("/api/v2/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 400)
开发者ID:paepke,项目名称:richard,代码行数:8,代码来源:test_api.py
示例16: test_get_category
def test_get_category(self):
"""Test that a category can be retrieved."""
cat = category(save=True)
resp = self.client.get("/api/v2/category/%s/" % cat.slug, {"format": "json"})
eq_(resp.status_code, 200)
content = json.loads(resp.content)
eq_(json.loads(resp.content)["title"], cat.title)
开发者ID:paepke,项目名称:richard,代码行数:8,代码来源:test_api.py
示例17: test_post_video_no_title
def test_post_video_no_title(self):
"""Test that no title throws an error."""
cat = category(save=True)
data = {"title": "", "category": cat.title, "state": Video.STATE_LIVE}
resp = self.auth_post("/api/v2/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 400)
开发者ID:paepke,项目名称:richard,代码行数:8,代码来源:test_api.py
示例18: test_get_category
def test_get_category(self):
"""Test that a category can be retrieved."""
cat = category(save=True)
resp = self.client.get('/api/v2/category/%s/' % cat.slug,
{'format': 'json'})
eq_(resp.status_code, 200)
content = json.loads(smart_text(resp.content))
eq_(json.loads(smart_text(resp.content))['title'], cat.title)
开发者ID:kjjjjj,项目名称:richard,代码行数:9,代码来源:test_api.py
示例19: test_post_with_bad_speaker_string
def test_post_with_bad_speaker_string(self):
cat = category(save=True)
data = {"title": "test1", "category": "/api/v1/category/%d/" % cat.pk, "state": Video.STATE_DRAFT}
data.update({"speakers": [""]})
resp = self.auth_post("/api/v1/video/", json.dumps(data), content_type="application/json")
eq_(resp.status_code, 400)
开发者ID:pombredanne,项目名称:richard,代码行数:9,代码来源:test_api.py
示例20: test_post_video_not_authenticated
def test_post_video_not_authenticated(self):
"""Test that not authenticated users can't write."""
cat = category(save=True)
data = {'title': 'Creating delicious APIs since 2010.',
'category': cat.title,
'state': Video.STATE_LIVE}
resp = self.client.post('/api/v2/video/', json.dumps(data),
content_type='application/json')
eq_(resp.status_code, 401)
开发者ID:kjjjjj,项目名称:richard,代码行数:10,代码来源:test_api.py
注:本文中的richard.videos.tests.category函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论