From c5bd3231df17fda2130e3bd51188dbe34628321a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 28 May 2018 13:22:41 -0700 Subject: start refactoring pythong code --- python/tests/api.py | 308 --------------------- python/tests/codegen_tests/__init__.py | 0 .../tests/codegen_tests/test_changelogentries.py | 40 +++ .../codegen_tests/test_changelogentries_inner.py | 40 +++ .../tests/codegen_tests/test_container_entity.py | 40 +++ python/tests/codegen_tests/test_creator_entity.py | 40 +++ python/tests/codegen_tests/test_default_api.py | 178 ++++++++++++ python/tests/codegen_tests/test_editgroup.py | 40 +++ python/tests/codegen_tests/test_editgroup_edits.py | 40 +++ python/tests/codegen_tests/test_editor.py | 40 +++ python/tests/codegen_tests/test_entity_edit.py | 40 +++ python/tests/codegen_tests/test_error_response.py | 40 +++ python/tests/codegen_tests/test_file_entity.py | 40 +++ python/tests/codegen_tests/test_release_contrib.py | 40 +++ python/tests/codegen_tests/test_release_entity.py | 40 +++ python/tests/codegen_tests/test_release_ref.py | 40 +++ python/tests/codegen_tests/test_success.py | 40 +++ python/tests/codegen_tests/test_work_entity.py | 40 +++ python/tests/entity_lifecycle.py | 80 ------ python/tests/fatcat_client/__init__.py | 0 .../tests/fatcat_client/test_changelogentries.py | 40 --- .../fatcat_client/test_changelogentries_inner.py | 40 --- .../tests/fatcat_client/test_container_entity.py | 40 --- python/tests/fatcat_client/test_creator_entity.py | 40 --- python/tests/fatcat_client/test_default_api.py | 178 ------------ python/tests/fatcat_client/test_editgroup.py | 40 --- python/tests/fatcat_client/test_editgroup_edits.py | 40 --- python/tests/fatcat_client/test_editor.py | 40 --- python/tests/fatcat_client/test_entity_edit.py | 40 --- python/tests/fatcat_client/test_error_response.py | 40 --- python/tests/fatcat_client/test_file_entity.py | 40 --- python/tests/fatcat_client/test_release_contrib.py | 40 --- python/tests/fatcat_client/test_release_entity.py | 40 --- python/tests/fatcat_client/test_release_ref.py | 40 --- python/tests/fatcat_client/test_success.py | 40 --- python/tests/fatcat_client/test_work_entity.py | 40 --- python/tests/fixtures.py | 108 -------- python/tests/models.py | 87 ------ python/tests/routes.py | 10 +- python/tests/test_fixtures.py | 29 -- 40 files changed, 780 insertions(+), 1398 deletions(-) delete mode 100644 python/tests/api.py create mode 100644 python/tests/codegen_tests/__init__.py create mode 100644 python/tests/codegen_tests/test_changelogentries.py create mode 100644 python/tests/codegen_tests/test_changelogentries_inner.py create mode 100644 python/tests/codegen_tests/test_container_entity.py create mode 100644 python/tests/codegen_tests/test_creator_entity.py create mode 100644 python/tests/codegen_tests/test_default_api.py create mode 100644 python/tests/codegen_tests/test_editgroup.py create mode 100644 python/tests/codegen_tests/test_editgroup_edits.py create mode 100644 python/tests/codegen_tests/test_editor.py create mode 100644 python/tests/codegen_tests/test_entity_edit.py create mode 100644 python/tests/codegen_tests/test_error_response.py create mode 100644 python/tests/codegen_tests/test_file_entity.py create mode 100644 python/tests/codegen_tests/test_release_contrib.py create mode 100644 python/tests/codegen_tests/test_release_entity.py create mode 100644 python/tests/codegen_tests/test_release_ref.py create mode 100644 python/tests/codegen_tests/test_success.py create mode 100644 python/tests/codegen_tests/test_work_entity.py delete mode 100644 python/tests/entity_lifecycle.py delete mode 100644 python/tests/fatcat_client/__init__.py delete mode 100644 python/tests/fatcat_client/test_changelogentries.py delete mode 100644 python/tests/fatcat_client/test_changelogentries_inner.py delete mode 100644 python/tests/fatcat_client/test_container_entity.py delete mode 100644 python/tests/fatcat_client/test_creator_entity.py delete mode 100644 python/tests/fatcat_client/test_default_api.py delete mode 100644 python/tests/fatcat_client/test_editgroup.py delete mode 100644 python/tests/fatcat_client/test_editgroup_edits.py delete mode 100644 python/tests/fatcat_client/test_editor.py delete mode 100644 python/tests/fatcat_client/test_entity_edit.py delete mode 100644 python/tests/fatcat_client/test_error_response.py delete mode 100644 python/tests/fatcat_client/test_file_entity.py delete mode 100644 python/tests/fatcat_client/test_release_contrib.py delete mode 100644 python/tests/fatcat_client/test_release_entity.py delete mode 100644 python/tests/fatcat_client/test_release_ref.py delete mode 100644 python/tests/fatcat_client/test_success.py delete mode 100644 python/tests/fatcat_client/test_work_entity.py delete mode 100644 python/tests/models.py delete mode 100644 python/tests/test_fixtures.py (limited to 'python/tests') diff --git a/python/tests/api.py b/python/tests/api.py deleted file mode 100644 index 02875f64..00000000 --- a/python/tests/api.py +++ /dev/null @@ -1,308 +0,0 @@ - -import json -import unittest -import tempfile -import pytest -import fatcat -import fatcat.sql -from fatcat.models import * -from fixtures import * - - -def test_health(app): - rv = app.get('/health') - obj = json.loads(rv.data.decode('utf-8')) - assert obj['ok'] - -def test_api_work(app): - fatcat.dummy.insert_example_works() - - # Invalid Id - rv = app.get('/v0/work/_') - assert rv.status_code == 404 - - # Random - rv = app.get('/v0/work/random') - rv = app.get(rv.location) - work = json.loads(rv.data.decode('utf-8')) - check_entity_fields(work) - print(work) - assert work['title'] - assert work['work_type'] - - # Valid Id (from random above) - rv = app.get('/v0/work/{}'.format(work['id'])) - assert rv.status_code == 200 - - # Missing Id - rv = app.get('/v0/work/r3zga5b9cd7ef8gh084714iljk') - assert rv.status_code == 404 - -def test_api_work_create(app): - assert WorkIdent.query.count() == 0 - assert WorkRev.query.count() == 0 - assert WorkEdit.query.count() == 0 - rv = app.post('/v0/work', - data=json.dumps(dict(title="dummy", work_type="thing", extra=dict(a=1, b="zing"))), - headers={"content-type": "application/json"}) - print(rv) - assert rv.status_code == 200 - assert WorkIdent.query.count() == 1 - assert WorkRev.query.count() == 1 - assert WorkEdit.query.count() == 1 - # not alive yet - assert WorkIdent.query.filter(WorkIdent.is_live==True).count() == 0 - -def test_api_rich_create(app): - - # TODO: create user? - - rv = app.post('/v0/editgroup', - data=json.dumps(dict( - extra=dict(q=1, u="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - editgroup_id = obj['id'] - - for cls in (WorkIdent, WorkRev, WorkEdit, - ContainerIdent, ContainerRev, ContainerEdit, - CreatorIdent, CreatorRev, CreatorEdit, - ReleaseIdent, ReleaseRev, ReleaseEdit, - FileIdent, FileRev, FileEdit, - ChangelogEntry): - assert cls.query.count() == 0 - - rv = app.post('/v0/container', - data=json.dumps(dict( - name="schmournal", - publisher="society of authors", - issn="2222-3333", - editgroup=editgroup_id, - extra=dict(a=2, i="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - container_id = obj['id'] - - rv = app.post('/v0/creator', - data=json.dumps(dict( - name="anon y. mouse", - orcid="0000-0002-1825-0097", - editgroup=editgroup_id, - extra=dict(w=1, q="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - creator_id = obj['id'] - - rv = app.post('/v0/work', - data=json.dumps(dict( - title="dummy work", - work_type="book", - editgroup=editgroup_id, - extra=dict(a=3, b="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - work_id = obj['id'] - - # this stub work will be referenced - rv = app.post('/v0/release', - data=json.dumps(dict( - title="derivative work", - work_type="journal-article", - work=work_id, - creators=[creator_id], - doi="10.1234/58", - editgroup=editgroup_id, - refs=[ - dict(stub="some other journal article"), - ], - extra=dict(f=7, b="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - stub_release_id = obj['id'] - - rv = app.post('/v0/release', - data=json.dumps(dict( - title="dummy work", - work_type="book", - work=work_id, - container=container_id, - creators=[creator_id], - doi="10.1234/5678", - editgroup=editgroup_id, - refs=[ - dict(stub="some book", target=stub_release_id), - ], - extra=dict(f=7, b="loopy"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - release_id = obj['id'] - - rv = app.post('/v0/file', - data=json.dumps(dict( - sha1="deadbeefdeadbeef", - size=1234, - releases=[release_id], - editgroup=editgroup_id, - extra=dict(f=4, b="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - file_id = obj['id'] - - for cls in (WorkIdent, WorkRev, WorkEdit, - ContainerIdent, ContainerRev, ContainerEdit, - CreatorIdent, CreatorRev, CreatorEdit, - FileIdent, FileRev, FileEdit): - assert cls.query.count() == 1 - for cls in (ReleaseIdent, ReleaseRev, ReleaseEdit): - assert cls.query.count() == 2 - - for cls in (WorkIdent, - ContainerIdent, - CreatorIdent, - ReleaseIdent, - FileIdent): - assert cls.query.filter(cls.is_live==True).count() == 0 - - assert ChangelogEntry.query.count() == 0 - rv = app.post('/v0/editgroup/{}/accept'.format(editgroup_id), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - assert ChangelogEntry.query.count() == 1 - - for cls in (WorkIdent, WorkRev, WorkEdit, - ContainerIdent, ContainerRev, ContainerEdit, - CreatorIdent, CreatorRev, CreatorEdit, - FileIdent, FileRev, FileEdit): - assert cls.query.count() == 1 - for cls in (ReleaseIdent, ReleaseRev, ReleaseEdit): - assert cls.query.count() == 2 - - for cls in (WorkIdent, - ContainerIdent, - CreatorIdent, - FileIdent): - assert cls.query.filter(cls.is_live==True).count() == 1 - assert ReleaseIdent.query.filter(ReleaseIdent.is_live==True).count() == 2 - - # Test that foreign key relations worked - release_rv = json.loads(app.get('/v0/release/{}'.format(release_id)).data.decode('utf-8')) - print(release_rv) - assert release_rv['creators'][0]['creator'] == creator_id - assert release_rv['container']['id'] == container_id - assert release_rv['work']['id'] == work_id - assert release_rv['refs'][0]['target'] == stub_release_id - - file_rv = json.loads(app.get('/v0/file/{}'.format(file_id)).data.decode('utf-8')) - print(file_rv) - assert file_rv['releases'][0]['release'] == release_id - - # test that editor's active edit group is now invalid - editor = Editor.query.first() - assert editor.active_editgroup is None - -def test_api_release_lookup(rich_app): - app = rich_app - - rv = app.get('/v0/release/1', - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - - rv = app.get('/v0/release/lookup', - data=json.dumps(dict(doi="10.1234/5678")), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - assert obj['doi'] == "10.1234/5678" - assert obj.get('id') != None - - rv = app.get('/v0/release/lookup', - data=json.dumps(dict(doi="10.1234/5678_noexit")), - headers={"content-type": "application/json"}) - assert rv.status_code == 404 - - rv = app.get('/v0/release/lookup', - data=json.dumps(dict(doi="not_even_valid_doi")), - headers={"content-type": "application/json"}) - assert rv.status_code == 400 - -def test_api_creator_lookup(rich_app): - app = rich_app - - rv = app.get('/v0/creator/1', - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - - rv = app.get('/v0/creator/lookup', - data=json.dumps(dict(orcid="0000-0002-1825-0097")), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - assert obj['orcid'] == "0000-0002-1825-0097" - assert obj.get('id') != None - - rv = app.get('/v0/creator/lookup', - data=json.dumps(dict(orcid="0000-0002-1825-0098")), - headers={"content-type": "application/json"}) - assert rv.status_code == 404 - - rv = app.get('/v0/creator/lookup', - data=json.dumps(dict(orcid="not_even_valid_orcid")), - headers={"content-type": "application/json"}) - assert rv.status_code == 400 - - -def test_api_container_lookup(rich_app): - app = rich_app - - rv = app.get('/v0/container/1', - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - - rv = app.get('/v0/container/lookup', - data=json.dumps(dict(issn="2222-3333")), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - assert obj['issn'] == "2222-3333" - assert obj.get('id') != None - - rv = app.get('/v0/container/lookup', - data=json.dumps(dict(issn="2222-3334")), - headers={"content-type": "application/json"}) - assert rv.status_code == 404 - - rv = app.get('/v0/container/lookup', - data=json.dumps(dict(issn="not_even_valid_issn")), - headers={"content-type": "application/json"}) - assert rv.status_code == 400 - -def test_api_editor_get(rich_app): - app = rich_app - - rv = app.get('/v0/editor/admin', - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - print(obj) - assert obj['username'] == "admin" - assert obj['id'] == 1 - -def test_api_editor_changelog(rich_app): - app = rich_app - - rv = app.get('/v0/editor/admin/changelog', - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - print(obj) - assert len(obj) == 1 diff --git a/python/tests/codegen_tests/__init__.py b/python/tests/codegen_tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/tests/codegen_tests/test_changelogentries.py b/python/tests/codegen_tests/test_changelogentries.py new file mode 100644 index 00000000..3b2bc885 --- /dev/null +++ b/python/tests/codegen_tests/test_changelogentries.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.changelogentries import Changelogentries # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestChangelogentries(unittest.TestCase): + """Changelogentries unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChangelogentries(self): + """Test Changelogentries""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.changelogentries.Changelogentries() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_changelogentries_inner.py b/python/tests/codegen_tests/test_changelogentries_inner.py new file mode 100644 index 00000000..ac836714 --- /dev/null +++ b/python/tests/codegen_tests/test_changelogentries_inner.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.changelogentries_inner import ChangelogentriesInner # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestChangelogentriesInner(unittest.TestCase): + """ChangelogentriesInner unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChangelogentriesInner(self): + """Test ChangelogentriesInner""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.changelogentries_inner.ChangelogentriesInner() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_container_entity.py b/python/tests/codegen_tests/test_container_entity.py new file mode 100644 index 00000000..0bafb7dd --- /dev/null +++ b/python/tests/codegen_tests/test_container_entity.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.container_entity import ContainerEntity # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestContainerEntity(unittest.TestCase): + """ContainerEntity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testContainerEntity(self): + """Test ContainerEntity""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.container_entity.ContainerEntity() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_creator_entity.py b/python/tests/codegen_tests/test_creator_entity.py new file mode 100644 index 00000000..b235b640 --- /dev/null +++ b/python/tests/codegen_tests/test_creator_entity.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.creator_entity import CreatorEntity # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestCreatorEntity(unittest.TestCase): + """CreatorEntity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCreatorEntity(self): + """Test CreatorEntity""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.creator_entity.CreatorEntity() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_default_api.py b/python/tests/codegen_tests/test_default_api.py new file mode 100644 index 00000000..cda38f38 --- /dev/null +++ b/python/tests/codegen_tests/test_default_api.py @@ -0,0 +1,178 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.api.default_api import DefaultApi # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestDefaultApi(unittest.TestCase): + """DefaultApi unit test stubs""" + + def setUp(self): + self.api = fatcat_client.api.default_api.DefaultApi() # noqa: E501 + + def tearDown(self): + pass + + def test_container_batch_post(self): + """Test case for container_batch_post + + """ + pass + + def test_container_id_get(self): + """Test case for container_id_get + + """ + pass + + def test_container_lookup_get(self): + """Test case for container_lookup_get + + """ + pass + + def test_container_post(self): + """Test case for container_post + + """ + pass + + def test_creator_batch_post(self): + """Test case for creator_batch_post + + """ + pass + + def test_creator_id_get(self): + """Test case for creator_id_get + + """ + pass + + def test_creator_lookup_get(self): + """Test case for creator_lookup_get + + """ + pass + + def test_creator_post(self): + """Test case for creator_post + + """ + pass + + def test_editgroup_id_accept_post(self): + """Test case for editgroup_id_accept_post + + """ + pass + + def test_editgroup_id_get(self): + """Test case for editgroup_id_get + + """ + pass + + def test_editgroup_post(self): + """Test case for editgroup_post + + """ + pass + + def test_editor_username_changelog_get(self): + """Test case for editor_username_changelog_get + + """ + pass + + def test_editor_username_get(self): + """Test case for editor_username_get + + """ + pass + + def test_file_batch_post(self): + """Test case for file_batch_post + + """ + pass + + def test_file_id_get(self): + """Test case for file_id_get + + """ + pass + + def test_file_lookup_get(self): + """Test case for file_lookup_get + + """ + pass + + def test_file_post(self): + """Test case for file_post + + """ + pass + + def test_release_batch_post(self): + """Test case for release_batch_post + + """ + pass + + def test_release_id_get(self): + """Test case for release_id_get + + """ + pass + + def test_release_lookup_get(self): + """Test case for release_lookup_get + + """ + pass + + def test_release_post(self): + """Test case for release_post + + """ + pass + + def test_work_batch_post(self): + """Test case for work_batch_post + + """ + pass + + def test_work_id_get(self): + """Test case for work_id_get + + """ + pass + + def test_work_post(self): + """Test case for work_post + + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_editgroup.py b/python/tests/codegen_tests/test_editgroup.py new file mode 100644 index 00000000..e770fd54 --- /dev/null +++ b/python/tests/codegen_tests/test_editgroup.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.editgroup import Editgroup # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestEditgroup(unittest.TestCase): + """Editgroup unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEditgroup(self): + """Test Editgroup""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.editgroup.Editgroup() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_editgroup_edits.py b/python/tests/codegen_tests/test_editgroup_edits.py new file mode 100644 index 00000000..38c3c814 --- /dev/null +++ b/python/tests/codegen_tests/test_editgroup_edits.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.editgroup_edits import EditgroupEdits # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestEditgroupEdits(unittest.TestCase): + """EditgroupEdits unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEditgroupEdits(self): + """Test EditgroupEdits""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.editgroup_edits.EditgroupEdits() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_editor.py b/python/tests/codegen_tests/test_editor.py new file mode 100644 index 00000000..00ca625e --- /dev/null +++ b/python/tests/codegen_tests/test_editor.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.editor import Editor # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestEditor(unittest.TestCase): + """Editor unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEditor(self): + """Test Editor""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.editor.Editor() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_entity_edit.py b/python/tests/codegen_tests/test_entity_edit.py new file mode 100644 index 00000000..2f0f7ac3 --- /dev/null +++ b/python/tests/codegen_tests/test_entity_edit.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.entity_edit import EntityEdit # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestEntityEdit(unittest.TestCase): + """EntityEdit unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEntityEdit(self): + """Test EntityEdit""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.entity_edit.EntityEdit() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_error_response.py b/python/tests/codegen_tests/test_error_response.py new file mode 100644 index 00000000..f0d09ee8 --- /dev/null +++ b/python/tests/codegen_tests/test_error_response.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.error_response import ErrorResponse # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestErrorResponse(unittest.TestCase): + """ErrorResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testErrorResponse(self): + """Test ErrorResponse""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.error_response.ErrorResponse() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_file_entity.py b/python/tests/codegen_tests/test_file_entity.py new file mode 100644 index 00000000..f5806f9b --- /dev/null +++ b/python/tests/codegen_tests/test_file_entity.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.file_entity import FileEntity # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestFileEntity(unittest.TestCase): + """FileEntity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testFileEntity(self): + """Test FileEntity""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.file_entity.FileEntity() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_release_contrib.py b/python/tests/codegen_tests/test_release_contrib.py new file mode 100644 index 00000000..9a61ef89 --- /dev/null +++ b/python/tests/codegen_tests/test_release_contrib.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.release_contrib import ReleaseContrib # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestReleaseContrib(unittest.TestCase): + """ReleaseContrib unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testReleaseContrib(self): + """Test ReleaseContrib""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.release_contrib.ReleaseContrib() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_release_entity.py b/python/tests/codegen_tests/test_release_entity.py new file mode 100644 index 00000000..9a1f0e97 --- /dev/null +++ b/python/tests/codegen_tests/test_release_entity.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.release_entity import ReleaseEntity # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestReleaseEntity(unittest.TestCase): + """ReleaseEntity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testReleaseEntity(self): + """Test ReleaseEntity""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.release_entity.ReleaseEntity() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_release_ref.py b/python/tests/codegen_tests/test_release_ref.py new file mode 100644 index 00000000..cafb6700 --- /dev/null +++ b/python/tests/codegen_tests/test_release_ref.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.release_ref import ReleaseRef # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestReleaseRef(unittest.TestCase): + """ReleaseRef unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testReleaseRef(self): + """Test ReleaseRef""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.release_ref.ReleaseRef() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_success.py b/python/tests/codegen_tests/test_success.py new file mode 100644 index 00000000..28d855fb --- /dev/null +++ b/python/tests/codegen_tests/test_success.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.success import Success # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestSuccess(unittest.TestCase): + """Success unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testSuccess(self): + """Test Success""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.success.Success() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/codegen_tests/test_work_entity.py b/python/tests/codegen_tests/test_work_entity.py new file mode 100644 index 00000000..57b0cdad --- /dev/null +++ b/python/tests/codegen_tests/test_work_entity.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + fatcat + + A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import unittest + +import fatcat_client +from fatcat_client.models.work_entity import WorkEntity # noqa: E501 +from fatcat_client.rest import ApiException + + +class TestWorkEntity(unittest.TestCase): + """WorkEntity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testWorkEntity(self): + """Test WorkEntity""" + # FIXME: construct object with mandatory attributes with example values + # model = fatcat_client.models.work_entity.WorkEntity() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/entity_lifecycle.py b/python/tests/entity_lifecycle.py deleted file mode 100644 index 4ac7ee68..00000000 --- a/python/tests/entity_lifecycle.py +++ /dev/null @@ -1,80 +0,0 @@ - -import json -import unittest -import tempfile -import pytest -import fatcat -import fatcat.sql -from fatcat.models import * -from fixtures import * - - -def test_merge_works(app): - - # two works, each with releases - rv = app.post('/v0/work', - data=json.dumps(dict()), - headers={"content-type": "application/json"}) - workA_id = json.loads(rv.data.decode('utf-8'))['id'] - - rv = app.post('/v0/work', - data=json.dumps(dict()), - headers={"content-type": "application/json"}) - workB_id = json.loads(rv.data.decode('utf-8'))['id'] - - rv = app.post('/v0/release', - data=json.dumps(dict( - title="some release", - work_type="journal-article", - work=workA_id, - doi="10.1234/A1")), - headers={"content-type": "application/json"}) - releaseA1 = json.loads(rv.data.decode('utf-8'))['id'] - - rv = app.post('/v0/release', - data=json.dumps(dict( - title="some release", - work_type="journal-article", - work=workB_id, - doi="10.1234/B1")), - headers={"content-type": "application/json"}) - releaseB1 = json.loads(rv.data.decode('utf-8'))['id'] - - rv = app.post('/v0/release', - data=json.dumps(dict( - title="some release", - work_type="journal-article", - work=workB_id, - doi="10.1234/A1")), - headers={"content-type": "application/json"}) - releaseB2 = json.loads(rv.data.decode('utf-8'))['id'] - - # XXX: what if workB primary was set? - - editgroup_id = 1 - rv = app.post('/v0/editgroup/{}/accept'.format(editgroup_id), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - assert ChangelogEntry.query.count() == 1 - assert WorkIdent.query.filter(WorkIdent.is_live==True).count() == 2 - assert ReleaseIdent.query.filter(ReleaseIdent.is_live==True).count() == 3 - - # merge works - fatcat.sql.merge_works(workA_id, workB_id) - editgroup_id = 2 - rv = app.post('/v0/editgroup/{}/accept'.format(editgroup_id), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - - # check results - assert ChangelogEntry.query.count() == 2 - assert WorkIdent.query.filter(WorkIdent.is_live==True).count() == 2 - assert ReleaseIdent.query.filter(ReleaseIdent.is_live==True).count() == 3 - - workA_json = json.loads(app.get('/v0/work/{}'.format(workA_id)).data.decode('utf-8')) - workB_json = json.loads(app.get('/v0/work/{}'.format(workB_id)).data.decode('utf-8')) - assert workA_json['rev'] == workB_json['rev'] - print(workA_json) - print(workB_json) - assert workA_json['redirect_id'] == None - assert workB_json['redirect_id'] == workA_json['id'] diff --git a/python/tests/fatcat_client/__init__.py b/python/tests/fatcat_client/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/python/tests/fatcat_client/test_changelogentries.py b/python/tests/fatcat_client/test_changelogentries.py deleted file mode 100644 index 3b2bc885..00000000 --- a/python/tests/fatcat_client/test_changelogentries.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.changelogentries import Changelogentries # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestChangelogentries(unittest.TestCase): - """Changelogentries unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testChangelogentries(self): - """Test Changelogentries""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.changelogentries.Changelogentries() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_changelogentries_inner.py b/python/tests/fatcat_client/test_changelogentries_inner.py deleted file mode 100644 index ac836714..00000000 --- a/python/tests/fatcat_client/test_changelogentries_inner.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.changelogentries_inner import ChangelogentriesInner # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestChangelogentriesInner(unittest.TestCase): - """ChangelogentriesInner unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testChangelogentriesInner(self): - """Test ChangelogentriesInner""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.changelogentries_inner.ChangelogentriesInner() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_container_entity.py b/python/tests/fatcat_client/test_container_entity.py deleted file mode 100644 index 0bafb7dd..00000000 --- a/python/tests/fatcat_client/test_container_entity.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.container_entity import ContainerEntity # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestContainerEntity(unittest.TestCase): - """ContainerEntity unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testContainerEntity(self): - """Test ContainerEntity""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.container_entity.ContainerEntity() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_creator_entity.py b/python/tests/fatcat_client/test_creator_entity.py deleted file mode 100644 index b235b640..00000000 --- a/python/tests/fatcat_client/test_creator_entity.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.creator_entity import CreatorEntity # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestCreatorEntity(unittest.TestCase): - """CreatorEntity unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testCreatorEntity(self): - """Test CreatorEntity""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.creator_entity.CreatorEntity() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_default_api.py b/python/tests/fatcat_client/test_default_api.py deleted file mode 100644 index cda38f38..00000000 --- a/python/tests/fatcat_client/test_default_api.py +++ /dev/null @@ -1,178 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.api.default_api import DefaultApi # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestDefaultApi(unittest.TestCase): - """DefaultApi unit test stubs""" - - def setUp(self): - self.api = fatcat_client.api.default_api.DefaultApi() # noqa: E501 - - def tearDown(self): - pass - - def test_container_batch_post(self): - """Test case for container_batch_post - - """ - pass - - def test_container_id_get(self): - """Test case for container_id_get - - """ - pass - - def test_container_lookup_get(self): - """Test case for container_lookup_get - - """ - pass - - def test_container_post(self): - """Test case for container_post - - """ - pass - - def test_creator_batch_post(self): - """Test case for creator_batch_post - - """ - pass - - def test_creator_id_get(self): - """Test case for creator_id_get - - """ - pass - - def test_creator_lookup_get(self): - """Test case for creator_lookup_get - - """ - pass - - def test_creator_post(self): - """Test case for creator_post - - """ - pass - - def test_editgroup_id_accept_post(self): - """Test case for editgroup_id_accept_post - - """ - pass - - def test_editgroup_id_get(self): - """Test case for editgroup_id_get - - """ - pass - - def test_editgroup_post(self): - """Test case for editgroup_post - - """ - pass - - def test_editor_username_changelog_get(self): - """Test case for editor_username_changelog_get - - """ - pass - - def test_editor_username_get(self): - """Test case for editor_username_get - - """ - pass - - def test_file_batch_post(self): - """Test case for file_batch_post - - """ - pass - - def test_file_id_get(self): - """Test case for file_id_get - - """ - pass - - def test_file_lookup_get(self): - """Test case for file_lookup_get - - """ - pass - - def test_file_post(self): - """Test case for file_post - - """ - pass - - def test_release_batch_post(self): - """Test case for release_batch_post - - """ - pass - - def test_release_id_get(self): - """Test case for release_id_get - - """ - pass - - def test_release_lookup_get(self): - """Test case for release_lookup_get - - """ - pass - - def test_release_post(self): - """Test case for release_post - - """ - pass - - def test_work_batch_post(self): - """Test case for work_batch_post - - """ - pass - - def test_work_id_get(self): - """Test case for work_id_get - - """ - pass - - def test_work_post(self): - """Test case for work_post - - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_editgroup.py b/python/tests/fatcat_client/test_editgroup.py deleted file mode 100644 index e770fd54..00000000 --- a/python/tests/fatcat_client/test_editgroup.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.editgroup import Editgroup # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestEditgroup(unittest.TestCase): - """Editgroup unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testEditgroup(self): - """Test Editgroup""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.editgroup.Editgroup() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_editgroup_edits.py b/python/tests/fatcat_client/test_editgroup_edits.py deleted file mode 100644 index 38c3c814..00000000 --- a/python/tests/fatcat_client/test_editgroup_edits.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.editgroup_edits import EditgroupEdits # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestEditgroupEdits(unittest.TestCase): - """EditgroupEdits unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testEditgroupEdits(self): - """Test EditgroupEdits""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.editgroup_edits.EditgroupEdits() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_editor.py b/python/tests/fatcat_client/test_editor.py deleted file mode 100644 index 00ca625e..00000000 --- a/python/tests/fatcat_client/test_editor.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.editor import Editor # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestEditor(unittest.TestCase): - """Editor unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testEditor(self): - """Test Editor""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.editor.Editor() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_entity_edit.py b/python/tests/fatcat_client/test_entity_edit.py deleted file mode 100644 index 2f0f7ac3..00000000 --- a/python/tests/fatcat_client/test_entity_edit.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.entity_edit import EntityEdit # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestEntityEdit(unittest.TestCase): - """EntityEdit unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testEntityEdit(self): - """Test EntityEdit""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.entity_edit.EntityEdit() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_error_response.py b/python/tests/fatcat_client/test_error_response.py deleted file mode 100644 index f0d09ee8..00000000 --- a/python/tests/fatcat_client/test_error_response.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.error_response import ErrorResponse # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestErrorResponse(unittest.TestCase): - """ErrorResponse unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testErrorResponse(self): - """Test ErrorResponse""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.error_response.ErrorResponse() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_file_entity.py b/python/tests/fatcat_client/test_file_entity.py deleted file mode 100644 index f5806f9b..00000000 --- a/python/tests/fatcat_client/test_file_entity.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.file_entity import FileEntity # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestFileEntity(unittest.TestCase): - """FileEntity unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testFileEntity(self): - """Test FileEntity""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.file_entity.FileEntity() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_release_contrib.py b/python/tests/fatcat_client/test_release_contrib.py deleted file mode 100644 index 9a61ef89..00000000 --- a/python/tests/fatcat_client/test_release_contrib.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.release_contrib import ReleaseContrib # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestReleaseContrib(unittest.TestCase): - """ReleaseContrib unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testReleaseContrib(self): - """Test ReleaseContrib""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.release_contrib.ReleaseContrib() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_release_entity.py b/python/tests/fatcat_client/test_release_entity.py deleted file mode 100644 index 9a1f0e97..00000000 --- a/python/tests/fatcat_client/test_release_entity.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.release_entity import ReleaseEntity # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestReleaseEntity(unittest.TestCase): - """ReleaseEntity unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testReleaseEntity(self): - """Test ReleaseEntity""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.release_entity.ReleaseEntity() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_release_ref.py b/python/tests/fatcat_client/test_release_ref.py deleted file mode 100644 index cafb6700..00000000 --- a/python/tests/fatcat_client/test_release_ref.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.release_ref import ReleaseRef # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestReleaseRef(unittest.TestCase): - """ReleaseRef unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testReleaseRef(self): - """Test ReleaseRef""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.release_ref.ReleaseRef() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_success.py b/python/tests/fatcat_client/test_success.py deleted file mode 100644 index 28d855fb..00000000 --- a/python/tests/fatcat_client/test_success.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.success import Success # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestSuccess(unittest.TestCase): - """Success unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testSuccess(self): - """Test Success""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.success.Success() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fatcat_client/test_work_entity.py b/python/tests/fatcat_client/test_work_entity.py deleted file mode 100644 index 57b0cdad..00000000 --- a/python/tests/fatcat_client/test_work_entity.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - fatcat - - A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata # noqa: E501 - - OpenAPI spec version: 0.1.0 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import unittest - -import fatcat_client -from fatcat_client.models.work_entity import WorkEntity # noqa: E501 -from fatcat_client.rest import ApiException - - -class TestWorkEntity(unittest.TestCase): - """WorkEntity unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def testWorkEntity(self): - """Test WorkEntity""" - # FIXME: construct object with mandatory attributes with example values - # model = fatcat_client.models.work_entity.WorkEntity() # noqa: E501 - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py index d3d8c24b..9092421f 100644 --- a/python/tests/fixtures.py +++ b/python/tests/fixtures.py @@ -5,30 +5,18 @@ import json import signal import pytest import fatcat -import fatcat.sql -from fatcat.models import * @pytest.fixture def full_app(): - fatcat.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' fatcat.app.testing = True fatcat.app.debug = False - fatcat.db.session.remove() - fatcat.db.drop_all() - fatcat.db.create_all() - fatcat.sql.populate_db() return fatcat.app @pytest.fixture def app(full_app): return full_app.test_client() -@pytest.fixture -def rich_app(app): - enrichen_test_app(app) - return app - @pytest.fixture(scope="function") def api_client(full_app): @@ -46,102 +34,6 @@ def api_client(full_app): ## Helpers ################################################################## -def enrichen_test_app(app): - - rv = app.post('/v0/editgroup', - data=json.dumps(dict( - extra=dict(q=1, u="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - editgroup_id = obj['id'] - - rv = app.post('/v0/container', - data=json.dumps(dict( - name="schmournal", - publisher="society of authors", - issn="2222-3333", - editgroup=editgroup_id, - extra=dict(a=2, i="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - container_id = obj['id'] - - rv = app.post('/v0/creator', - data=json.dumps(dict( - name="anon y. mouse", - orcid="0000-0002-1825-0097", - editgroup=editgroup_id, - extra=dict(w=1, q="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - creator_id = obj['id'] - - rv = app.post('/v0/work', - data=json.dumps(dict( - title="dummy work", - work_type="book", - editgroup=editgroup_id, - extra=dict(a=3, b="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - work_id = obj['id'] - - # this stub work will be referenced - rv = app.post('/v0/release', - data=json.dumps(dict( - title="derivative work", - work_type="journal-article", - work=work_id, - creators=[creator_id], - doi="10.1234/58", - editgroup=editgroup_id, - refs=[ - dict(stub="some other journal article"), - ], - extra=dict(f=7, b="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - stub_release_id = obj['id'] - - rv = app.post('/v0/release', - data=json.dumps(dict( - title="dummy work", - work_type="book", - work=work_id, - container=container_id, - creators=[creator_id], - doi="10.1234/5678", - editgroup=editgroup_id, - refs=[ - dict(stub="some book", target=stub_release_id), - ], - extra=dict(f=7, b="loopy"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - release_id = obj['id'] - - rv = app.post('/v0/file', - data=json.dumps(dict( - sha1="deadbeefdeadbeef", - size=1234, - releases=[release_id], - editgroup=editgroup_id, - extra=dict(f=4, b="zing"))), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - obj = json.loads(rv.data.decode('utf-8')) - file_id = obj['id'] - - rv = app.post('/v0/editgroup/{}/accept'.format(editgroup_id), - headers={"content-type": "application/json"}) - assert rv.status_code == 200 - def check_entity_fields(e): for key in ('rev', 'is_live', 'redirect_id'): assert key in e diff --git a/python/tests/models.py b/python/tests/models.py deleted file mode 100644 index 98bb6bc7..00000000 --- a/python/tests/models.py +++ /dev/null @@ -1,87 +0,0 @@ - -import json -import unittest -import tempfile -import pytest -import fatcat -import fatcat.sql -from fatcat.models import * -from fixtures import * - - -def test_example_works(app): - fatcat.dummy.insert_example_works() - -def test_random_works(app): - fatcat.dummy.insert_random_works() - -def test_load_crossref(app): - with open('./tests/files/crossref-works.2018-01-21.badsample.json', 'r') as f: - raw = [json.loads(l) for l in f.readlines() if len(l) > 3] - for obj in raw: - fatcat.sql.add_crossref_via_model(obj) - -def test_schema_release_rev(app): - assert ReleaseRev.query.count() == 0 - e = { - "title": "Bogus title", - "release_type": "book", - "creators": [], - "refs": [], - } - model = release_rev_schema.load(e) - fatcat.db.session.add(model.data) - fatcat.db.session.commit() - assert ReleaseRev.query.count() == 1 - model_after = ReleaseRev.query.first() - serial = release_rev_schema.dump(model_after).data - #check_release(serial) - for k in e: - assert e[k] == serial[k] - -def test_schema_creator_rev(app): - assert ReleaseRev.query.count() == 0 - e = { - "name": "Robin (Batman)", - } - model = creator_rev_schema.load(e) - fatcat.db.session.add(model.data) - fatcat.db.session.commit() - assert CreatorRev.query.count() == 1 - model_after = CreatorRev.query.first() - serial = creator_rev_schema.dump(model_after).data - check_creator(serial) - for k in e.keys(): - assert e[k] == serial[k] - -def test_schema_container_rev(app): - assert ReleaseRev.query.count() == 0 - e = { - "name": "Papers Monthly", - } - model = container_rev_schema.load(e) - fatcat.db.session.add(model.data) - fatcat.db.session.commit() - assert ContainerRev.query.count() == 1 - model_after = ContainerRev.query.first() - serial = container_rev_schema.dump(model_after).data - check_container(serial) - for k in e.keys(): - assert e[k] == serial[k] - -def test_schema_file_rev(app): - assert ReleaseRev.query.count() == 0 - e = { - "sha1": "asdf", - "size": 6, - } - model = file_rev_schema.load(e) - print(model) - fatcat.db.session.add(model.data) - fatcat.db.session.commit() - assert FileRev.query.count() == 1 - model_after = FileRev.query.first() - serial = file_rev_schema.dump(model_after).data - check_file(serial) - for k in e.keys(): - assert e[k] == serial[k] diff --git a/python/tests/routes.py b/python/tests/routes.py index 79d97fe4..80eb15fe 100644 --- a/python/tests/routes.py +++ b/python/tests/routes.py @@ -3,14 +3,10 @@ import json import tempfile import pytest import fatcat -import fatcat.sql -from fatcat.models import * from fixtures import * -def test_static_routes(rich_app): - app = rich_app - +def test_static_routes(app): for route in ('/health', '/robots.txt', '/', '/about'): rv = app.get(route) assert rv.status_code == 200 @@ -18,9 +14,7 @@ def test_static_routes(rich_app): assert app.get("/static/bogus/route").status_code == 404 -def test_all_views(rich_app): - app = rich_app - +def test_all_views(app): for route in ('work', 'release', 'creator', 'container', 'file'): print(route) rv = app.get('/{}/1'.format(route)) diff --git a/python/tests/test_fixtures.py b/python/tests/test_fixtures.py deleted file mode 100644 index 0a0d3176..00000000 --- a/python/tests/test_fixtures.py +++ /dev/null @@ -1,29 +0,0 @@ - -import pytest -import fatcat.api_client -from fixtures import * - - -def test_rich_app_fixture(rich_app): - app = rich_app - - assert ChangelogEntry.query.count() == 1 - - for cls in (WorkIdent, WorkRev, WorkEdit, - ContainerIdent, ContainerRev, ContainerEdit, - CreatorIdent, CreatorRev, CreatorEdit, - FileIdent, FileRev, FileEdit): - assert cls.query.count() == 1 - for cls in (ReleaseIdent, ReleaseRev, ReleaseEdit): - assert cls.query.count() == 2 - - for cls in (WorkIdent, - ContainerIdent, - CreatorIdent, - FileIdent): - assert cls.query.filter(cls.is_live==True).count() == 1 - assert ReleaseIdent.query.filter(ReleaseIdent.is_live==True).count() == 2 - - # test that editor's active edit group is now invalid - editor = Editor.query.first() - assert editor.active_editgroup == None -- cgit v1.2.3