summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/fixtures.py5
-rw-r--r--python/tests/import_crossref.py16
2 files changed, 16 insertions, 5 deletions
diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py
index c415abef..6a880c48 100644
--- a/python/tests/fixtures.py
+++ b/python/tests/fixtures.py
@@ -4,12 +4,14 @@ import time
import json
import signal
import pytest
+from dotenv import load_dotenv
import fatcat_web
import fatcat_client
@pytest.fixture
def full_app():
+ load_dotenv(dotenv_path="./env.example")
fatcat_web.app.testing = True
fatcat_web.app.debug = False
return fatcat_web.app
@@ -20,9 +22,10 @@ def app(full_app):
@pytest.fixture
def api():
+ load_dotenv(dotenv_path="./env.example")
conf = fatcat_client.Configuration()
conf.host = "http://localhost:9411/v0"
- conf.api_key["Authorization"] = "AgEPZGV2LmZhdGNhdC53aWtpAg4yMDE4LTEyLTMxLWRldgACJmVkaXRvcl9pZCA9IGFhYWFhYWFhYWFhYWJrdmthYWFhYWFhYWFlAAIeY3JlYXRlZCA9IDIwMTgtMTItMzFUMjE6MTU6NDdaAAAGIMWFZeZ54pH4OzNl5+U5X3p1H1rMioSuIldihuiM5XAw"
+ conf.api_key["Authorization"] = os.getenv("FATCAT_API_AUTH_TOKEN")
conf.api_key_prefix["Authorization"] = "Bearer"
api_client = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))
return api_client
diff --git a/python/tests/import_crossref.py b/python/tests/import_crossref.py
index 1fb4a70f..3ef97719 100644
--- a/python/tests/import_crossref.py
+++ b/python/tests/import_crossref.py
@@ -2,17 +2,18 @@
import json
import pytest
from fatcat_tools.importers import CrossrefImporter
+from fixtures import api
@pytest.fixture(scope="function")
-def crossref_importer():
+def crossref_importer(api):
with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- yield CrossrefImporter("http://localhost:9411/v0", issn_file, 'tests/files/example_map.sqlite3', check_existing=False)
+ yield CrossrefImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', check_existing=False)
@pytest.fixture(scope="function")
-def crossref_importer_existing():
+def crossref_importer_existing(api):
with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- yield CrossrefImporter("http://localhost:9411/v0", issn_file, 'tests/files/example_map.sqlite3', check_existing=True)
+ yield CrossrefImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', check_existing=True)
def test_crossref_importer_batch(crossref_importer):
with open('tests/files/crossref-works.2018-01-21.badsample.json', 'r') as f:
@@ -21,6 +22,13 @@ def test_crossref_importer_batch(crossref_importer):
def test_crossref_importer(crossref_importer):
with open('tests/files/crossref-works.2018-01-21.badsample.json', 'r') as f:
crossref_importer.process_source(f)
+ # fetch most recent editgroup
+ changes = crossref_importer.api.get_changelog(limit=1)
+ eg = changes[0].editgroup
+ assert eg.description
+ assert "crossref" in eg.description.lower()
+ assert eg.extra['git_rev']
+ assert "CrossrefImporter" in eg.extra['agent']
def test_crossref_mappings(crossref_importer):
assert crossref_importer.map_release_type('journal-article') == "article-journal"