本文整理汇总了Python中api_test.Helpers.createInterpretation方法的典型用法代码示例。如果您正苦于以下问题:Python Helpers.createInterpretation方法的具体用法?Python Helpers.createInterpretation怎么用?Python Helpers.createInterpretation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_test.Helpers
的用法示例。
在下文中一共展示了Helpers.createInterpretation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_post_returns_forbidden_for_not_authorized_user
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_post_returns_forbidden_for_not_authorized_user(self):
interpretation = Helpers.createInterpretation()
url = '/compositions/{0}/interpretations/{1}/comments'.format(interpretation.composition.id, interpretation.id)
response = self.client.post(url, data={})
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(
response.data, {"detail": "Authentication credentials were not provided."})
self.assertEqual(Comment.objects.all().count(), 0)
示例2: test_delete_return_forbidden_for_non_authenticated_user
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_delete_return_forbidden_for_non_authenticated_user(self):
user1 = Helpers.getUser(Helpers.USER1)
interpretation = Helpers.createInterpretation()
comment = Comment.objects.create(
commenter=user1, interpretation=interpretation, comment='comment1')
url = '/compositions/{0}/interpretations/{1}/comments/{2}'.format(
interpretation.composition.id,
interpretation.id,
comment.id)
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
示例3: test_post_authenticated_user_valid_post_data
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_post_authenticated_user_valid_post_data(self):
user2 = Helpers.getUser(Helpers.USER2)
interpretation = Helpers.createInterpretation()
comment_data = {'comment': 'comment1'}
url = '/compositions/{0}/interpretations/{1}/comments'.format(interpretation.composition.id, interpretation.id)
self.client.login(username='[email protected]', password='user2')
response = self.client.post(url, data=comment_data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.data, self.createResponse(
1, 'comment1', user2.id, interpretation.id, datetime.now()))
self.assertEqual(Comment.objects.all().count(), 1)
示例4: test_post_for_authenticated_user_empty_comment
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_post_for_authenticated_user_empty_comment(self):
Helpers.getUser(Helpers.USER2)
interpretation = Helpers.createInterpretation()
comment_data = {'comment': ''}
url = '/compositions/{0}/interpretations/{1}/comments'.format(interpretation.composition.id, interpretation.id)
self.client.login(username='[email protected]', password='user2')
response = self.client.post(url, data=comment_data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.data, {"comment": ["This field is required."]})
self.assertEqual(Comment.objects.all().count(), 0)
示例5: test_delete_for_autheticated_valid_commenter
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_delete_for_autheticated_valid_commenter(self):
user1 = Helpers.getUser(Helpers.USER1)
interpretation = Helpers.createInterpretation()
comment = Comment.objects.create(
commenter=user1, interpretation=interpretation, comment='comment1')
url = '/compositions/{0}/interpretations/{1}/comments/{2}'.format(
interpretation.composition.id,
interpretation.id,
comment.id)
self.client.login(username='[email protected]', password='user1')
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
示例6: test_delete_returns_forbidden_for_user_not_commenter
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_delete_returns_forbidden_for_user_not_commenter(self):
user1 = Helpers.getUser(Helpers.USER1)
Helpers.getUser(Helpers.USER2)
interpretation = Helpers.createInterpretation()
comment = Comment.objects.create(
commenter=user1, interpretation=interpretation, comment='comment1')
url = '/compositions/{0}/interpretations/{1}/comments/{2}'.format(
interpretation.composition.id,
interpretation.id,
comment.id)
self.client.login(username='[email protected]', password='user2')
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
示例7: test_update_for_autheticated_valid_commenter
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_update_for_autheticated_valid_commenter(self):
user1 = Helpers.getUser(Helpers.USER1)
interpretation = Helpers.createInterpretation()
comment = Comment.objects.create(
commenter=user1, interpretation=interpretation, comment='comment1')
comment_data = {'comment': 'comment2'}
url = '/compositions/{0}/interpretations/{1}/comments/{2}'.format(
interpretation.composition.id,
interpretation.id,
comment.id)
self.client.login(username='[email protected]ser.com', password='user1')
response = self.client.put(url, data=comment_data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, self.createResponse(
1, 'comment2', user1.id, interpretation.id, comment.created, True))
示例8: test_get_returns_all_comments_for_interpretation
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def test_get_returns_all_comments_for_interpretation(self):
user1 = Helpers.getUser(Helpers.USER1)
user2 = Helpers.getUser(Helpers.USER1)
interpretation = Helpers.createInterpretation()
comment1 = Comment.objects.create(
commenter=user1, interpretation=interpretation, comment='comment1')
comment2 = Comment.objects.create(
commenter=user1, interpretation=interpretation, comment='comment2')
comment3 = Comment.objects.create(
commenter=user2, interpretation=interpretation, comment='comment3')
url = '/compositions/{0}/interpretations/{1}/comments'.format(interpretation.composition.id, interpretation.id)
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
expected_response = [
self.createResponse(1, 'comment1', user1.id, interpretation.id, comment1.created)]
expected_response.append(
self.createResponse(2, 'comment2', user1.id, interpretation.id, comment2.created))
expected_response.append(
self.createResponse(3, 'comment3', user2.id, interpretation.id, comment3.created))
self.assertEqual(response.data, expected_response)
示例9: createVote
# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import createInterpretation [as 别名]
def createVote(self):
interpretation = Helpers.createInterpretation()
return InterpretationVote.objects.get(interpretation=interpretation)