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


Python Helpers.getUser方法代码示例

本文整理汇总了Python中api_test.Helpers.getUser方法的典型用法代码示例。如果您正苦于以下问题:Python Helpers.getUser方法的具体用法?Python Helpers.getUser怎么用?Python Helpers.getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在api_test.Helpers的用法示例。


在下文中一共展示了Helpers.getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_post_works_for_multiple_authenticated_user_that_has_not_already_voted

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_post_works_for_multiple_authenticated_user_that_has_not_already_voted(self):
        user1 = Helpers.getUser(Helpers.USER1)
        user2 = Helpers.getUser(Helpers.USER2)
        user3 = Helpers.getUser(Helpers.USER3)
        vote = self.createVote()
        vote_data1 = {"id": vote.id, "vote": True}
        vote_data2 = {"id": vote.id, "vote": False}
        vote_data3 = {"id": vote.id, "vote": True}
        url = self.url.format(vote.composition.id)

        self.client.login(
            username=user1.email, password=Helpers.USER1["password"])
        response = self.client.post(url, vote_data1)
        self.client.logout()

        self.client.login(
            username=user2.email, password=Helpers.USER2["password"])
        response = self.client.post(url, vote_data2)
        self.client.logout()

        self.client.login(
            username=user3.email, password=Helpers.USER3["password"])
        response = self.client.post(url, vote_data3)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            response.data, self.createResponse(vote.composition.id, 2, 1))
        vote = self.refreshFromDB(vote)
        self.assertEqual(vote.positive, 2)
        self.assertEqual(vote.negative, 1)
        self.assertEqual(vote.voters.all().count(), 3)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:33,代码来源:testVotes.py

示例2: test_post_throws_forbidden_for_authenticated_user_not_himself

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_post_throws_forbidden_for_authenticated_user_not_himself(self):
        user = Helpers.getUser(Helpers.USER1)
        other_user = Helpers.getUser(Helpers.USER2)
        composition = Helpers.createComposition(user)
        bookmark_data = {'bookmarks': [composition.id]}
        url = self.url.format(user.id)

        self.client.login(
            username=other_user.email, password=Helpers.USER2["password"])
        response = self.client.post(url, bookmark_data, format="json")

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
        self.assertEqual(user.bookmarks.all().count(), 0)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:15,代码来源:testBookmarks.py

示例3: test_get_throws_forbidden_when_user_not_himself

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_get_throws_forbidden_when_user_not_himself(self):
        user = Helpers.getUser(Helpers.USER1)
        other_user = Helpers.getUser(Helpers.USER2)
        composition1 = Helpers.createComposition(user)
        composition2 = Helpers.createComposition(user)
        user.bookmarks.add(composition1, composition2)
        url = self.url.format(user.id)

        self.client.login(
            username=other_user.email, password=Helpers.USER2["password"])
        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:15,代码来源:testBookmarks.py

示例4: test_delete_returns_forbidden_for_user_not_interpretationer

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_delete_returns_forbidden_for_user_not_interpretationer(self):
        user1 = Helpers.getUser(user_data=Helpers.USER1)
        Helpers.getUser(user_data=Helpers.USER2)
        composition = Helpers.getComposition(artist=user1)
        interpretation = Interpretation.objects.create(
            user=user1, composition=composition, interpretation="interpretation1"
        )
        url = "/compositions/{0}/interpretations/{1}".format(composition.id, interpretation.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,代码行数:15,代码来源:testSingleInterpretation.py

示例5: test_post_for_authenticated_user_empty_comment

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [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

示例6: test_post_for_authenticated_user_empty_interpretation

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_post_for_authenticated_user_empty_interpretation(self):
        user1 = Helpers.getUser(user_data=Helpers.USER1)
        Helpers.getUser(user_data=Helpers.USER2)
        composition = Helpers.getComposition(artist=user1)
        interpretation_data = {'interpretation': ''}
        url = '/compositions/{0}/interpretations'.format(composition.id)

        self.client.login(username='[email protected]', password='user2')
        response = self.client.post(url, data=interpretation_data)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(
            response.data, {"interpretation": ["This field is required."]})
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:15,代码来源:testListInterpretations.py

示例7: test_post_throws_forbidden_for_non_authenticated_user

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_post_throws_forbidden_for_non_authenticated_user(self):
        Helpers.getUser(Helpers.USER1)
        vote = self.createVote()
        vote_data = {"id": vote.id, "vote": True}
        url = self.url.format(vote.interpretation.composition.id, vote.interpretation.id)

        response = self.client.post(url, vote_data)

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
        vote = self.refreshFromDB(vote)
        self.assertEqual(vote.positive, 0)
        self.assertEqual(vote.negative, 0)
        self.assertEqual(vote.voters.all().count(), 0)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:15,代码来源:testInterpretationVotes.py

示例8: test_delete_for_autheticated_valid_interpretationer

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_delete_for_autheticated_valid_interpretationer(self):
        user1 = Helpers.getUser(user_data=Helpers.USER1)
        Helpers.getUser(user_data=Helpers.USER2)
        composition = Helpers.getComposition(artist=user1)
        interpretation = Interpretation.objects.create(
            user=user1, composition=composition, interpretation="interpretation1"
        )
        url = "/compositions/{0}/interpretations/{1}".format(composition.id, interpretation.id)

        self.client.login(username="[email protected]", password="user1")
        response = self.client.delete(url)

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        self.assertEqual(Interpretation.objects.all().count(), 0)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:16,代码来源:testSingleInterpretation.py

示例9: test_post_authenticated_user_valid_post_data

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_post_authenticated_user_valid_post_data(self):
        user1 = Helpers.getUser(user_data=Helpers.USER1)
        user2 = Helpers.getUser(user_data=Helpers.USER2)
        composition = Helpers.getComposition(artist=user1)
        interpretation_data = {'interpretation': 'interpretation1'}
        url = '/compositions/{0}/interpretations'.format(composition.id)

        self.client.login(username='[email protected]', password='user2')
        response = self.client.post(url, data=interpretation_data)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(response.data, self.createResponse(
            1, 'interpretation1', user2.id, composition.id, datetime.now()))
        self.assertEqual(Interpretation.objects.get(pk=1).interpretation, interpretation_data["interpretation"])
        self.assertEqual(Interpretation.objects.all().count(), 1)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:17,代码来源:testListInterpretations.py

示例10: test_delete_returns_forbidden_for_user_not_commenter

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [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

示例11: test_unread_returns_unread_notifications

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_unread_returns_unread_notifications(self):
        notification1_data = self.createNotification("Action1")
        self.createNotification("Action2")
        notification3_data = self.createNotification("Action3")
        notification = Notification.objects.get(pk=2)
        notification.unread = False
        notification.save()
        user = Helpers.getUser(Helpers.USER2)
        url = self.url + "/unread"

        self.client.login(
            username=user.email, password=Helpers.USER2["password"])
        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        expected_response = [self.createResponse(3,
                                                 user.id,
                                                 notification3_data["verb"],
                                                 datetime.now(),
                                                 notification3_data["actor"],
                                                 notification3_data[
                                                     "action_object"],
                                                 notification3_data["target"])]
        expected_response += [self.createResponse(1,
                                                  user.id,
                                                  notification1_data["verb"],
                                                  datetime.now(),
                                                  notification1_data["actor"],
                                                  notification1_data[
                                                      "action_object"],
                                                  notification1_data["target"])]
        self.assertEqual(response.data, expected_response)
开发者ID:,项目名称:,代码行数:34,代码来源:

示例12: test_all_returns_all_notifications

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_all_returns_all_notifications(self):
        notification1_data = self.createNotification()
        notification2_data = self.createNotification()
        user = Helpers.getUser(Helpers.USER2)

        self.client.login(
            username=user.email, password=Helpers.USER2["password"])
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        expected_response = [self.createResponse(2,
                                                 user.id,
                                                 notification2_data["verb"],
                                                 datetime.now(),
                                                 notification2_data["actor"],
                                                 notification2_data[
                                                     "action_object"],
                                                 notification2_data["target"])]
        expected_response += [self.createResponse(1,
                                                  user.id,
                                                  notification1_data["verb"],
                                                  datetime.now(),
                                                  notification1_data["actor"],
                                                  notification1_data[
                                                      "action_object"],
                                                  notification1_data["target"])]
        self.assertEqual(response.data, expected_response)
开发者ID:,项目名称:,代码行数:29,代码来源:

示例13: test_get_throws_forbidden_when_user_not_authenticated

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_get_throws_forbidden_when_user_not_authenticated(self):
        user = Helpers.getUser(Helpers.USER1)
        composition1 = Helpers.createComposition(user)
        composition2 = Helpers.createComposition(user)
        user.bookmarks.add(composition1, composition2)
        url = self.url.format(user.id)

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:12,代码来源:testBookmarks.py

示例14: test_update_for_autheticated_valid_interpretationer

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_update_for_autheticated_valid_interpretationer(self):
        user1 = Helpers.getUser(user_data=Helpers.USER1)
        Helpers.getUser(user_data=Helpers.USER2)
        composition = Helpers.getComposition(artist=user1)
        interpretation = Interpretation.objects.create(
            user=user1, composition=composition, interpretation="interpretation1"
        )
        interpretation_data = {"interpretation": "interpretation2"}
        url = "/compositions/{0}/interpretations/{1}".format(composition.id, interpretation.id)

        self.client.login(username="[email protected]", password="user1")
        response = self.client.put(url, data=interpretation_data)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(
            response.data, self.createResponse(1, "interpretation2", user1.id, composition.id, interpretation.created)
        )
        self.assertEqual(Interpretation.objects.all().count(), 1)
        self.assertEqual(Interpretation.objects.get(pk=1).interpretation, interpretation_data["interpretation"])
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:21,代码来源:testSingleInterpretation.py

示例15: test_post_returns_forbidden_for_not_authorized_user

# 需要导入模块: from api_test import Helpers [as 别名]
# 或者: from api_test.Helpers import getUser [as 别名]
    def test_post_returns_forbidden_for_not_authorized_user(self):
        user1 = Helpers.getUser(user_data=Helpers.USER1)
        composition = Helpers.getComposition(artist=user1)
        url = '/compositions/{0}/interpretations'.format(composition.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."})
开发者ID:RohitRepo,项目名称:ShowCase,代码行数:12,代码来源:testListInterpretations.py


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