def test_doesnt_return_retractions_with_auth(self): retraction = WithdrawnRegistrationFactory(registration=self.registration2, user=self.user1) assert_true(self.registration2.is_retracted) res = self.app.get(self.institution_node_url, auth=self.user1.auth) assert_equal(res.status_code, 200) ids = [each['id'] for each in res.json['data']] assert_not_in(self.registration2._id, ids)
def setUp(self): super(TestWithdrawnRegistrations, self).setUp() self.registration = RegistrationFactory(creator=self.user, project=self.public_project) self.withdrawn_registration = WithdrawnRegistrationFactory(registration=self.registration, user=self.registration.creator) self.public_pointer_project = ProjectFactory(is_public=True) self.public_pointer = self.public_project.add_pointer(self.public_pointer_project, auth=Auth(self.user), save=True) self.withdrawn_url = '/{}registrations/{}/'.format(API_BASE, self.registration._id) self.withdrawn_registration.justification = 'We made a major error.' self.withdrawn_registration.save()
def setUp(self): super(TestNodeCount, self).setUp() self.user = UserFactory() # 3 Projects - Public, Private, Private Component self.public_project = ProjectFactory(is_public=True) self.private_project = ProjectFactory(is_public=False) self.private_component = ProjectFactory(parent=self.private_project) # 5 Registrations - Public, Public Registrations of Private Proj + Component, Embargoed, Withdrawn self.public_registration = RegistrationFactory(project=self.public_project, is_public=True) self.registration_of_components = RegistrationFactory(project=self.private_project, is_public=True) registration_of_component = self.private_component.registrations_all[0] registration_of_component.is_public = True registration_of_component.save() self.embargoed_registration = RegistrationFactory(project=self.public_project, creator=self.user) self.embargoed_registration.embargo_registration( self.user, datetime.datetime.utcnow() + datetime.timedelta(days=10) ) self.embargoed_registration.save() self.reg_to_be_withdrawn = RegistrationFactory(project=self.public_project) self.withdrawn_registration = WithdrawnRegistrationFactory( registration=self.reg_to_be_withdrawn, user=self.reg_to_be_withdrawn.creator ) # Add Deleted Nodes self.deleted_node = ProjectFactory(is_deleted=True) self.deleted_node2 = ProjectFactory(is_deleted=True) self.date = datetime.datetime.utcnow() - datetime.timedelta(1) modify_node_dates_in_mongo(self.date - datetime.timedelta(0.1)) self.results = NodeSummary().get_events(self.date.date())[0]
def test_cannot_fork_retractions(self): retraction = WithdrawnRegistrationFactory(registration=self.private_registration, user=self.user) url = '/{}registrations/{}/forks/'.format(API_BASE, self.private_registration._id) + '?embed=forked_from' res = self.app.post_json_api(url, self.fork_data, auth=self.user.auth, expect_errors=True) assert_equal(res.status_code, 403)