summaryrefslogtreecommitdiffstats
path: root/rust/tests/test_api_server_http.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/tests/test_api_server_http.rs')
-rw-r--r--rust/tests/test_api_server_http.rs267
1 files changed, 133 insertions, 134 deletions
diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs
index 5405c9cb..f84e7e1f 100644
--- a/rust/tests/test_api_server_http.rs
+++ b/rust/tests/test_api_server_http.rs
@@ -21,13 +21,12 @@ use iron_test::request;
use uuid::Uuid;
mod helpers;
-use helpers::{check_http_response, setup_http};
#[test]
fn test_entity_gets() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/aaaaaaaaaaaaaeiraaaaaaaaai",
headers.clone(),
@@ -38,7 +37,7 @@ fn test_entity_gets() {
);
// Check revision encoding
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/aaaaaaaaaaaaaeiraaaaaaaaai",
headers.clone(),
@@ -48,7 +47,7 @@ fn test_entity_gets() {
Some("00000000-0000-0000-1111-fff000000002"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/creator/aaaaaaaaaaaaaircaaaaaaaaae",
headers.clone(),
@@ -58,7 +57,7 @@ fn test_entity_gets() {
Some("Grace Hopper"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/aaaaaaaaaaaaamztaaaaaaaaai",
headers.clone(),
@@ -68,7 +67,7 @@ fn test_entity_gets() {
Some("archive.org"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/fileset/aaaaaaaaaaaaaztgaaaaaaaaam",
headers.clone(),
@@ -78,7 +77,7 @@ fn test_entity_gets() {
Some(".tar.gz"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/webcapture/aaaaaaaaaaaaa53xaaaaaaaaam",
headers.clone(),
@@ -88,7 +87,7 @@ fn test_entity_gets() {
Some("asheesh.org"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/aaaaaaaaaaaaarceaaaaaaaaai",
headers.clone(),
@@ -99,7 +98,7 @@ fn test_entity_gets() {
);
// expand keyword
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/aaaaaaaaaaaaarceaaaaaaaaai?expand=container",
headers.clone(),
@@ -110,7 +109,7 @@ fn test_entity_gets() {
);
// hide keyword
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/aaaaaaaaaaaaarceaaaaaaaaai?hide=refs,container",
headers.clone(),
@@ -120,7 +119,7 @@ fn test_entity_gets() {
Some("bigger example"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/work/aaaaaaaaaaaaavkvaaaaaaaaai",
headers.clone(),
@@ -133,9 +132,9 @@ fn test_entity_gets() {
#[test]
fn test_entity_404() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/creator/aaaaaaaaaaaaairceeeeeeeeee",
headers.clone(),
@@ -148,9 +147,9 @@ fn test_entity_404() {
#[test]
fn test_entity_history() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/aaaaaaaaaaaaaeiraaaaaaaaai/history",
headers.clone(),
@@ -160,7 +159,7 @@ fn test_entity_history() {
Some("changelog"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/creator/aaaaaaaaaaaaaircaaaaaaaaae/history",
headers.clone(),
@@ -170,7 +169,7 @@ fn test_entity_history() {
Some("changelog"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/aaaaaaaaaaaaamztaaaaaaaaam/history",
headers.clone(),
@@ -180,7 +179,7 @@ fn test_entity_history() {
Some("changelog"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/fileset/aaaaaaaaaaaaaztgaaaaaaaaam/history",
headers.clone(),
@@ -190,7 +189,7 @@ fn test_entity_history() {
Some("changelog"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/webcapture/aaaaaaaaaaaaa53xaaaaaaaaam/history",
headers.clone(),
@@ -200,7 +199,7 @@ fn test_entity_history() {
Some("changelog"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/aaaaaaaaaaaaarceaaaaaaaaai/history",
headers.clone(),
@@ -210,7 +209,7 @@ fn test_entity_history() {
Some("changelog"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/work/aaaaaaaaaaaaavkvaaaaaaaaai/history",
headers.clone(),
@@ -223,9 +222,9 @@ fn test_entity_history() {
#[test]
fn test_lookups() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/lookup?issnl=1234-0000",
headers.clone(),
@@ -235,7 +234,7 @@ fn test_lookups() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/lookup?issnl=1234",
headers.clone(),
@@ -245,7 +244,7 @@ fn test_lookups() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/lookup?wikidata_qid=Q84913959359",
headers.clone(),
@@ -255,7 +254,7 @@ fn test_lookups() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/lookup?wikidata_qid=84913959359",
headers.clone(),
@@ -265,7 +264,7 @@ fn test_lookups() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/container/lookup?wikidata_qid=Q84913959359&issnl=1234-0000",
headers.clone(),
@@ -275,7 +274,7 @@ fn test_lookups() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/creator/lookup?orcid=0000-0003-2088-7465",
headers.clone(),
@@ -285,7 +284,7 @@ fn test_lookups() {
Some("Christine Moran"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/creator/lookup?wikidata_qid=Q5678",
headers.clone(),
@@ -295,7 +294,7 @@ fn test_lookups() {
Some("John P. A. Ioannidis"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/creator/lookup?orcid=0000-0003-2088-0000",
headers.clone(),
@@ -305,7 +304,7 @@ fn test_lookups() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/lookup?md5=00000000000ab9fdc2a128f962faebff",
headers.clone(),
@@ -314,7 +313,7 @@ fn test_lookups() {
status::NotFound,
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/lookup?md5=00000000000ab9fdc2a128f962faebfff",
headers.clone(),
@@ -323,7 +322,7 @@ fn test_lookups() {
status::BadRequest,
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/lookup?md5=f4de91152c7ab9fdc2a128f962faebff",
headers.clone(),
@@ -332,7 +331,7 @@ fn test_lookups() {
status::Ok,
Some("0020124&type=printable"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/lookup?sha1=7d97e98f8af710c7e7fe703abc8f639e0ee507c4",
headers.clone(),
@@ -341,7 +340,7 @@ fn test_lookups() {
status::Ok,
Some("robots.txt"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/lookup?sha256=ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362",
headers.clone(),
@@ -351,7 +350,7 @@ fn test_lookups() {
Some("0020124&type=printable"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/lookup?sha1=00000000000000c7e7fe703abc8f639e0ee507c4",
headers.clone(),
@@ -362,7 +361,7 @@ fn test_lookups() {
);
// not URL encoded
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?doi=10.123/abc",
headers.clone(),
@@ -373,7 +372,7 @@ fn test_lookups() {
);
// URL encoded
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?doi=10.123%2Fabc",
headers.clone(),
@@ -383,7 +382,7 @@ fn test_lookups() {
Some("bigger example"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?wikidata_qid=Q55555",
headers.clone(),
@@ -393,7 +392,7 @@ fn test_lookups() {
Some("bigger example"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?pmid=54321",
headers.clone(),
@@ -403,7 +402,7 @@ fn test_lookups() {
Some("bigger example"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?pmcid=PMC555",
headers.clone(),
@@ -413,7 +412,7 @@ fn test_lookups() {
Some("bigger example"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?isbn13=978-3-16-148410-0",
headers.clone(),
@@ -423,7 +422,7 @@ fn test_lookups() {
Some("bigger example"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?core_id=42022773",
headers.clone(),
@@ -436,9 +435,9 @@ fn test_lookups() {
#[test]
fn test_reverse_lookups() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/creator/aaaaaaaaaaaaaircaaaaaaaaai/releases",
headers.clone(),
@@ -448,7 +447,7 @@ fn test_reverse_lookups() {
Some("bigger example"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/aaaaaaaaaaaaarceaaaaaaaaai/files",
headers.clone(),
@@ -458,7 +457,7 @@ fn test_reverse_lookups() {
Some("7d97e98f8af710c7e7fe703abc8f639e0ee507c4"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/aaaaaaaaaaaaarceaaaaaaaaai/filesets",
headers.clone(),
@@ -468,7 +467,7 @@ fn test_reverse_lookups() {
Some("README.md"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/aaaaaaaaaaaaarceaaaaaaaaai/webcaptures",
headers.clone(),
@@ -478,7 +477,7 @@ fn test_reverse_lookups() {
Some("http://example.org"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/work/aaaaaaaaaaaaavkvaaaaaaaaai/releases",
headers.clone(),
@@ -491,9 +490,9 @@ fn test_reverse_lookups() {
#[test]
fn test_post_container() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container",
headers,
@@ -507,9 +506,9 @@ fn test_post_container() {
#[test]
fn test_post_batch_container() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container/batch",
headers,
@@ -523,9 +522,9 @@ fn test_post_batch_container() {
#[test]
fn test_post_creator() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/creator",
headers,
@@ -539,9 +538,9 @@ fn test_post_creator() {
#[test]
fn test_post_file() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/file",
headers.clone(),
@@ -552,7 +551,7 @@ fn test_post_file() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/file",
headers.clone(),
@@ -579,7 +578,7 @@ fn test_post_file() {
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -593,7 +592,7 @@ fn test_post_file() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/file/lookup?sha1=f0000000000000008b7eb2a93e6d0440c1f3e7f8",
headers.clone(),
@@ -606,9 +605,9 @@ fn test_post_file() {
#[test]
fn test_post_fileset() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/fileset",
headers.clone(),
@@ -619,7 +618,7 @@ fn test_post_fileset() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/fileset",
headers.clone(),
@@ -645,7 +644,7 @@ fn test_post_fileset() {
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -663,9 +662,9 @@ fn test_post_fileset() {
#[test]
fn test_post_webcapture() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/webcapture",
headers.clone(),
@@ -677,7 +676,7 @@ fn test_post_webcapture() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/webcapture",
headers.clone(),
@@ -709,7 +708,7 @@ fn test_post_webcapture() {
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -727,9 +726,9 @@ fn test_post_webcapture() {
#[test]
fn test_post_release() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -745,7 +744,7 @@ fn test_post_release() {
); // TODO: "secret paper"
// No work_id supplied (auto-created)
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -759,7 +758,7 @@ fn test_post_release() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -802,7 +801,7 @@ fn test_post_release() {
// Bogus non-existant fields
/* XXX: doesn't fail
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -819,9 +818,9 @@ fn test_post_release() {
#[test]
fn test_post_work() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/work",
headers.clone(),
@@ -838,9 +837,9 @@ fn test_post_work() {
#[test]
fn test_update_work() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/work",
headers.clone(),
@@ -855,7 +854,7 @@ fn test_update_work() {
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -872,9 +871,9 @@ fn test_update_work() {
#[test]
fn test_delete_work() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::delete(
"http://localhost:9411/v0/work/aaaaaaaaaaaaavkvaaaaaaaaai",
headers.clone(),
@@ -886,7 +885,7 @@ fn test_delete_work() {
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -903,7 +902,7 @@ fn test_delete_work() {
#[test]
fn test_accept_editgroup() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
@@ -921,7 +920,7 @@ fn test_accept_editgroup() {
.unwrap();
assert_eq!(c, 0);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container",
headers.clone(),
@@ -934,7 +933,7 @@ fn test_accept_editgroup() {
status::Created,
None,
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container",
headers.clone(),
@@ -955,7 +954,7 @@ fn test_accept_editgroup() {
.unwrap();
assert_eq!(c, 2);
- check_http_response(
+ helpers::check_http_response(
request::get(
&format!(
"http://localhost:9411/v0/editgroup/{}",
@@ -968,7 +967,7 @@ fn test_accept_editgroup() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -998,9 +997,9 @@ fn test_accept_editgroup() {
#[test]
fn test_changelog() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/changelog",
headers.clone(),
@@ -1010,7 +1009,7 @@ fn test_changelog() {
Some("editgroup_id"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/changelog/1",
headers.clone(),
@@ -1023,9 +1022,9 @@ fn test_changelog() {
#[test]
fn test_400() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers,
@@ -1062,9 +1061,9 @@ fn test_400() {
#[test]
fn test_edit_gets() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/editor/aaaaaaaaaaaabkvkaaaaaaaaae",
headers.clone(),
@@ -1074,7 +1073,7 @@ fn test_edit_gets() {
Some("admin"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/editor/aaaaaaaaaaaabkvkaaaaaaaaae/changelog",
headers.clone(),
@@ -1084,7 +1083,7 @@ fn test_edit_gets() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/editgroup/aaaaaaaaaaaabo53aaaaaaaaae",
headers.clone(),
@@ -1097,10 +1096,10 @@ fn test_edit_gets() {
#[test]
fn test_bad_external_idents() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
// Bad wikidata QID
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1112,7 +1111,7 @@ fn test_bad_external_idents() {
status::BadRequest,
Some("Wikidata QID"),
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container",
headers.clone(),
@@ -1124,7 +1123,7 @@ fn test_bad_external_idents() {
status::BadRequest,
Some("Wikidata QID"),
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/creator",
headers.clone(),
@@ -1138,7 +1137,7 @@ fn test_bad_external_idents() {
);
// Bad PMCID
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1152,7 +1151,7 @@ fn test_bad_external_idents() {
);
// Bad PMID
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1166,7 +1165,7 @@ fn test_bad_external_idents() {
);
// Bad DOI
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1180,7 +1179,7 @@ fn test_bad_external_idents() {
);
// Good identifiers
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1199,9 +1198,9 @@ fn test_bad_external_idents() {
#[test]
fn test_abstracts() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1223,7 +1222,7 @@ fn test_abstracts() {
);
// Same abstracts; checking that re-inserting works
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1245,7 +1244,7 @@ fn test_abstracts() {
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -1259,7 +1258,7 @@ fn test_abstracts() {
None,
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?doi=10.1234/iiiiiii",
headers.clone(),
@@ -1269,7 +1268,7 @@ fn test_abstracts() {
// SHA-1 of first abstract string (with no trailing newline)
Some("65c171bd8c968e12ede25ad95f02cd4b2ce9db52"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?doi=10.1234/iiiiiii",
headers.clone(),
@@ -1278,7 +1277,7 @@ fn test_abstracts() {
status::Ok,
Some("99139405"),
);
- check_http_response(
+ helpers::check_http_response(
request::get(
"http://localhost:9411/v0/release/lookup?doi=10.1234/iiiiiii",
headers.clone(),
@@ -1291,9 +1290,9 @@ fn test_abstracts() {
#[test]
fn test_contribs() {
- let (headers, router, conn) = setup_http();
+ let (headers, router, conn) = helpers::setup_http();
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1317,7 +1316,7 @@ fn test_contribs() {
let editor_id = Uuid::parse_str("00000000-0000-0000-AAAA-000000000001").unwrap();
let editgroup_id = get_or_create_editgroup(editor_id, &conn).unwrap();
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!(
"http://localhost:9411/v0/editgroup/{}/accept",
@@ -1334,10 +1333,10 @@ fn test_contribs() {
#[test]
fn test_post_batch_autoaccept() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
// "true"
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container/batch?autoaccept=true",
headers.clone(),
@@ -1349,7 +1348,7 @@ fn test_post_batch_autoaccept() {
);
// "n"
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container/batch?autoaccept=n",
headers.clone(),
@@ -1361,7 +1360,7 @@ fn test_post_batch_autoaccept() {
);
// editgroup
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/container/batch?autoaccept=yes&editgroup_id=asdf",
headers.clone(),
@@ -1375,10 +1374,10 @@ fn test_post_batch_autoaccept() {
#[test]
fn test_release_dates() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
// Ok
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1393,7 +1392,7 @@ fn test_release_dates() {
);
// Ok
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1408,7 +1407,7 @@ fn test_release_dates() {
);
// Ok; ISO 8601
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1421,7 +1420,7 @@ fn test_release_dates() {
status::Created,
None,
);
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1436,7 +1435,7 @@ fn test_release_dates() {
);
// Ok
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1452,7 +1451,7 @@ fn test_release_dates() {
);
// Ok for now, but may be excluded later
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1468,7 +1467,7 @@ fn test_release_dates() {
);
// Bad: year/month only
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1483,7 +1482,7 @@ fn test_release_dates() {
);
// Bad: full timestamp
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1498,7 +1497,7 @@ fn test_release_dates() {
);
// Bad: bogus month/day
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1515,10 +1514,10 @@ fn test_release_dates() {
#[test]
fn test_release_types() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
// Ok
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1532,7 +1531,7 @@ fn test_release_types() {
);
// Bad
- check_http_response(
+ helpers::check_http_response(
request::post(
"http://localhost:9411/v0/release",
headers.clone(),
@@ -1548,10 +1547,10 @@ fn test_release_types() {
#[test]
fn test_create_editgroup() {
- let (headers, router, _conn) = setup_http();
+ let (headers, router, _conn) = helpers::setup_http();
// We're authenticated, so don't need to supply editor_id
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!("http://localhost:9411/v0/editgroup",),
headers.clone(),
@@ -1563,7 +1562,7 @@ fn test_create_editgroup() {
);
// But can if we want to
- check_http_response(
+ helpers::check_http_response(
request::post(
&format!("http://localhost:9411/v0/editgroup",),
headers.clone(),