summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-08 14:59:38 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-08 14:59:38 -0800
commit8c930ded07b6a668bc1721ef98312d9259c06b59 (patch)
treece31708556d17d7165a64f15d0dac78d881e80bc /python/tests
parentd1862ea4a6dcb781713ffc54bdc4bd7d7cdbdb9e (diff)
downloadfatcat-8c930ded07b6a668bc1721ef98312d9259c06b59.tar.gz
fatcat-8c930ded07b6a668bc1721ef98312d9259c06b59.zip
importers and tests all use new api-passing
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/import_crossref.py2
-rw-r--r--python/tests/import_grobid_metadata.py13
-rw-r--r--python/tests/import_issn.py13
-rw-r--r--python/tests/import_matched.py13
-rw-r--r--python/tests/import_orcid.py13
-rw-r--r--python/tests/importer.py9
-rw-r--r--python/tests/transform_tests.py1
7 files changed, 51 insertions, 13 deletions
diff --git a/python/tests/import_crossref.py b/python/tests/import_crossref.py
index 3ef97719..e2ca6122 100644
--- a/python/tests/import_crossref.py
+++ b/python/tests/import_crossref.py
@@ -28,7 +28,7 @@ def test_crossref_importer(crossref_importer):
assert eg.description
assert "crossref" in eg.description.lower()
assert eg.extra['git_rev']
- assert "CrossrefImporter" in eg.extra['agent']
+ assert "fatcat_tools.CrossrefImporter" in eg.extra['agent']
def test_crossref_mappings(crossref_importer):
assert crossref_importer.map_release_type('journal-article') == "article-journal"
diff --git a/python/tests/import_grobid_metadata.py b/python/tests/import_grobid_metadata.py
index 459b247b..97ebcaef 100644
--- a/python/tests/import_grobid_metadata.py
+++ b/python/tests/import_grobid_metadata.py
@@ -4,6 +4,7 @@ import json
import base64
import pytest
from fatcat_tools.importers import GrobidMetadataImporter
+from fixtures import api
"""
WARNING: these tests are currently very fragile because they have database
@@ -11,8 +12,8 @@ side-effects. Should probably be disabled or re-written.
"""
@pytest.fixture(scope="function")
-def grobid_metadata_importer():
- yield GrobidMetadataImporter("http://localhost:9411/v0")
+def grobid_metadata_importer(api):
+ yield GrobidMetadataImporter(api)
# TODO: use API to check that entities actually created...
#def test_grobid_metadata_importer_batch(grobid_metadata_importer):
@@ -54,3 +55,11 @@ def test_file_metadata_parse(grobid_metadata_importer):
def test_grobid_metadata_importer(grobid_metadata_importer):
with open('tests/files/example_grobid_metadata_lines.tsv', 'r') as f:
grobid_metadata_importer.process_source(f)
+
+ # fetch most recent editgroup
+ changes = grobid_metadata_importer.api.get_changelog(limit=1)
+ eg = changes[0].editgroup
+ assert eg.description
+ assert "grobid" in eg.description.lower()
+ assert eg.extra['git_rev']
+ assert "fatcat_tools.GrobidMetadataImporter" in eg.extra['agent']
diff --git a/python/tests/import_issn.py b/python/tests/import_issn.py
index 98a9f4a7..6b5978d9 100644
--- a/python/tests/import_issn.py
+++ b/python/tests/import_issn.py
@@ -1,11 +1,12 @@
import pytest
from fatcat_tools.importers import IssnImporter
+from fixtures import api
@pytest.fixture(scope="function")
-def issn_importer():
- yield IssnImporter("http://localhost:9411/v0")
+def issn_importer(api):
+ yield IssnImporter(api)
# TODO: use API to check that entities actually created...
def test_issn_importer_batch(issn_importer):
@@ -15,3 +16,11 @@ def test_issn_importer_batch(issn_importer):
def test_issn_importer(issn_importer):
with open('tests/files/journal_extra_metadata.snip.csv', 'r') as f:
issn_importer.process_csv_source(f)
+
+ # fetch most recent editgroup
+ changes = issn_importer.api.get_changelog(limit=1)
+ eg = changes[0].editgroup
+ assert eg.description
+ assert "container" in eg.description.lower()
+ assert eg.extra['git_rev']
+ assert "fatcat_tools.IssnImporter" in eg.extra['agent']
diff --git a/python/tests/import_matched.py b/python/tests/import_matched.py
index 46a9ef85..080674ac 100644
--- a/python/tests/import_matched.py
+++ b/python/tests/import_matched.py
@@ -2,11 +2,12 @@
import json
import pytest
from fatcat_tools.importers import MatchedImporter
+from fixtures import api
@pytest.fixture(scope="function")
-def matched_importer():
- yield MatchedImporter("http://localhost:9411/v0")
+def matched_importer(api):
+ yield MatchedImporter(api)
# TODO: use API to check that entities actually created...
def test_matched_importer_batch(matched_importer):
@@ -17,6 +18,14 @@ def test_matched_importer(matched_importer):
with open('tests/files/example_matched.json', 'r') as f:
matched_importer.process_source(f)
+ # fetch most recent editgroup
+ changes = matched_importer.api.get_changelog(limit=1)
+ eg = changes[0].editgroup
+ assert eg.description
+ assert "file-to-release" in eg.description.lower()
+ assert eg.extra['git_rev']
+ assert "fatcat_tools.MatchedImporter" in eg.extra['agent']
+
def test_matched_dict_parse(matched_importer):
with open('tests/files/example_matched.json', 'r') as f:
raw = json.loads(f.readline())
diff --git a/python/tests/import_orcid.py b/python/tests/import_orcid.py
index 18199888..717a1328 100644
--- a/python/tests/import_orcid.py
+++ b/python/tests/import_orcid.py
@@ -2,11 +2,12 @@
import json
import pytest
from fatcat_tools.importers import OrcidImporter
+from fixtures import api
@pytest.fixture(scope="function")
-def orcid_importer():
- yield OrcidImporter("http://localhost:9411/v0")
+def orcid_importer(api):
+ yield OrcidImporter(api)
# TODO: use API to check that entities actually created...
def test_orcid_importer_batch(orcid_importer):
@@ -21,6 +22,14 @@ def test_orcid_importer(orcid_importer):
with open('tests/files/0000-0001-8254-7103.json', 'r') as f:
orcid_importer.process_source(f)
+ # fetch most recent editgroup
+ changes = orcid_importer.api.get_changelog(limit=1)
+ eg = changes[0].editgroup
+ assert eg.description
+ assert "orcid" in eg.description.lower()
+ assert eg.extra['git_rev']
+ assert "fatcat_tools.OrcidImporter" in eg.extra['agent']
+
def test_orcid_importer_x(orcid_importer):
with open('tests/files/0000-0003-3953-765X.json', 'r') as f:
orcid_importer.process_source(f)
diff --git a/python/tests/importer.py b/python/tests/importer.py
index f228a9b2..34efa5d8 100644
--- a/python/tests/importer.py
+++ b/python/tests/importer.py
@@ -2,11 +2,12 @@
import pytest
from fatcat_tools.importers import FatcatImporter
+from fixtures import api
-def test_issnl_mapping_lookup():
+def test_issnl_mapping_lookup(api):
with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- fi = FatcatImporter("http://localhost:9411/v0", issn_file)
+ fi = FatcatImporter(api, issn_map_file=issn_file)
assert fi.issn2issnl('0000-0027') == '0002-0027'
assert fi.issn2issnl('0002-0027') == '0002-0027'
@@ -14,10 +15,10 @@ def test_issnl_mapping_lookup():
assert fi.lookup_issnl('9999-9999') == None
-def test_identifiers():
+def test_identifiers(api):
with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- fi = FatcatImporter("http://localhost:9411/v0", issn_file)
+ fi = FatcatImporter(api, issn_map_file=issn_file)
assert fi.is_issnl("1234-5678") == True
assert fi.is_issnl("1234-5678.") == False
diff --git a/python/tests/transform_tests.py b/python/tests/transform_tests.py
index a42db244..e9d23250 100644
--- a/python/tests/transform_tests.py
+++ b/python/tests/transform_tests.py
@@ -3,6 +3,7 @@ import json
import pytest
from fatcat_tools import *
from fatcat_client import *
+from fixtures import api
from import_crossref import crossref_importer