diff options
Diffstat (limited to 'python/tests')
45 files changed, 54 insertions, 150 deletions
diff --git a/python/tests/api_annotations.py b/python/tests/api_annotations.py index e5566eef..0606b637 100644 --- a/python/tests/api_annotations.py +++ b/python/tests/api_annotations.py @@ -1,10 +1,5 @@ -import json -import pytest -from copy import copy - from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * diff --git a/python/tests/api_containers.py b/python/tests/api_containers.py index 0850fab7..70dbcd7e 100644 --- a/python/tests/api_containers.py +++ b/python/tests/api_containers.py @@ -1,10 +1,5 @@ -import json -import pytest -from copy import copy - from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -43,7 +38,7 @@ def test_container(api): # get redirects (none) assert api.get_container_redirects(c2.ident) == [] - + # delete eg = quick_eg(api) api.delete_container(eg.editgroup_id, c2.ident) @@ -59,4 +54,3 @@ def test_container_examples(api): c2 = api.lookup_container(issnl=c1.issnl) assert c1.ident == c2.ident - diff --git a/python/tests/api_creators.py b/python/tests/api_creators.py index 1ce6380a..b271e2b3 100644 --- a/python/tests/api_creators.py +++ b/python/tests/api_creators.py @@ -1,10 +1,5 @@ -import json -import pytest -from copy import copy - from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -52,7 +47,7 @@ def test_creators(api): assert c1.display_name == c3.display_name assert c1.extra == c3.extra - + # delete eg = quick_eg(api) api.delete_creator(eg.editgroup_id, c2.ident) diff --git a/python/tests/api_editgroups.py b/python/tests/api_editgroups.py index d82c9233..142687c2 100644 --- a/python/tests/api_editgroups.py +++ b/python/tests/api_editgroups.py @@ -1,11 +1,8 @@ -import json import pytest import datetime -from copy import copy from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * diff --git a/python/tests/api_editor.py b/python/tests/api_editor.py index 64bb2759..91881743 100644 --- a/python/tests/api_editor.py +++ b/python/tests/api_editor.py @@ -1,12 +1,5 @@ -import json -import pytest -import datetime -from copy import copy - -from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException -from fixtures import * +from fixtures import api def test_editor_update(api): diff --git a/python/tests/api_entity_editing.py b/python/tests/api_entity_editing.py index d5377e18..fee4e34f 100644 --- a/python/tests/api_entity_editing.py +++ b/python/tests/api_entity_editing.py @@ -1,10 +1,7 @@ -import json import pytest -from copy import copy from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -180,4 +177,3 @@ def test_edit_delete_all(api_dummy_entities): assert len(eg.edits.webcaptures) == 0 assert len(eg.edits.releases) == 0 assert len(eg.edits.works) == 0 - diff --git a/python/tests/api_files.py b/python/tests/api_files.py index 74865daa..65eda993 100644 --- a/python/tests/api_files.py +++ b/python/tests/api_files.py @@ -1,10 +1,5 @@ -import json -import pytest -from copy import copy - from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -50,7 +45,7 @@ def test_file(api): # get redirects (none) assert api.get_file_redirects(f2.ident) == [] - + # delete eg = quick_eg(api) api.delete_file(eg.editgroup_id, f2.ident) diff --git a/python/tests/api_filesets.py b/python/tests/api_filesets.py index 7f3235cb..6d755744 100644 --- a/python/tests/api_filesets.py +++ b/python/tests/api_filesets.py @@ -1,10 +1,7 @@ -import json import pytest -from copy import copy from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -64,7 +61,7 @@ def test_fileset(api): # get redirects (none) assert api.get_fileset_redirects(fs2.ident) == [] - + # delete eg = quick_eg(api) api.delete_fileset(eg.editgroup_id, fs2.ident) @@ -100,4 +97,3 @@ def test_bad_fileset(api): for b in bad_list: with pytest.raises(fatcat_openapi_client.rest.ApiException): api.create_fileset(eg.editgroup_id, b) - diff --git a/python/tests/api_misc.py b/python/tests/api_misc.py index 11f85fd6..4c9ac9a6 100644 --- a/python/tests/api_misc.py +++ b/python/tests/api_misc.py @@ -1,10 +1,5 @@ -import json -import pytest -from copy import copy - from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -45,4 +40,3 @@ def test_unexpected_body(api): ) f1.urls = [dict(url="http://thing", rel="repository", asdf="blue")] api.create_file(eg.editgroup_id, f1) - diff --git a/python/tests/api_releases.py b/python/tests/api_releases.py index 2df08698..c4c05ea6 100644 --- a/python/tests/api_releases.py +++ b/python/tests/api_releases.py @@ -1,11 +1,8 @@ -import json import pytest import datetime -from copy import copy from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -130,7 +127,7 @@ def test_release(api): # get redirects (none) assert api.get_release_redirects(r2.ident) == [] - + # delete eg = quick_eg(api) api.delete_release(eg.editgroup_id, r2.ident) @@ -210,4 +207,3 @@ def test_controlled_vocab(api): api.create_release(eg.editgroup_id, r3) r3.withdrawn_status = "spam" api.create_release(eg.editgroup_id, r3) - diff --git a/python/tests/api_webcaptures.py b/python/tests/api_webcaptures.py index 1054b41f..85813218 100644 --- a/python/tests/api_webcaptures.py +++ b/python/tests/api_webcaptures.py @@ -1,11 +1,8 @@ -import json import pytest import datetime -from copy import copy from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -84,7 +81,7 @@ def test_webcapture(api): # get redirects (none) assert api.get_webcapture_redirects(wc2.ident) == [] - + # delete eg = quick_eg(api) api.delete_webcapture(eg.editgroup_id, wc2.ident) diff --git a/python/tests/citation_efficiency.py b/python/tests/citation_efficiency.py index aefb7d15..f8807db6 100644 --- a/python/tests/citation_efficiency.py +++ b/python/tests/citation_efficiency.py @@ -1,10 +1,5 @@ -import json -import pytest -from copy import copy - from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -110,4 +105,3 @@ def test_citation_encoding(api): assert container == r1.refs[0].container_name assert extra == r1.refs[0].extra assert locator == r1.refs[0].locator - diff --git a/python/tests/clean_files.py b/python/tests/clean_files.py index 8a87f218..ce1102be 100644 --- a/python/tests/clean_files.py +++ b/python/tests/clean_files.py @@ -1,9 +1,10 @@ import copy import pytest + from fatcat_tools.cleanups import FileCleaner from fatcat_openapi_client import * -from fixtures import api +from fixtures import * @pytest.fixture(scope="function") diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py index 78742114..44c7be63 100644 --- a/python/tests/fixtures.py +++ b/python/tests/fixtures.py @@ -1,8 +1,4 @@ -import os -import time -import json -import signal import pytest from dotenv import load_dotenv import fatcat_web @@ -87,4 +83,3 @@ def test_get_changelog_entry(api): def quick_eg(api_inst): eg = api_inst.create_editgroup(fatcat_openapi_client.Editgroup()) return eg - diff --git a/python/tests/harvest_crossref.py b/python/tests/harvest_crossref.py index e902cda5..cad0f03b 100644 --- a/python/tests/harvest_crossref.py +++ b/python/tests/harvest_crossref.py @@ -1,6 +1,5 @@ import json -import pytest import datetime import responses from fatcat_tools.harvest import * diff --git a/python/tests/harvest_datacite.py b/python/tests/harvest_datacite.py index 004d1fef..13c6042a 100644 --- a/python/tests/harvest_datacite.py +++ b/python/tests/harvest_datacite.py @@ -1,6 +1,5 @@ import json -import pytest import datetime import responses from fatcat_tools.harvest import * diff --git a/python/tests/harvest_pubmed.py b/python/tests/harvest_pubmed.py index f8db46b6..58bc4226 100644 --- a/python/tests/harvest_pubmed.py +++ b/python/tests/harvest_pubmed.py @@ -2,14 +2,11 @@ Test pubmed FTP harvest. """ -import datetime -import json import os - +import datetime import pytest from fatcat_tools.harvest import * -from fatcat_tools.harvest.pubmed import generate_date_file_map def test_pubmed_harvest_date(mocker): @@ -77,4 +74,3 @@ def test_pubmed_harvest_date_no_pmid(mocker): # The file has not PMID, not importable. with pytest.raises(ValueError): harvester.fetch_date(datetime.datetime.strptime(test_date, '%Y-%m-%d')) - diff --git a/python/tests/harvest_state.py b/python/tests/harvest_state.py index 8b7deba6..cc624d97 100644 --- a/python/tests/harvest_state.py +++ b/python/tests/harvest_state.py @@ -1,6 +1,4 @@ -import json -import pytest import datetime from fatcat_tools.harvest import * diff --git a/python/tests/import_arabesque.py b/python/tests/import_arabesque.py index 9483eb45..20cde3a6 100644 --- a/python/tests/import_arabesque.py +++ b/python/tests/import_arabesque.py @@ -1,8 +1,9 @@ import json import pytest + from fatcat_tools.importers import ArabesqueMatchImporter, SqlitePusher, JsonLinePusher -from fixtures import api +from fixtures import * @pytest.fixture(scope="function") diff --git a/python/tests/import_arxiv.py b/python/tests/import_arxiv.py index 1e649616..9306e67c 100644 --- a/python/tests/import_arxiv.py +++ b/python/tests/import_arxiv.py @@ -1,10 +1,10 @@ -import json, gzip import pytest -from fatcat_tools.importers import ArxivRawImporter, Bs4XmlFilePusher -from fixtures import api from bs4 import BeautifulSoup +from fatcat_tools.importers import ArxivRawImporter, Bs4XmlFilePusher +from fixtures import * + @pytest.fixture(scope="function") def arxiv_importer(api): diff --git a/python/tests/import_crossref.py b/python/tests/import_crossref.py index afa2410f..65cd2c37 100644 --- a/python/tests/import_crossref.py +++ b/python/tests/import_crossref.py @@ -1,8 +1,10 @@ -import json, gzip +import json +import gzip import pytest + from fatcat_tools.importers import CrossrefImporter, JsonLinePusher -from fixtures import api +from fixtures import * @pytest.fixture(scope="function") diff --git a/python/tests/import_datacite.py b/python/tests/import_datacite.py index b01a11e6..b94b6bc5 100644 --- a/python/tests/import_datacite.py +++ b/python/tests/import_datacite.py @@ -2,10 +2,13 @@ Test datacite importer. """ -import collections +import gzip +import json import datetime +import collections + import pytest -import gzip + from fatcat_tools.importers import DataciteImporter, JsonLinePusher from fatcat_tools.importers.datacite import ( find_original_language_title, diff --git a/python/tests/import_grobid_metadata.py b/python/tests/import_grobid_metadata.py index 51ab3faa..52284b89 100644 --- a/python/tests/import_grobid_metadata.py +++ b/python/tests/import_grobid_metadata.py @@ -3,8 +3,9 @@ import os import json import base64 import pytest + from fatcat_tools.importers import GrobidMetadataImporter, LinePusher -from fixtures import api +from fixtures import * """ WARNING: these tests are currently very fragile because they have database diff --git a/python/tests/import_ingest.py b/python/tests/import_ingest.py index 02486de6..ebe2923c 100644 --- a/python/tests/import_ingest.py +++ b/python/tests/import_ingest.py @@ -1,6 +1,7 @@ import json import pytest + from fatcat_tools.importers import IngestFileResultImporter, JsonLinePusher from fixtures import * diff --git a/python/tests/import_jalc.py b/python/tests/import_jalc.py index f61ec849..ff757e51 100644 --- a/python/tests/import_jalc.py +++ b/python/tests/import_jalc.py @@ -1,10 +1,10 @@ -import json, gzip import pytest -from fatcat_tools.importers import JalcImporter, Bs4XmlFilePusher, Bs4XmlLinesPusher -from fixtures import api from bs4 import BeautifulSoup +from fatcat_tools.importers import JalcImporter, Bs4XmlFilePusher, Bs4XmlLinesPusher +from fixtures import * + @pytest.fixture(scope="function") def jalc_importer(api): diff --git a/python/tests/import_journal_metadata.py b/python/tests/import_journal_metadata.py index cfeee517..51b0a78a 100644 --- a/python/tests/import_journal_metadata.py +++ b/python/tests/import_journal_metadata.py @@ -1,7 +1,8 @@ import pytest + from fatcat_tools.importers import JournalMetadataImporter, JsonLinePusher -from fixtures import api +from fixtures import * @pytest.fixture(scope="function") diff --git a/python/tests/import_jstor.py b/python/tests/import_jstor.py index 019f0aae..8494ffb2 100644 --- a/python/tests/import_jstor.py +++ b/python/tests/import_jstor.py @@ -1,10 +1,10 @@ -import json, gzip import pytest -from fatcat_tools.importers import JstorImporter, Bs4XmlFilePusher -from fixtures import api from bs4 import BeautifulSoup +from fatcat_tools.importers import JstorImporter, Bs4XmlFilePusher +from fixtures import * + @pytest.fixture(scope="function") def jstor_importer(api): diff --git a/python/tests/import_matched.py b/python/tests/import_matched.py index 72ed068c..6b61c53c 100644 --- a/python/tests/import_matched.py +++ b/python/tests/import_matched.py @@ -1,8 +1,9 @@ import json import pytest + from fatcat_tools.importers import MatchedImporter, JsonLinePusher -from fixtures import api +from fixtures import * @pytest.fixture(scope="function") diff --git a/python/tests/import_orcid.py b/python/tests/import_orcid.py index 57886b52..f78ccde7 100644 --- a/python/tests/import_orcid.py +++ b/python/tests/import_orcid.py @@ -1,8 +1,9 @@ import json import pytest + from fatcat_tools.importers import OrcidImporter, JsonLinePusher -from fixtures import api +from fixtures import * @pytest.fixture(scope="function") diff --git a/python/tests/import_pubmed.py b/python/tests/import_pubmed.py index f57aa273..201f533c 100644 --- a/python/tests/import_pubmed.py +++ b/python/tests/import_pubmed.py @@ -1,10 +1,10 @@ -import json, gzip import pytest -from fatcat_tools.importers import PubmedImporter, Bs4XmlLargeFilePusher -from fixtures import api from bs4 import BeautifulSoup +from fatcat_tools.importers import PubmedImporter, Bs4XmlLargeFilePusher +from fixtures import * + @pytest.fixture(scope="function") def pubmed_importer(api): @@ -137,4 +137,3 @@ def test_pubmed_xml_parse_refs(pubmed_importer): r1 = pubmed_importer.parse_record(soup.find_all("PubmedArticle")[0]) assert len(r1.refs) > 1 - diff --git a/python/tests/import_shadow.py b/python/tests/import_shadow.py index 70a918d2..40a1d589 100644 --- a/python/tests/import_shadow.py +++ b/python/tests/import_shadow.py @@ -1,8 +1,9 @@ import json import pytest + from fatcat_tools.importers import ShadowLibraryImporter, JsonLinePusher -from fixtures import api +from fixtures import * @pytest.fixture(scope="function") @@ -58,4 +59,3 @@ def test_shadow_dict_parse(shadow_importer): assert u.url.startswith("https://web.archive.org/") assert "20180729135948" in u.url assert len(f.release_ids) == 1 - diff --git a/python/tests/importer.py b/python/tests/importer.py index 9308ba84..a412b247 100644 --- a/python/tests/importer.py +++ b/python/tests/importer.py @@ -1,8 +1,6 @@ - -import pytest from fatcat_tools.importers import CrossrefImporter, OrcidImporter -from fixtures import api +from fixtures import * def test_issnl_mapping_lookup(api): @@ -32,4 +30,3 @@ def test_identifiers(api): assert oi.is_orcid("0000-00x3-3118-659") == False assert oi.is_orcid("0000-00033118-659") == False assert oi.is_orcid("0000-0003-3118-659.") == False - diff --git a/python/tests/subentity_state.py b/python/tests/subentity_state.py index 614f88f1..e03fa99e 100644 --- a/python/tests/subentity_state.py +++ b/python/tests/subentity_state.py @@ -1,10 +1,5 @@ -import json -import pytest -from copy import copy - from fatcat_openapi_client import * -from fatcat_openapi_client.rest import ApiException from fixtures import * """ @@ -221,4 +216,3 @@ def test_app_entity_states(api, app): assert rv.status_code == 200 rv = app.get('/work/{}'.format(r2.work_id)) assert rv.status_code == 302 - diff --git a/python/tests/tools_api.py b/python/tests/tools_api.py index fd26b8ee..a4b5f2ea 100644 --- a/python/tests/tools_api.py +++ b/python/tests/tools_api.py @@ -1,6 +1,5 @@ import pytest -from fatcat_openapi_client import EditgroupAnnotation from fatcat_openapi_client.rest import ApiException from fatcat_tools import public_api, authenticated_api diff --git a/python/tests/transform_csl.py b/python/tests/transform_csl.py index 15c64ce5..6436f876 100644 --- a/python/tests/transform_csl.py +++ b/python/tests/transform_csl.py @@ -1,11 +1,11 @@ import json import pytest + from fatcat_tools import * from fatcat_openapi_client import * - -from fixtures import api from import_crossref import crossref_importer +from fixtures import * def test_csl_crossref(crossref_importer): with open('tests/files/crossref-works.single.json', 'r') as f: diff --git a/python/tests/transform_elasticsearch.py b/python/tests/transform_elasticsearch.py index a954fc4d..f791562c 100644 --- a/python/tests/transform_elasticsearch.py +++ b/python/tests/transform_elasticsearch.py @@ -1,13 +1,13 @@ import json -import pytest + from fatcat_tools import * from fatcat_openapi_client import * -from fixtures import api from import_journal_metadata import journal_metadata_importer - from import_crossref import crossref_importer from import_matched import matched_importer +from fixtures import * + def test_basic_elasticsearch_convert(crossref_importer): with open('tests/files/crossref-works.single.json', 'r') as f: diff --git a/python/tests/transform_ingest.py b/python/tests/transform_ingest.py index 2d5652b8..c7044bc0 100644 --- a/python/tests/transform_ingest.py +++ b/python/tests/transform_ingest.py @@ -1,12 +1,12 @@ import json -import pytest + from fatcat_tools.transforms import release_ingest_request from fatcat_openapi_client import * from fixtures import api - from import_crossref import crossref_importer + def test_basic_ingest_release(crossref_importer): with open('tests/files/crossref-works.single.json', 'r') as f: # not a single line @@ -54,4 +54,3 @@ def test_rich_ingest_release(): assert ir['base_url'] == 'https://doi.org/10.123/456' assert ir['ext_ids']['doi'] == '10.123/456' assert ir['ext_ids'].get('pmcid') is None - diff --git a/python/tests/web_auth.py b/python/tests/web_auth.py index 2c545b6b..643d806e 100644 --- a/python/tests/web_auth.py +++ b/python/tests/web_auth.py @@ -1,8 +1,5 @@ -import json -import pytest import responses -from fatcat_openapi_client.rest import ApiException from fixtures import * diff --git a/python/tests/web_citation_csl.py b/python/tests/web_citation_csl.py index e016b2d9..fb3ce58d 100644 --- a/python/tests/web_citation_csl.py +++ b/python/tests/web_citation_csl.py @@ -1,8 +1,6 @@ import json -import tempfile import pytest -from fatcat_openapi_client.rest import ApiException from fixtures import * diff --git a/python/tests/web_editgroup.py b/python/tests/web_editgroup.py index cbdd2176..20dc8d93 100644 --- a/python/tests/web_editgroup.py +++ b/python/tests/web_editgroup.py @@ -1,9 +1,7 @@ -import json -import pytest -from fatcat_openapi_client.rest import ApiException from fixtures import * + def test_editgroup_basics(app): rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaae') @@ -59,4 +57,3 @@ def test_editgroup_annotations_login(app_admin): assert rv.status_code == 200 assert b'Signup' not in rv.data assert b'Add Comment' in rv.data - diff --git a/python/tests/web_editing.py b/python/tests/web_editing.py index 773a59dd..17f4f5ae 100644 --- a/python/tests/web_editing.py +++ b/python/tests/web_editing.py @@ -1,7 +1,4 @@ -import json -import pytest -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -147,4 +144,3 @@ def test_web_edit_get(app_admin): rv = app_admin.get('/container/aaaaaaaaaaaaaeiraaaaaaaaam/edit') assert rv.status_code == 200 assert b'1549-1277' in rv.data - diff --git a/python/tests/web_editor.py b/python/tests/web_editor.py index 2614be96..58b21ddf 100644 --- a/python/tests/web_editor.py +++ b/python/tests/web_editor.py @@ -1,7 +1,4 @@ -import json -import pytest -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -25,4 +22,3 @@ def test_change_username(app_admin): assert rv.status_code == 200 rv = app_admin.get('/auth/account') assert b'admin-tmp' not in rv.data - diff --git a/python/tests/web_entity_views.py b/python/tests/web_entity_views.py index a3f0f897..c1cbdc29 100644 --- a/python/tests/web_entity_views.py +++ b/python/tests/web_entity_views.py @@ -1,7 +1,4 @@ -import json -import pytest -from fatcat_openapi_client.rest import ApiException from fixtures import * from fatcat_web.forms import ReleaseEntityForm, FileEntityForm, ContainerEntityForm @@ -367,4 +364,3 @@ def test_web_work(app): assert rv.status_code == 404 rv = app.get('/work/create') assert rv.status_code == 404 - diff --git a/python/tests/web_routes.py b/python/tests/web_routes.py index 026776ee..0edf06d1 100644 --- a/python/tests/web_routes.py +++ b/python/tests/web_routes.py @@ -1,7 +1,4 @@ -import json -import pytest -from fatcat_openapi_client.rest import ApiException from fixtures import * @@ -13,4 +10,3 @@ def test_static_routes(app): assert app.get("/search").status_code == 302 assert app.get("/static/bogus/route").status_code == 404 - diff --git a/python/tests/web_search.py b/python/tests/web_search.py index 24b817dc..7647bcf5 100644 --- a/python/tests/web_search.py +++ b/python/tests/web_search.py @@ -1,8 +1,7 @@ import json -import pytest import responses -from fatcat_openapi_client.rest import ApiException + from fixtures import * @responses.activate |