diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-20 09:37:37 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-20 09:37:37 -0700 |
commit | bde5c8f14e13afe4d54e9bfafd8bda8b0f33f804 (patch) | |
tree | 67d7039b1621bebdafd89539602c2b5d05332501 /python/tests | |
parent | 698399c49edcefe33c012856b604985925969a77 (diff) | |
download | fatcat-bde5c8f14e13afe4d54e9bfafd8bda8b0f33f804.tar.gz fatcat-bde5c8f14e13afe4d54e9bfafd8bda8b0f33f804.zip |
python: refactor importer code (+crossref)
Diffstat (limited to 'python/tests')
-rw-r--r-- | python/tests/api_client.py | 15 | ||||
-rw-r--r-- | python/tests/crossref.py | 16 | ||||
-rw-r--r-- | python/tests/fixtures.py | 17 | ||||
-rw-r--r-- | python/tests/orcid.py | 2 |
4 files changed, 21 insertions, 29 deletions
diff --git a/python/tests/api_client.py b/python/tests/api_client.py deleted file mode 100644 index 9d2ec302..00000000 --- a/python/tests/api_client.py +++ /dev/null @@ -1,15 +0,0 @@ - -import pytest -import fatcat.api_client -from fixtures import * - - -# TODO: -#def test_client_health(api_client): -# assert api_client.health() != None - - -def test_import_crossref(api_client): - api_client.import_crossref_file('tests/files/crossref-works.2018-01-21.badsample.json') - - # TODO: use API to check that entities actually created... diff --git a/python/tests/crossref.py b/python/tests/crossref.py new file mode 100644 index 00000000..e72f7d02 --- /dev/null +++ b/python/tests/crossref.py @@ -0,0 +1,16 @@ + +import pytest +from fatcat.crossref_importer import FatcatCrossrefImporter + + +@pytest.fixture(scope="function") +def crossref_importer(): + yield FatcatCrossrefImporter("http://localhost:9411/v0") + +def test_crossref_importer_batch(crossref_importer): + with open('tests/files/crossref-works.2018-01-21.badsample.json', 'r') as f: + crossref_importer.process_batch(f) + +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) diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py index b1682e79..c9da9253 100644 --- a/python/tests/fixtures.py +++ b/python/tests/fixtures.py @@ -19,23 +19,12 @@ def app(full_app): @pytest.fixture(scope="function") -def api_client(full_app): - - # TODO: - #pid = os.fork() - #if pid == 0: - # full_app.testing = False - # full_app.run(host="localhost", port=8444, debug=False) - # os._exit(0) - # - #time.sleep(0.2) - #yield fatcat.api_client.FatCatApiClient("http://localhost:8444") - #os.kill(pid, signal.SIGKILL) - - yield fatcat.api_client.FatCatApiClient("http://localhost:9411") +def raw_api_client(): + yield fatcat.raw_api_client.RawFatcatApiClient("http://localhost:9411") ## Helpers ################################################################## +# TODO: what are these even here for? def check_entity_fields(e): for key in ('rev', 'is_live', 'redirect_id'): diff --git a/python/tests/orcid.py b/python/tests/orcid.py index 86a23603..d0e99cfc 100644 --- a/python/tests/orcid.py +++ b/python/tests/orcid.py @@ -2,10 +2,12 @@ import pytest from fatcat.orcid_importer import FatcatOrcidImporter + @pytest.fixture(scope="function") def orcid_importer(): yield FatcatOrcidImporter("http://localhost:9411/v0") +# TODO: use API to check that entities actually created... def test_orcid_importer_batch(orcid_importer): with open('tests/files/0000-0001-8254-7103.json', 'r') as f: orcid_importer.process_batch(f) |