Beispiel #1
0
class Mutation(graphene.ObjectType):
    register_user = RegisterUser.Field()
    update_email = UpdateEmail.Field()
    update_send_reminder_emails = UpdateSendReminderEmails.Field()

    create_feedback_request = CreateFeedbackRequest.Field()
    delete_feedback_request = DeleteFeedbackRequest.Field()
    edit_feedback_request = EditFeedbackRequest.Field()
    submit_feedback_response = SubmitFeedbackResponse.Field()
    rate_feedback_response = RateFeedbackResponse.Field()
    add_feedback_response_reply = AddFeedbackResponseReply.Field()
    mark_replies_as_read = MarkRepliesAsRead.Field()

    token_auth = ObtainJSONWebTokenCaseInsensitive.Field()
Beispiel #2
0
    def test_no_account(self):
        info = Mock()
        result = (schema.get_mutation_type().fields["registerUser"].resolver(
            self=Mock(),
            info=info,
            email="*****@*****.**",
            password="******",
            password_repeat="sussexbythesea1901",
        ))

        self.assertEqual(result, RegisterUser(
            success=True,
            error=None,
        ))

        self.assertEqual(
            FeedbackGroupsUser.objects.filter(
                user__username="******", ).count(),
            1,
        )
Beispiel #3
0
    def test_weak_password(self):
        info = Mock()
        result = (schema.get_mutation_type().fields["registerUser"].resolver(
            self=Mock(),
            info=info,
            email="*****@*****.**",
            password="******",
            password_repeat="password",
        ))

        self.assertEqual(
            result,
            RegisterUser(
                success=False,
                error=INVALID_PASSWORD_MESSAGE,
            ))

        self.assertEqual(
            FeedbackGroupsUser.objects.filter(
                user__username="******", ).count(),
            0,
        )
Beispiel #4
0
    def test_nonmatching_passwords(self):
        info = Mock()
        result = (schema.get_mutation_type().fields["registerUser"].resolver(
            self=Mock(),
            info=info,
            email="*****@*****.**",
            password="******",
            password_repeat="woopsthisiswrong",
        ))

        self.assertEqual(
            result,
            RegisterUser(
                success=False,
                error="Passwords don't match.",
            ))

        self.assertEqual(
            FeedbackGroupsUser.objects.filter(
                user__username="******", ).count(),
            0,
        )
Beispiel #5
0
    def test_invalid_email(self):
        info = Mock()
        result = (schema.get_mutation_type().fields["registerUser"].resolver(
            self=Mock(),
            info=info,
            email="this is not an email",
            password="******",
            password_repeat="sussexbythesea1901",
        ))

        self.assertEqual(
            result,
            RegisterUser(
                success=False,
                error="Please provide a valid email address.",
            ),
        )

        self.assertEqual(
            FeedbackGroupsUser.objects.filter(
                user__username="******", ).count(),
            0,
        )
Beispiel #6
0
    def test_existing_account(self):
        info = Mock()
        result = (schema.get_mutation_type().fields["registerUser"].resolver(
            self=Mock(),
            info=info,
            email="*****@*****.**",
            password="******",
            password_repeat="sussexbythesea1901",
        ))

        self.assertEqual(
            result,
            RegisterUser(
                success=False,
                error="An account for that email address already exists.",
            ),
        )

        self.assertEqual(
            FeedbackGroupsUser.objects.filter(
                user__username="******", ).count(),
            1,
        )