示例#1
0
    def test_create_withuser(self):
        """Test access request creation with user."""
        from zenodo.modules.accessrequests.models import AccessRequest, \
            RequestStatus
        from zenodo.modules.accessrequests.signals import \
            request_created, request_confirmed

        with request_created.connected_to(self.get_receiver('created')):
            with request_confirmed.connected_to(
                    self.get_receiver('confirmed')):
                r = AccessRequest.create(
                    recid=1,
                    receiver=self.receiver,
                    sender_full_name="Another Name",
                    sender_email="*****@*****.**",
                    sender=self.sender,
                    justification="Bla bla bla",
                )

                self.assertEqual(r.status, RequestStatus.PENDING)
                self.assertEqual(r.sender_user_id, self.sender.get_id())
                self.assertIsNotNone(r.created)
                self.assertIsNotNone(r.modified)
                self.assertEqual(r.message, u'')
                self.assertEqual(r.sender_full_name, u'Another Name')
                self.assertEqual(r.sender_email, u'*****@*****.**')

                self.assertIsNone(self.called['created'])
                self.assertIsNotNone(self.called['confirmed'])
示例#2
0
    def test_create_nouser(self):
        """Test access request creation without user."""
        from zenodo.modules.accessrequests.models import AccessRequest, \
            RequestStatus
        from zenodo.modules.accessrequests.signals import \
            request_created, request_confirmed

        with request_created.connected_to(self.get_receiver('created')):
            with request_confirmed.connected_to(
                    self.get_receiver('confirmed')):

                r = AccessRequest.create(
                    recid=1,
                    receiver=self.receiver,
                    sender_full_name="John Smith",
                    sender_email="*****@*****.**",
                    justification="Bla bla bla",
                )

                self.assertEqual(r.status, RequestStatus.EMAIL_VALIDATION)
                self.assertIsNone(r.sender_user_id)
                self.assertIsNotNone(r.created)
                self.assertIsNotNone(r.modified)
                self.assertEqual(r.message, u'')

                self.assertIsNotNone(self.called['created'])
                self.assertIsNone(self.called['confirmed'])
示例#3
0
    def test_create_withuser(self):
        """Test access request creation with user."""
        from zenodo.modules.accessrequests.models import AccessRequest, \
            RequestStatus
        from zenodo.modules.accessrequests.signals import \
            request_created, request_confirmed

        with request_created.connected_to(self.get_receiver('created')):
            with request_confirmed.connected_to(
                 self.get_receiver('confirmed')):
                r = AccessRequest.create(
                    recid=1,
                    receiver=self.receiver,
                    sender_full_name="Another Name",
                    sender_email="*****@*****.**",
                    sender=self.sender,
                    justification="Bla bla bla",
                )

                self.assertEqual(r.status, RequestStatus.PENDING)
                self.assertEqual(r.sender_user_id, self.sender.get_id())
                self.assertIsNotNone(r.created)
                self.assertIsNotNone(r.modified)
                self.assertEqual(r.message, u'')
                self.assertEqual(r.sender_full_name, u'Another Name')
                self.assertEqual(r.sender_email, u'*****@*****.**')

                self.assertIsNone(self.called['created'])
                self.assertIsNotNone(self.called['confirmed'])
示例#4
0
    def test_create_nouser(self):
        """Test access request creation without user."""
        from zenodo.modules.accessrequests.models import AccessRequest, \
            RequestStatus
        from zenodo.modules.accessrequests.signals import \
            request_created, request_confirmed

        with request_created.connected_to(self.get_receiver('created')):
            with request_confirmed.connected_to(
                 self.get_receiver('confirmed')):

                r = AccessRequest.create(
                    recid=1,
                    receiver=self.receiver,
                    sender_full_name="John Smith",
                    sender_email="*****@*****.**",
                    justification="Bla bla bla",
                )

                self.assertEqual(r.status, RequestStatus.EMAIL_VALIDATION)
                self.assertIsNone(r.sender_user_id)
                self.assertIsNotNone(r.created)
                self.assertIsNotNone(r.modified)
                self.assertEqual(r.message, u'')

                self.assertIsNotNone(self.called['created'])
                self.assertIsNone(self.called['confirmed'])
示例#5
0
    def get_request(self, confirmed=False):
        """Create an access request."""
        from zenodo.modules.accessrequests.models import AccessRequest

        return AccessRequest.create(
            recid=1,
            receiver=self.receiver,
            sender_full_name="Another Name",
            sender_email="*****@*****.**",
            sender=self.sender if confirmed else None,
            justification="Bla bla bla",
        )
示例#6
0
    def get_request(self, confirmed=False):
        """Create an access request."""
        from zenodo.modules.accessrequests.models import AccessRequest

        return AccessRequest.create(
            recid=1,
            receiver=self.receiver,
            sender_full_name="Another Name",
            sender_email="*****@*****.**",
            sender=self.sender if confirmed else None,
            justification="Bla bla bla",
        )