diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-04-04 16:48:02 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-04-04 16:48:02 -0700 |
commit | 9dfb5f3f83f715cdb16e68c4dedb12ca87bb93b3 (patch) | |
tree | b99ee6306e13f53d4eb3c6cdcbc71a0e028947a8 | |
parent | a7a9442144e3ab7dfafcfc2274016c58ac5558c0 (diff) | |
download | fatcat-9dfb5f3f83f715cdb16e68c4dedb12ca87bb93b3.tar.gz fatcat-9dfb5f3f83f715cdb16e68c4dedb12ca87bb93b3.zip |
many web test improvements
-rw-r--r-- | python/tests/files/elastic_container_search.json | 1 | ||||
-rw-r--r-- | python/tests/files/elastic_release_search.json | 1 | ||||
-rw-r--r-- | python/tests/fixtures.py | 9 | ||||
-rw-r--r-- | python/tests/web_auth.py | 46 | ||||
-rw-r--r-- | python/tests/web_editgroup.py | 50 | ||||
-rw-r--r-- | python/tests/web_entity_views.py | 31 | ||||
-rw-r--r-- | python/tests/web_routes.py | 23 | ||||
-rw-r--r-- | python/tests/web_search.py | 40 |
8 files changed, 165 insertions, 36 deletions
diff --git a/python/tests/files/elastic_container_search.json b/python/tests/files/elastic_container_search.json new file mode 100644 index 00000000..e12d8883 --- /dev/null +++ b/python/tests/files/elastic_container_search.json @@ -0,0 +1 @@ +{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":107823,"max_score":1.0,"hits":[{"_index":"fatcat_container","_type":"container","_id":"tnrwkuo6srahvhtn6ugpxyfcvq","_score":1.0,"_source":{"is_oa": false, "publisher": "Georg Thieme Verlag", "name": "Flugmedizin Tropenmedizin Reisemedizin", "ident": "tnrwkuo6srahvhtn6ugpxyfcvq", "any_kbart": true, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "a0108581-ead9-40d0-8aee-f47b171088a4", "any_jstor": false, "in_sherpa_romeo": true, "issnl": "0947-7616", "any_ia_sim": false, "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"icf6lv4p6bbjbekygsqhniwshy","_score":1.0,"_source":{"is_oa": false, "languages": ["en"], "publisher": "British Editorial Society of Bone and Joint Surger", "name": "European Instructional Course Lectures", "ident": "icf6lv4p6bbjbekygsqhniwshy", "any_kbart": false, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "53d58d3d-d1e4-4a58-93bf-fe18286a8659", "any_jstor": false, "in_sherpa_romeo": false, "issnl": "1359-2335", "any_ia_sim": false, "country": "gb", "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"re37glwyaffybnlzknloc7ryhq","_score":1.0,"_source":{"is_oa": false, "publisher": null, "name": "Statistics of Navy medicine", "ident": "re37glwyaffybnlzknloc7ryhq", "any_kbart": false, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "bb18aede-9783-422e-8031-631a38b4d585", "any_jstor": false, "in_sherpa_romeo": false, "issnl": "0146-3020", "any_ia_sim": false, "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"2c2wb5wsjfgyja6lxfqebtqs5u","_score":1.0,"_source":{"is_oa": false, "publisher": null, "name": "Agrartorteneti szemle = Historia rerum rusticarum", "ident": "2c2wb5wsjfgyja6lxfqebtqs5u", "any_kbart": false, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "ce5677a7-7bb2-4546-9afd-2760a8c9dbae", "any_jstor": false, "in_sherpa_romeo": false, "issnl": "0002-1105", "any_ia_sim": false, "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"v6w5dfwjsjbsfmji6ektlu2a64","_score":1.0,"_source":{"is_oa": false, "languages": ["en"], "publisher": "The University of Chicago Press", "name": "Source", "ident": "v6w5dfwjsjbsfmji6ektlu2a64", "any_kbart": true, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "29c87763-c076-4862-8efc-60b2ed6b328b", "any_jstor": true, "in_sherpa_romeo": true, "issnl": "0737-4453", "any_ia_sim": false, "country": "us", "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"x4klwmn2frbjpmqqi2w6tecf5u","_score":1.0,"_source":{"is_oa": false, "publisher": null, "name": "The Toxicologist : an official publication of the Society of Toxicology", "ident": "x4klwmn2frbjpmqqi2w6tecf5u", "any_kbart": false, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "895f5004-fee1-45e8-ba2d-a14c41a1bc48", "any_jstor": false, "in_sherpa_romeo": false, "issnl": "0731-9193", "any_ia_sim": false, "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"sostwre6tbdk3ffe2mfho4mmhm","_score":1.0,"_source":{"is_oa": false, "publisher": "Publicaciones Universidad de Alicante", "name": "Journal of Physical Agents (JoPha)", "ident": "sostwre6tbdk3ffe2mfho4mmhm", "any_kbart": false, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "6c16b7b2-c5da-48b1-9cd6-d5adbc1bbd21", "any_jstor": false, "in_sherpa_romeo": false, "issnl": "1888-0258", "any_ia_sim": false, "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"vop54mgelfc3vdtkn63d63iasy","_score":1.0,"_source":{"is_oa": false, "publisher": "J-STAGE", "name": "Japan D.H. Lawrence Studies", "ident": "vop54mgelfc3vdtkn63d63iasy", "any_kbart": true, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "0ef013ed-dec3-404d-9d23-7a5cf53b3a89", "any_jstor": false, "in_sherpa_romeo": false, "issnl": "1342-2405", "any_ia_sim": false, "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"z7md365rqbf4tkyxwm67nh4lii","_score":1.0,"_source":{"is_oa": true, "publisher": "Journal of Pattern Recognition Research", "name": "Journal of Pattern Recognition Research", "ident": "z7md365rqbf4tkyxwm67nh4lii", "any_kbart": false, "container_type": null, "in_road": true, "state": "active", "in_doi": false, "revision": "ec75dd56-b66d-46dd-9ec7-337dc4110a04", "any_jstor": false, "in_sherpa_romeo": false, "issnl": "1558-884X", "any_ia_sim": false, "country": "us", "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}},{"_index":"fatcat_container","_type":"container","_id":"gfx3e6zx4jhmjdt5vawwdszihm","_score":1.0,"_source":{"is_oa": false, "publisher": "Aarhus Universitet", "name": "Distinktion : Scandinavian Journal of Social Theory", "ident": "gfx3e6zx4jhmjdt5vawwdszihm", "any_kbart": true, "container_type": null, "in_road": false, "state": "active", "in_doi": false, "revision": "e3958737-423a-40ef-b716-e12b6e8584c2", "any_jstor": false, "in_sherpa_romeo": true, "issnl": "1600-910X", "any_ia_sim": false, "country": "dk", "is_longtail_oa": false, "in_doaj": false, "wikidata_qid": null}}]}}
\ No newline at end of file diff --git a/python/tests/files/elastic_release_search.json b/python/tests/files/elastic_release_search.json new file mode 100644 index 00000000..ce462049 --- /dev/null +++ b/python/tests/files/elastic_release_search.json @@ -0,0 +1 @@ +{"took":299,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":98618704,"max_score":1.0,"hits":[{"_index":"fatcat_release","_type":"release","_id":"6a4bihzfkzbfxgwpo2ojjrmgxi","_score":1.0,"_source":{"best_pdf_url": null, "container_issnl": "1089-5639", "in_kbart": true, "doi": "10.1021/jp992317v", "revision": "a7b76f63-f3cd-47d8-bb57-145b9cf3e8f5", "fileset_count": 0, "in_ia_sim": false, "is_longtail_oa": false, "is_preserved": true, "state": "active", "publisher": "ACS Publications", "ident": "6a4bihzfkzbfxgwpo2ojjrmgxi", "is_oa": false, "in_dweb": false, "wikidata_qid": null, "core_id": null, "file_count": 0, "contrib_names": ["A. Allouche"], "container_name": "Journal of Physical Chemistry A", "release_status": "published", "webcapture_count": 0, "pmid": null, "release_type": "article-journal", "pmcid": null, "in_jstor": false, "arxiv_id": null, "title": "Quantum Studies of Acetylene Adsorption on Ice Surface", "any_abstract": false, "contrib_count": 1, "isbn13": null, "ia_pdf_url": null, "original_title": null, "license": null, "in_ia": false, "release_year": 1999, "in_web": false, "ref_count": 0, "jstor_id": null, "language": "en", "container_type": null}},{"_index":"fatcat_release","_type":"release","_id":"mtlapyek2fgxzo4ts7nrmeqyqi","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0192-2882", "contrib_count": 1, "arxiv_id": null, "revision": "6a7ce823-96cb-4b55-b668-4000a87450f5", "best_pdf_url": null, "in_jstor": true, "fileset_count": 0, "in_ia": false, "title": "Pinter's Staged \"Monologue\"", "any_abstract": false, "is_preserved": true, "in_dweb": false, "container_type": null, "wikidata_qid": null, "ref_count": 0, "in_web": false, "isbn13": null, "original_title": null, "ident": "mtlapyek2fgxzo4ts7nrmeqyqi", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 1980, "container_name": "Theatre journal (Washington, D.C.)", "in_ia_sim": true, "is_longtail_oa": false, "in_kbart": true, "contrib_names": ["Bernard F. Dukore"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": null, "publisher": "Project MUSE", "ia_pdf_url": null, "pmid": null, "doi": "10.2307/3207411"}},{"_index":"fatcat_release","_type":"release","_id":"xogjlyaitfhgxdbhimqwr3l7ce","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0192-2882", "contrib_count": 2, "arxiv_id": null, "revision": "040a4094-a41f-44a3-b5c9-ec45e8240011", "best_pdf_url": null, "in_jstor": true, "fileset_count": 0, "in_ia": false, "title": "Thomas Betterton and the Management of Lincoln's Inn Fields: 1695-1708", "any_abstract": false, "is_preserved": true, "in_dweb": false, "container_type": null, "wikidata_qid": null, "ref_count": 0, "in_web": false, "isbn13": null, "original_title": null, "ident": "xogjlyaitfhgxdbhimqwr3l7ce", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 1980, "container_name": "Theatre journal (Washington, D.C.)", "in_ia_sim": true, "is_longtail_oa": false, "in_kbart": true, "contrib_names": ["Daniel J. Watermeier", "Judith Milhous"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": null, "publisher": "Project MUSE", "ia_pdf_url": null, "pmid": null, "doi": "10.2307/3207432"}},{"_index":"fatcat_release","_type":"release","_id":"cvhigc5j7zduxn3cjppygzjhoy","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0275-1879", "contrib_count": 1, "arxiv_id": null, "revision": "7367ecb4-4eff-4304-b0a9-a533b3ce7035", "best_pdf_url": null, "in_jstor": false, "fileset_count": 0, "in_ia": false, "title": "Dental management of a patient with Rubinstein-Taybi syndrome", "any_abstract": false, "is_preserved": true, "in_dweb": false, "container_type": null, "wikidata_qid": "Q48356033", "ref_count": 13, "in_web": false, "isbn13": null, "original_title": null, "ident": "cvhigc5j7zduxn3cjppygzjhoy", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 2010, "container_name": "Special Care in Dentistry: managing special patients, settings, and situations", "in_ia_sim": true, "is_longtail_oa": false, "in_kbart": true, "contrib_names": ["Mariana C. Morales-Ch\u00e1vez"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": "en", "publisher": "Wiley (Blackwell Publishing)", "ia_pdf_url": null, "pmid": "20500708", "release_date": "2010-04-12", "doi": "10.1111/j.1754-4505.2010.00137.x"}},{"_index":"fatcat_release","_type":"release","_id":"n2zq5cyan5bhfoskhwe6klfwcm","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0192-2882", "contrib_count": 2, "arxiv_id": null, "revision": "1aab55f2-d35d-4ebc-8688-f0df3c8f8c22", "best_pdf_url": null, "in_jstor": true, "fileset_count": 0, "in_ia": false, "title": "Training the Young Actor", "any_abstract": false, "is_preserved": true, "in_dweb": false, "container_type": null, "wikidata_qid": null, "ref_count": 0, "in_web": false, "isbn13": null, "original_title": null, "ident": "n2zq5cyan5bhfoskhwe6klfwcm", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 1980, "container_name": "Theatre journal (Washington, D.C.)", "in_ia_sim": true, "is_longtail_oa": false, "in_kbart": true, "contrib_names": ["Kenneth Lee Jones", "Michael R. Malkin"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": null, "publisher": "Project MUSE", "ia_pdf_url": null, "pmid": null, "doi": "10.2307/3207438"}},{"_index":"fatcat_release","_type":"release","_id":"qmocfeg44rhvlojnquxyr5j62y","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0192-2882", "contrib_count": 1, "arxiv_id": null, "revision": "288f3923-eb82-4eed-b540-f022e140de14", "best_pdf_url": null, "in_jstor": true, "fileset_count": 0, "in_ia": false, "title": "Theatre in Madrid: The Difficult Transition to Democracy", "any_abstract": false, "is_preserved": true, "in_dweb": false, "container_type": null, "wikidata_qid": null, "ref_count": 0, "in_web": false, "isbn13": null, "original_title": null, "ident": "qmocfeg44rhvlojnquxyr5j62y", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 1980, "container_name": "Theatre journal (Washington, D.C.)", "in_ia_sim": true, "is_longtail_oa": false, "in_kbart": true, "contrib_names": ["Phyllis Zatlin Boring"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": null, "publisher": "Project MUSE", "ia_pdf_url": null, "pmid": null, "doi": "10.2307/3207408"}},{"_index":"fatcat_release","_type":"release","_id":"s3zud6qfxvffhnbhpdd6nqpapq","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0095-3679", "contrib_count": 2, "arxiv_id": null, "revision": "f9d3231d-eb5f-4fb9-9904-96fb81f7b9ea", "best_pdf_url": null, "in_jstor": false, "fileset_count": 0, "in_ia": false, "title": "Effect of Dinitroaniline Herbicides upon Yield and Grade of Five Runner Cultivars1", "any_abstract": false, "is_preserved": false, "in_dweb": false, "container_type": null, "wikidata_qid": null, "ref_count": 0, "in_web": false, "isbn13": null, "original_title": null, "ident": "s3zud6qfxvffhnbhpdd6nqpapq", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 1993, "container_name": "Peanut Science", "in_ia_sim": false, "is_longtail_oa": false, "in_kbart": false, "contrib_names": ["W. James Grichar", "A. Edwin Colburn"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": "en", "publisher": "American Peanut Research & Education Society", "ia_pdf_url": null, "pmid": null, "doi": "10.3146/i0095-3679-20-2-15"}},{"_index":"fatcat_release","_type":"release","_id":"jvexnxqmznahtmyg2rwcnyml6i","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0275-1879", "contrib_count": 5, "arxiv_id": null, "revision": "bca77810-60ec-4e3c-ba78-bf68de313b54", "best_pdf_url": null, "in_jstor": false, "fileset_count": 0, "in_ia": false, "title": "Letter to the editor", "any_abstract": false, "is_preserved": true, "in_dweb": false, "container_type": null, "wikidata_qid": null, "ref_count": 14, "in_web": false, "isbn13": null, "original_title": null, "ident": "jvexnxqmznahtmyg2rwcnyml6i", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 2010, "container_name": "Special Care in Dentistry: managing special patients, settings, and situations", "in_ia_sim": true, "is_longtail_oa": false, "in_kbart": true, "contrib_names": ["Renata Gon\u00e7alves Resende", "Jeane De F\u00e1tima Correia-Silva", "Humberto Correa De Almeida", "Ricardo Rodrigues Vaz", "Ricardo Santiago Gomez"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": "en", "publisher": "Wiley (Blackwell Publishing)", "ia_pdf_url": null, "pmid": "20500709", "release_date": "2010-04-12", "doi": "10.1111/j.1754-4505.2010.00138.x"}},{"_index":"fatcat_release","_type":"release","_id":"p7qzwzf4y5a67c7eglp6j5xzba","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0140-0118", "contrib_count": 3, "arxiv_id": null, "revision": "935f835b-a6b5-4479-8098-4485f7425c9c", "best_pdf_url": null, "in_jstor": false, "fileset_count": 0, "in_ia": false, "title": "Spectrum of a series of point events, generated by the integral pulse frequency modulation model", "any_abstract": false, "is_preserved": true, "in_dweb": false, "container_type": null, "wikidata_qid": "Q52674850", "ref_count": 10, "in_web": false, "isbn13": null, "original_title": null, "ident": "p7qzwzf4y5a67c7eglp6j5xzba", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 1985, "container_name": "Medical and Biological Engineering and Computing", "in_ia_sim": false, "is_longtail_oa": false, "in_kbart": true, "contrib_names": ["R. W. de Boer", "J. M. Karemaker", "Jan Strackee"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": "en", "publisher": "Springer-Verlag", "ia_pdf_url": null, "pmid": "3982093", "doi": "10.1007/bf02456750"}},{"_index":"fatcat_release","_type":"release","_id":"ptw63egenzdyxj7qfgab446tra","_score":1.0,"_source":{"is_oa": false, "jstor_id": null, "container_issnl": "0253-4827", "contrib_count": 1, "arxiv_id": null, "revision": "3fe73c6a-9364-4ddc-b3bb-e7dd839f41d9", "best_pdf_url": null, "in_jstor": false, "fileset_count": 0, "in_ia": false, "title": "On problems of U-shaped bellows with nonlinear deformation of large axisymmetrical deflection (II) \u2014Counting variation of thickness distribution", "any_abstract": false, "is_preserved": false, "in_dweb": false, "container_type": null, "wikidata_qid": null, "ref_count": 4, "in_web": false, "isbn13": null, "original_title": null, "ident": "ptw63egenzdyxj7qfgab446tra", "webcapture_count": 0, "core_id": null, "release_type": "article-journal", "release_year": 1993, "container_name": "Applied mathematics and mechanics", "in_ia_sim": false, "is_longtail_oa": false, "in_kbart": false, "contrib_names": ["Hu Liang"], "pmcid": null, "file_count": 0, "release_status": "published", "state": "active", "license": null, "language": "en", "publisher": "Springer-Verlag", "ia_pdf_url": null, "pmid": null, "doi": "10.1007/bf02451365"}}]}}
\ No newline at end of file diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py index d7ebdac8..b3dba19f 100644 --- a/python/tests/fixtures.py +++ b/python/tests/fixtures.py @@ -21,6 +21,15 @@ def app(full_app): return full_app.test_client() @pytest.fixture +def app_admin(app): + ADMIN_DEV_TOKEN = "AgEPZGV2LmZhdGNhdC53aWtpAhYyMDE5MDEwMS1kZXYtZHVtbXkta2V5AAImZWRpdG9yX2lkID0gYWFhYWFhYWFhYWFhYmt2a2FhYWFhYWFhYWkAAht0aW1lID4gMjAxOS0wNC0wNFQyMzozMjo0NloAAAYgrN3jjy0mgEqIydTFfsOLYSS55dz6Fh2d1CGMNQFLwcQ=" + rv = app.post('/auth/token_login', + data=dict(token=ADMIN_DEV_TOKEN), + follow_redirects=True) + assert rv.status_code == 200 + return app + +@pytest.fixture def api(): load_dotenv(dotenv_path="./example.env") conf = fatcat_client.Configuration() diff --git a/python/tests/web_auth.py b/python/tests/web_auth.py new file mode 100644 index 00000000..81986eec --- /dev/null +++ b/python/tests/web_auth.py @@ -0,0 +1,46 @@ + +import json +import pytest +import responses +from fatcat_client.rest import ApiException +from fixtures import * + + +@responses.activate +def test_ia_xauth_fail(full_app): + + # failed login + with full_app.test_client() as app: + + rv = app.get('/auth/ia/login') + assert rv.status_code == 200 + + responses.add(responses.POST, full_app.config['IA_XAUTH_URI'] + "?op=authenticate", + status=401, json=dict(success=False)) + rv = app.post('/auth/ia/login', follow_redirects=True, + data=dict(email="abcd@example.com", password="god")) + assert rv.status_code == 401 + +@responses.activate +def test_ia_xauth(full_app): + + # successful login + with full_app.test_client() as app: + responses.add(responses.POST, full_app.config['IA_XAUTH_URI'] + "?op=authenticate", + status=200, json={'success': True}) + responses.add(responses.POST, full_app.config['IA_XAUTH_URI'] + "?op=info", + status=200, json={ + 'success': True, + 'values': {'screenname': "user123", + 'itemname': "user_item123"}}) + rv = app.post('/auth/ia/login', follow_redirects=True, + data=dict(email="abcd@example.com", password="god")) + assert rv.status_code == 200 + +def test_basic_auth_views(app): + + rv = app.get('/auth/login') + assert rv.status_code == 200 + + rv = app.get('/auth/logout') + assert rv.status_code == 200 diff --git a/python/tests/web_editgroup.py b/python/tests/web_editgroup.py index e6185eda..2ce90fcb 100644 --- a/python/tests/web_editgroup.py +++ b/python/tests/web_editgroup.py @@ -1,20 +1,62 @@ import json -import tempfile import pytest from fatcat_client.rest import ApiException from fixtures import * -def test_web_editgroup(app): +def test_editgroup_basics(app): rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaae') assert rv.status_code == 200 - rv = app.get('/editgroup/ccccccccccccccccccccccccca') assert rv.status_code == 404 rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae') assert rv.status_code == 200 - + rv = app.get('/editor/ccccccccccccccccccccccccca') + assert rv.status_code == 404 rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae/editgroups') assert rv.status_code == 200 + rv = app.get('/editor/ccccccccccccccccccccccccca/editgroups') + assert rv.status_code == 404 + + rv = app.get('/changelog') + assert rv.status_code == 200 + rv = app.get('/changelog/1') + assert rv.status_code == 200 + rv = app.get('/changelog/1.3') + assert rv.status_code == 404 + rv = app.get('/changelog/9999999') + assert rv.status_code == 404 + + rv = app.get('/reviewable') + assert rv.status_code == 200 + +def test_editgroup_annotations(app): + + rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaa4') + assert rv.status_code == 200 + assert b'updated with changes, please re-review' in rv.data + assert b'concerns about this edit...' in rv.data + assert b'Admin' in rv.data + assert b'demo-user' in rv.data + assert b'claire' in rv.data + assert b'Signup' in rv.data + assert b'Add Comment' not in rv.data + + rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaaq/annotations') + assert rv.status_code == 200 + assert b'updated with changes, please re-review' not in rv.data + assert b'concerns about this edit...' in rv.data + assert b'Admin' not in rv.data + assert b'claire' in rv.data + assert b'aaaaaaaaaaaabo53aaaaaaaaa4' in rv.data + +def test_editgroup_annotations_login(app_admin): + + # if logged in, should see form + rv = app_admin.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaa4') + 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_entity_views.py b/python/tests/web_entity_views.py index fe2371ed..480b39cc 100644 --- a/python/tests/web_entity_views.py +++ b/python/tests/web_entity_views.py @@ -1,6 +1,5 @@ import json -import tempfile import pytest from fatcat_client.rest import ApiException from fixtures import * @@ -45,8 +44,11 @@ def test_entity_basics(app): rv = app.get('/{}/ccccccccccccccccccccccccca'.format(entity_type)) assert rv.status_code == 404 + # TODO: redirects and deleted entities -def test_container(app): + +def test_container(app_admin): + app = app_admin rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai') assert rv.status_code == 200 @@ -55,7 +57,7 @@ def test_container(app): assert rv.status_code == 200 rv = app.get('/container/create') - # XXX: login assert rv.status_code == 200 + assert rv.status_code == 200 def test_lookups(app): @@ -103,35 +105,42 @@ def test_lookups(app): def test_web_creator(app): + # not logged in rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai') assert rv.status_code == 200 - rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/edit') - assert rv.status_code == 200 + assert rv.status_code == 302 def test_web_file(app): + # not logged in rv = app.get('/file/aaaaaaaaaaaaamztaaaaaaaaai') assert rv.status_code == 200 - rv = app.get('/file/aaaaaaaaaaaaamztaaaaaaaaai/edit') - assert rv.status_code == 200 - + assert rv.status_code == 302 rv = app.get('/file/aaaaaaaaaaaaamztaaaaaaaaai/history') assert rv.status_code == 200 def test_web_release(app): + # not logged in rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai') assert rv.status_code == 200 rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/edit') - assert rv.status_code == 200 - + assert rv.status_code == 302 rv = app.get('/release/create') - # XXX: login assert rv.status_code == 200 + assert rv.status_code == 302 + + +def test_web_release_login(app_admin): + + rv = app_admin.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/edit') + assert rv.status_code == 200 + rv = app_admin.get('/release/create') + assert rv.status_code == 200 def test_web_search(app): diff --git a/python/tests/web_routes.py b/python/tests/web_routes.py index e6387882..889bdd90 100644 --- a/python/tests/web_routes.py +++ b/python/tests/web_routes.py @@ -1,34 +1,15 @@ import json -import tempfile import pytest from fatcat_client.rest import ApiException from fixtures import * def test_static_routes(app): - for route in ('/health.json', '/robots.txt', '/', '/about'): + for route in ('/health.json', '/robots.txt', '/', '/about', '/rfc', + '/static/fatcat.jpg'): rv = app.get(route) assert rv.status_code == 200 assert app.get("/static/bogus/route").status_code == 404 - -def test_all_views(app): - - rv = app.get('/editgroup/aaaaaaaaaaaabo53aaaaaaaaae') - assert rv.status_code == 200 - - rv = app.get('/editgroup/ccccccccccccccccccccccccca') - print(rv) - print(rv.data) - assert rv.status_code == 404 - - #rv = app.get('/editgroup/current') - #assert rv.status_code == 302 - - rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae') - assert rv.status_code == 200 - - rv = app.get('/editor/aaaaaaaaaaaabkvkaaaaaaaaae/editgroups') - assert rv.status_code == 200 diff --git a/python/tests/web_search.py b/python/tests/web_search.py new file mode 100644 index 00000000..4e7cb2e0 --- /dev/null +++ b/python/tests/web_search.py @@ -0,0 +1,40 @@ + +import json +import pytest +import responses +from fatcat_client.rest import ApiException +from fixtures import * + +@responses.activate +def test_release_search(app): + + with open('tests/files/elastic_release_search.json') as f: + elastic_resp=json.loads(f.read()) + + responses.add(responses.GET, 'http://localhost:9200/fatcat_release/_search', + json=elastic_resp, status=200) + + rv = app.get('/release/search?q=blood') + assert rv.status_code == 200 + assert b"Showing top " in rv.data + +@responses.activate +def test_container_search(app): + + with open('tests/files/elastic_container_search.json') as f: + elastic_resp=json.loads(f.read()) + + responses.add(responses.GET, 'http://localhost:9200/fatcat_container/_search', + json=elastic_resp, status=200) + + rv = app.get('/container/search?q=blood') + assert rv.status_code == 200 + assert b"Showing top " in rv.data + assert b"European Instructional Course Lectures" in rv.data + assert b"British Editorial Society of Bone and Joint Surger" in rv.data + +# TODO: entity stats +# TODO: container stats +# TODO: container ISSN-L query +# TODO: release DOI query +# TODO: release fulltext query |