SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
e057ee06
Commit
e057ee06
authored
7 years ago
by
Geert Kapteijns
Browse files
Options
Downloads
Patches
Plain Diff
Start with DOICaller, which wraps crossref call and reading of JSON into class.
parent
c3088ebf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost/services.py
+19
-3
19 additions, 3 deletions
scipost/services.py
scipost/test_services.py
+10
-1
10 additions, 1 deletion
scipost/test_services.py
with
29 additions
and
4 deletions
scipost/services.py
+
19
−
3
View file @
e057ee06
...
...
@@ -9,6 +9,22 @@ from .behaviors import ArxivCallable
from
strings
import
arxiv_caller_errormessages
class
DOICaller
:
def
__init__
(
self
,
doi_string
):
self
.
doi_string
=
doi_string
self
.
_call_crosslink
()
self
.
_format_data
()
def
_call_crosslink
(
self
):
url
=
'
http://api.crossref.org/works/%s
'
%
self
.
doi_string
self
.
crossref_data
=
requests
.
get
(
url
).
json
()
def
_collect_data
(
self
):
# read out json here.
# I'm going to revamp this whole thing...
class
BaseCaller
(
object
):
'''
Base mixin for caller (Arxiv, DOI).
The basic workflow is to initiate the caller, call process() to make the actual call
...
...
@@ -158,9 +174,9 @@ class BaseCaller(object):
return
t
.
render
(
Context
(
self
.
errorvariables
))
class
DOICaller
(
BaseCaller
):
"""
Perform a DOI lookup for a given identifier.
"""
pass
#
class DOICaller(BaseCaller):
#
"""Perform a DOI lookup for a given identifier."""
#
pass
class
ArxivCaller
(
BaseCaller
):
...
...
This diff is collapsed.
Click to expand it.
scipost/test_services.py
+
10
−
1
View file @
e057ee06
from
django.test
import
TestCase
from
.services
import
ArxivCaller
from
.services
import
ArxivCaller
,
DOICaller
from
submissions.models
import
Submission
...
...
@@ -44,3 +44,12 @@ class ArxivCallerTest(TestCase):
caller
.
process
()
self
.
assertEqual
(
caller
.
is_valid
(),
False
)
self
.
assertEqual
(
caller
.
errorcode
,
'
bad_identifier
'
)
class
DOICallerTest
(
TestCase
):
def
setUp
(
self
):
self
.
doi_string
=
'
10.1103/PhysRevB.92.214427
'
self
.
caller
=
DOICaller
(
self
.
doi_string
)
def
test_collects_data
(
self
):
print
(
self
.
caller
.
crossref_data
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment