Пример #1
0
 def test_no_login_presend_for_inactive_user(self, mock_mail):
     user = factories.AuthUserFactory()
     mail = self.queue_mail(mail=mails.NO_LOGIN, user=user)
     user.date_last_login = datetime.utcnow() - timedelta(weeks=10)
     user.save()
     assert_true(datetime.utcnow() - timedelta(days=1) > user.date_last_login)
     assert_true(mail.send_mail())
Пример #2
0
 def test_is_pending_embargo_searches_parents(self):
     user = factories.AuthUserFactory()
     node = factories.NodeFactory(creator=user)
     child = factories.NodeFactory(creator=user, parent=node)
     factories.NodeFactory(creator=user, parent=child)
     with mock_archive(node, embargo=True) as registration:
         sub_reg = registration.nodes[0].nodes[0]
         assert_true(sub_reg.is_pending_embargo)
Пример #3
0
    def test_disabled_user_gets_error(self):

        user = factories.AuthUserFactory()

        res = self.app.get('/{}nodes/'.format(API_BASE),
                           auth=user.auth,
                           expect_errors=True)
        assert_equal(res.status_code, http.BAD_REQUEST)
Пример #4
0
    def setUp(self):
        super(TestODMTitleSearch, self).setUp()

        self.user = factories.AuthUserFactory()
        self.user_two = factories.AuthUserFactory()
        self.project = factories.ProjectFactory(creator=self.user, title="foo")
        self.project_two = factories.ProjectFactory(creator=self.user_two,
                                                    title="bar")
        self.public_project = factories.ProjectFactory(creator=self.user_two,
                                                       is_public=True,
                                                       title="baz")
        self.registration_project = factories.RegistrationFactory(
            creator=self.user, title="qux")
        self.folder = factories.CollectionFactory(creator=self.user,
                                                  title="quux")
        self.dashboard = find_bookmark_collection(self.user)
        self.url = api_url_for('search_projects_by_title')
Пример #5
0
 def setUp(self):
     super(TestFileUpdated, self).setUp()
     self.user_1 = factories.AuthUserFactory()
     self.auth = Auth(user=self.user_1)
     self.user_2 = factories.AuthUserFactory()
     self.project = factories.ProjectFactory(creator=self.user_1)
     # subscription
     self.sub = factories.NotificationSubscriptionFactory(
         _id=self.project._id + 'file_updated',
         owner=self.project,
         event_name='file_updated',
     )
     self.sub.save()
     self.event = event_registry['file_updated'](self.user_2,
                                                 self.project,
                                                 'file_updated',
                                                 payload=file_payload)
Пример #6
0
 def test_sanction_searches_parents(self):
     user = factories.AuthUserFactory()
     node = factories.NodeFactory(creator=user)
     child = factories.NodeFactory(creator=user, parent=node)
     factories.NodeFactory(creator=user, parent=child)
     with mock_archive(node) as registration:
         approval = registration.registration_approval
         sub_reg = registration.nodes[0].nodes[0]
         assert_equal(sub_reg.sanction, approval)
Пример #7
0
 def test_auth_login_with_campaign_logged_in(self):
     ensure_schemas()
     url = web_url_for('auth_login', campaign='prereg')
     user = factories.AuthUserFactory()
     with self.app.app.test_request_context(url), mock_auth(user):
         res = auth_views.auth_login()
         assert_equal(res.status_code, http.FOUND)
         assert_equal(res.location,
                      campaigns.CAMPAIGNS['prereg']['redirect_url']())
Пример #8
0
    def test_non_contributor_GET_disapproval_returns_HTTPError(self, mock_enqueue):
        non_contributor = factories.AuthUserFactory()

        rejection_token = self.registration.registration_approval.approval_state[self.user._id]['rejection_token']
        rejection_url = self.registration.web_url_for('view_project', token=rejection_token)

        res = self.app.get(rejection_url, auth=non_contributor.auth, expect_errors=True)
        assert_equal(http.FORBIDDEN, res.status_code)
        assert_true(self.registration.is_pending_registration)
        assert_false(self.registration.is_registration_approved)
Пример #9
0
 def test_is_registration_approved_searches_parents(self):
     user = factories.AuthUserFactory()
     node = factories.NodeFactory(creator=user)
     child = factories.NodeFactory(creator=user, parent=node)
     factories.NodeFactory(creator=user, parent=child)
     with mock_archive(node) as registration:
         with mock.patch('website.project.sanctions.Sanction.is_approved',
                         mock.Mock(return_value=True)):
             sub_reg = registration.nodes[0].nodes[0]
             assert_true(sub_reg.is_registration_approved)
Пример #10
0
    def setUp(self):
        super(TestJSONAPIPagination, self).setUp()

        self.url_version_2_0 = '/{}nodes/'.format(settings.API_BASE)
        self.url_version_2_1 = '/{}nodes/?version=2.1'.format(
            settings.API_BASE)
        self.user = factories.AuthUserFactory()

        for i in range(0, 11):
            factories.ProjectFactory(creator=self.user)
Пример #11
0
    def setUp(self):
        super(TestNodeEmbargoTerminations, self).setUp()

        self.user = factories.AuthUserFactory()
        self.node = factories.ProjectFactory(creator=self.user)
        with mock_archive(self.node, embargo=True,
                          autoapprove=True) as registration:
            self.registration = registration

        self.not_embargoed = factories.RegistrationFactory()
Пример #12
0
    def setUp(self):
        super(TestJSONAPIBaseView, self).setUp()

        self.user = factories.AuthUserFactory()
        self.node = factories.ProjectFactory(creator=self.user)
        self.url = '/{0}nodes/{1}/'.format(API_BASE, self.node._id)
        for i in range(5):
            factories.ProjectFactory(parent=self.node, creator=self.user)
        for i in range(5):
            factories.ProjectFactory(parent=self.node)
Пример #13
0
 def test_is_retracted_searches_parents(self):
     user = factories.AuthUserFactory()
     node = factories.NodeFactory(creator=user)
     child = factories.NodeFactory(creator=user, parent=node)
     factories.NodeFactory(creator=user, parent=child)
     with mock_archive(node,
                       autoapprove=True,
                       retraction=True,
                       autoapprove_retraction=True) as registration:
         sub_reg = registration.nodes[0].nodes[0]
         assert_true(sub_reg.is_retracted)
Пример #14
0
    def setUp(self):
        super(TestApiBaseSerializers, self).setUp()
        self.user = factories.AuthUserFactory()
        self.auth = factories.Auth(self.user)
        self.node = factories.ProjectFactory(is_public=True)

        for i in range(5):
            factories.ProjectFactory(is_public=True, parent=self.node)
        self.linked_node = factories.NodeFactory(creator=self.user, is_public=True)
        self.node.add_pointer(self.linked_node, auth=self.auth)

        self.url = '/{}nodes/{}/'.format(API_BASE, self.node._id)
Пример #15
0
 def setUp(self):
     super(TestFileCopied, self).setUp()
     self.user_1 = factories.AuthUserFactory()
     self.auth = Auth(user=self.user_1)
     self.user_2 = factories.AuthUserFactory()
     self.user_3 = factories.AuthUserFactory()
     self.user_4 = factories.AuthUserFactory()
     self.project = factories.ProjectFactory(creator=self.user_1)
     self.private_node = factories.NodeFactory(parent=self.project,
                                               is_public=False,
                                               creator=self.user_1)
     # Payload
     file_copied_payload = file_copy_payload(self.private_node,
                                             self.project)
     self.event = event_registry['addon_file_copied'](
         self.user_2,
         self.private_node,
         'addon_file_copied',
         payload=file_copied_payload)
     # Subscriptions
     # for parent node
     self.sub = factories.NotificationSubscriptionFactory(
         _id=self.project._id + '_file_updated',
         owner=self.project,
         event_name='file_updated')
     self.sub.save()
     # for private node
     self.private_sub = factories.NotificationSubscriptionFactory(
         _id=self.private_node._id + '_file_updated',
         owner=self.private_node,
         event_name='file_updated')
     self.private_sub.save()
     # for file subscription
     self.file_sub = factories.NotificationSubscriptionFactory(
         _id='{pid}_{wbid}_file_updated'.format(
             pid=self.project._id, wbid=self.event.waterbutler_id),
         owner=self.project,
         event_name='xyz42_file_updated')
     self.file_sub.save()
Пример #16
0
    def setUp(self):
        super(TestFolderFileRenamed, self).setUp()
        self.user_1 = factories.AuthUserFactory()
        self.auth = Auth(user=self.user_1)
        self.user_2 = factories.AuthUserFactory()
        self.project = factories.ProjectFactory(creator=self.user_1)
        # subscription
        self.sub = factories.NotificationSubscriptionFactory(
            _id=self.project._id + 'file_updated',
            owner=self.project,
            event_name='file_updated',
        )
        self.sub.save()

        # Payload
        file_renamed_payload = file_move_payload(self.project, self.project)
        self.event = event_registry['addon_file_renamed'](
            self.user_1,
            self.project,
            'addon_file_renamed',
            payload=file_renamed_payload)
        self.sub.email_digest.append(self.user_2)
        self.sub.save()
Пример #17
0
    def setUp(self):
        super(UserTestCase, self).setUp()
        self.user = factories.AuthUserFactory()
        self.unregistered = factories.UnregUserFactory()
        self.unconfirmed = factories.UnconfirmedUserFactory()
        self.USERS = (self.user, self.unregistered, self.unconfirmed)

        factories.ProjectFactory(creator=self.user)
        self.project_with_unreg_contrib = factories.ProjectFactory()
        self.project_with_unreg_contrib.add_unregistered_contributor(
            fullname='Unreg',
            email=self.unregistered.username,
            auth=auth.Auth(self.project_with_unreg_contrib.creator))
        self.project_with_unreg_contrib.save()

        self.user.system_tags = ['shared', 'user']
        self.unconfirmed.system_tags = ['shared', 'unconfirmed']

        self.user.aka = ['shared', 'user']
        self.unconfirmed.aka = ['shared', 'unconfirmed']
Пример #18
0
 def setUp(self):
     super(TestCampaignsAuthViews, self).setUp();
     self.campaigns = {
         'prereg': {
             'title_register': 'Preregistration Challenge',
             'title_landing': 'Welcome to the Prereg Challenge!'
         },
         'erpc': {
             'title_register': 'Election Research Preacceptance Competition',
             'title_landing': 'Welcome to the Election Research Preacceptance Competition!'
         },
         'osf-preprints': {
             'title_register': 'OSF Preprint Service',
             'title_landing': 'OSF Preprints'
         }
     }
     for key, value in self.campaigns.items():
         value.update({'url_login': web_url_for('auth_login', campaign=key)})
         value.update({'url_register': web_url_for('auth_register', campaign=key)})
         value.update({'url_landing': campaigns.campaign_url_for(key)})
     self.user = factories.AuthUserFactory()
Пример #19
0
    def setUp(self):
        super(PreregViewsTests, self).setUp()

        ensure_schemas()

        self.osf_user = factories.AuthUserFactory()
        password = fake.password(),
        self.user = User.objects.create(email=fake.email(),
                                        first_name=fake.first_name(),
                                        last_name=fake.last_name(),
                                        osf_id=self.osf_user._id)
        self.user.set_password(password)
        self.user.save()
        self.logged_in = self.client.login(username=self.user.email,
                                           password=password)
        PREREG_GROUP.user_set.add(self.user)
        PREREG_GROUP.save()

        self.prereg_schema = MetaSchema.find_one(
            Q('name', 'eq', 'Prereg Challenge') & Q('schema_version', 'eq', 2))
        self.other_schema = MetaSchema.find(
            Q('name', 'ne', 'Prereg Challenge')
            & Q('schema_version', 'eq', 2))[0]
Пример #20
0
 def setUp(self):
     OsfTestCase.setUp(self)
     self.user = factories.AuthUserFactory()
     self.user.is_registered = True
     self.user.save()
Пример #21
0
 def setUp(self):
     super(TestRegistrationApproval, self).setUp()
     ensure_schemas()
     self.user = factories.AuthUserFactory()
     self.registration = factories.RegistrationFactory(creator=self.user, archive=True)
Пример #22
0
 def test_no_login_presend_for_active_user(self, mock_mail):
     user = factories.AuthUserFactory()
     mail = self.queue_mail(mail=mails.NO_LOGIN, user=user)
     user.date_last_login = datetime.utcnow() + timedelta(seconds=10)
     user.save()
     assert_false(mail.send_mail())
Пример #23
0
 def setUp(self):
     super(TestUser, self).setUp()
     self.user = factories.AuthUserFactory()