diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-11-14 19:59:08 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-11-14 19:59:08 -0800 |
commit | b8aa57160b6b5de9dca3196a792f46c6f785da31 (patch) | |
tree | 0cf7999d6c2c79652038d3f2b18621e020c56c49 /rust | |
parent | e095a6587c1915941d4ee4d4742418b31103ae46 (diff) | |
download | fatcat-b8aa57160b6b5de9dca3196a792f46c6f785da31.tar.gz fatcat-b8aa57160b6b5de9dca3196a792f46c6f785da31.zip |
implement new controlled vocabularies
Diffstat (limited to 'rust')
-rw-r--r-- | rust/migrations/2018-05-12-001226_init/up.sql | 4 | ||||
-rw-r--r-- | rust/tests/test_api_server_http.rs | 53 | ||||
-rw-r--r-- | rust/tests/test_old_python_tests.rs | 8 |
3 files changed, 49 insertions, 16 deletions
diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index 83bce88b..b5214078 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -427,8 +427,8 @@ INSERT INTO work_edit (ident_id, rev_id, redirect_id, editgroup_id, prev_rev) VA INSERT INTO release_rev (id, work_ident_id, container_ident_id, title, release_type, release_status, release_date, doi, isbn13, core_id, volume, issue, pages, publisher, language) VALUES ('00000000-0000-0000-4444-FFF000000001', '00000000-0000-0000-5555-000000000001', null, 'example title', null, null, null, null, null, null, null, null, null, null, null), - ('00000000-0000-0000-4444-FFF000000002', '00000000-0000-0000-5555-000000000002', '00000000-0000-0000-1111-000000000001', 'bigger example', 'journal-article', null,'2018-01-01', '10.123/abc', '978-3-16-148410-0', '42022773', '12', 'IV', '5-9', 'bogus publishing group', 'cn'), - ('00000000-0000-0000-4444-FFF000000003', '00000000-0000-0000-5555-000000000003', '00000000-0000-0000-1111-000000000003', 'Why Most Published Research Findings Are False', 'journal-article', 'published', '2005-08-30', '10.1371/journal.pmed.0020124', null, null, '2', '8', 'e124', 'Public Library of Science', 'en'); + ('00000000-0000-0000-4444-FFF000000002', '00000000-0000-0000-5555-000000000002', '00000000-0000-0000-1111-000000000001', 'bigger example', 'article-journal', null,'2018-01-01', '10.123/abc', '978-3-16-148410-0', '42022773', '12', 'IV', '5-9', 'bogus publishing group', 'cn'), + ('00000000-0000-0000-4444-FFF000000003', '00000000-0000-0000-5555-000000000003', '00000000-0000-0000-1111-000000000003', 'Why Most Published Research Findings Are False', 'article-journal', 'published', '2005-08-30', '10.1371/journal.pmed.0020124', null, null, '2', '8', 'e124', 'Public Library of Science', 'en'); INSERT INTO release_ident (id, is_live, rev_id, redirect_id) VALUES ('00000000-0000-0000-4444-000000000001', true, '00000000-0000-0000-4444-FFF000000001', null), -- aaaaaaaaaaaaarceaaaaaaaaae diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs index 6df616a6..0aa6b062 100644 --- a/rust/tests/test_api_server_http.rs +++ b/rust/tests/test_api_server_http.rs @@ -385,7 +385,7 @@ fn test_post_release() { headers.clone(), // TODO: target_release_id r#"{"title": "secret minimal paper", - "release_type": "journal-article", + "release_type": "article-journal", "work_id": "aaaaaaaaaaaaavkvaaaaaaaaae" }"#, &router, @@ -401,7 +401,7 @@ fn test_post_release() { headers.clone(), // TODO: target_release_id r#"{"title": "secret minimal paper the second", - "release_type": "journal-article" + "release_type": "article-journal" }"#, &router, ), @@ -412,10 +412,10 @@ fn test_post_release() { check_http_response( request::post( "http://localhost:9411/v0/release", - headers, + headers.clone(), // TODO: target_release_id r#"{"title": "secret paper", - "release_type": "journal-article", + "release_type": "article-journal", "release_date": "2000-01-02", "doi": "10.1234/abcde.781231231239", "pmid": "54321", @@ -437,7 +437,7 @@ fn test_post_release() { "index": 1, "raw_name": "textual description of contributor (aka, name)", "creator_id": "aaaaaaaaaaaaaircaaaaaaaaae", - "contrib_type": "author" + "role": "author" },{ "raw_name": "shorter" }], @@ -683,7 +683,7 @@ fn test_400() { "http://localhost:9411/v0/release", headers, r#"{"title": "secret paper", - "release_type": "journal-article", + "release_type": "article-journal", "doi": "10.1234/abcde.781231231239", "volume": "439", "issue": "IV", @@ -1036,7 +1036,7 @@ fn test_release_dates() { "http://localhost:9411/v0/release", headers.clone(), r#"{"title": "secret minimal paper", - "release_type": "journal-article", + "release_type": "article-journal", "release_date": "2000-01-02" }"#, &router, @@ -1051,7 +1051,7 @@ fn test_release_dates() { "http://localhost:9411/v0/release", headers.clone(), r#"{"title": "secret minimal paper", - "release_type": "journal-article", + "release_type": "article-journal", "release_date": "2000-01" }"#, &router, @@ -1066,7 +1066,7 @@ fn test_release_dates() { "http://localhost:9411/v0/release", headers.clone(), r#"{"title": "secret minimal paper", - "release_type": "journal-article", + "release_type": "article-journal", "release_date": "2005-08-30T00:00:00Z" }"#, &router, @@ -1081,7 +1081,7 @@ fn test_release_dates() { "http://localhost:9411/v0/release", headers.clone(), r#"{"title": "secret minimal paper", - "release_type": "journal-article", + "release_type": "article-journal", "release_date": "2000-88-99" }"#, &router, @@ -1090,3 +1090,36 @@ fn test_release_dates() { None, ); } + +#[test] +fn test_release_types() { + let (headers, router, _conn) = setup_http(); + + // Ok + check_http_response( + request::post( + "http://localhost:9411/v0/release", + headers.clone(), + r#"{"title": "secret minimal paper", + "release_type": "article-journal" + }"#, + &router, + ), + status::Created, + None, + ); + + // Bad + check_http_response( + request::post( + "http://localhost:9411/v0/release", + headers.clone(), + r#"{"title": "secret minimal paper", + "release_type": "journal-article" + }"#, + &router, + ), + status::BadRequest, + Some("release_type"), + ); +} diff --git a/rust/tests/test_old_python_tests.rs b/rust/tests/test_old_python_tests.rs index ebe1dd0b..1b496328 100644 --- a/rust/tests/test_old_python_tests.rs +++ b/rust/tests/test_old_python_tests.rs @@ -68,7 +68,7 @@ fn test_api_rich_create() { // this stub work will be referenced let mut new_release = ReleaseEntity::new("derivative work".to_string()); - new_release.release_type = Some("journal-article".to_string()); + new_release.release_type = Some("article-journal".to_string()); new_release.work_id = Some(work_id.clone()); let mut contrib = ReleaseContrib::new(); contrib.creator_id = Some(creator_id.clone()); @@ -209,7 +209,7 @@ fn test_merge_works() { _ => unreachable!(), }; let mut new_release = ReleaseEntity::new("some release".to_string()); - new_release.release_type = Some("journal-article".to_string()); + new_release.release_type = Some("article-journal".to_string()); new_release.work_id = Some(work_a_id.clone()); new_release.doi = Some("10.1234/A1".to_string()); let resp = client @@ -231,7 +231,7 @@ fn test_merge_works() { }; let mut new_release = ReleaseEntity::new("some release".to_string()); - new_release.release_type = Some("journal-article".to_string()); + new_release.release_type = Some("article-journal".to_string()); new_release.work_id = Some(work_b_id.clone()); new_release.doi = Some("10.1234/B1".to_string()); let resp = client @@ -244,7 +244,7 @@ fn test_merge_works() { }; let mut new_release = ReleaseEntity::new("some release".to_string()); - new_release.release_type = Some("journal-article".to_string()); + new_release.release_type = Some("article-journal".to_string()); new_release.work_id = Some(work_b_id.clone()); new_release.doi = Some("10.1234/B2".to_string()); let resp = client |