def get_preprint_provider(self, obj): preprint_id = obj.get('preprint', None) if preprint_id: preprint = PreprintService.load(preprint_id) if preprint: provider = preprint.provider return {'url': provider.external_url, 'name': provider.name} return None
def test_create_preprint_adds_log_if_published(self): public_project_payload = build_preprint_create_payload( self.public_project._id, self.provider._id, self.file_one_public_project._id, { 'is_published': True, 'subjects': [[SubjectFactory()._id]], }) res = self.app.post_json_api(self.url, public_project_payload, auth=self.user.auth) assert_equal(res.status_code, 201) preprint_id = res.json['data']['id'] preprint = PreprintService.load(preprint_id) log = preprint.node.logs[-2] assert_equal(log.action, 'preprint_initiated') assert_equal(log.params.get('preprint'), preprint_id)
def test_create_preprint_adds_log_if_published(self): public_project_payload = build_preprint_create_payload( self.public_project._id, self.provider._id, self.file_one_public_project._id, { 'is_published': True, 'subjects': [[SubjectFactory()._id]], } ) res = self.app.post_json_api(self.url, public_project_payload, auth=self.user.auth) assert_equal(res.status_code, 201) preprint_id = res.json['data']['id'] preprint = PreprintService.load(preprint_id) log = preprint.node.logs[-2] assert_equal(log.action, 'preprint_initiated') assert_equal(log.params.get('preprint'), preprint_id)
def get_object(self, queryset=None): return PreprintService.load(self.kwargs.get('guid'))
def tearDown(self): super(TestPreprintList, self).tearDown() Node.remove() PreprintService.remove()