Esempio n. 1
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'])
Esempio n. 2
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'])
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 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",
        )
Esempio n. 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",
        )
Esempio n. 7
0
    def test_query_by_receiver(self):
        """Test query by receiver."""
        from zenodo.modules.accessrequests.models import AccessRequest
        self.assertEqual(
            AccessRequest.query_by_receiver(self.receiver).count(), 0)
        self.assertEqual(
            AccessRequest.query_by_receiver(self.sender).count(), 0)

        # Create an accesrequest
        r = self.get_request(confirmed=False)

        self.assertEqual(
            AccessRequest.query_by_receiver(self.receiver).count(), 1)
        self.assertEqual(
            AccessRequest.query_by_receiver(self.sender).count(), 0)

        self.assertIsNotNone(AccessRequest.get_by_receiver(
            r.id, self.receiver))
        self.assertIsNone(AccessRequest.get_by_receiver(r.id, self.sender))
Esempio n. 8
0
    def test_query_by_receiver(self):
        """Test query by receiver."""
        from zenodo.modules.accessrequests.models import AccessRequest
        self.assertEqual(
            AccessRequest.query_by_receiver(self.receiver).count(),
            0)
        self.assertEqual(
            AccessRequest.query_by_receiver(self.sender).count(),
            0)

        # Create an accesrequest
        r = self.get_request(confirmed=False)

        self.assertEqual(
            AccessRequest.query_by_receiver(self.receiver).count(),
            1)
        self.assertEqual(
            AccessRequest.query_by_receiver(self.sender).count(),
            0)

        self.assertIsNotNone(AccessRequest.get_by_receiver(
            r.id, self.receiver))
        self.assertIsNone(AccessRequest.get_by_receiver(
            r.id, self.sender))