当前位置: 首页>>代码示例>>Python>>正文


Python Helpers.createInterpretation方法代码示例

本文整理汇总了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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:12,代码来源:testListComments.py

示例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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:15,代码来源:testSingleComment.py

示例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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:15,代码来源:testListComments.py

示例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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:15,代码来源:testListComments.py

示例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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:16,代码来源:testSingleComment.py

示例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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:17,代码来源:testSingleComment.py

示例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))
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:19,代码来源:testSingleComment.py

示例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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:24,代码来源:testListComments.py

示例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)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:5,代码来源:testInterpretationVotes.py


注:本文中的api_test.Helpers.createInterpretation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。