summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-08 21:43:14 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-08 21:43:17 -0800
commiteb6fb8e5fe1efb3fbb927d13075cf5a1b33aa83e (patch)
treec5f4daeed7e661bdfe41c432d0e8921d3f146489
parentba1bde18d780db53ac3562a3be9ae62bb5729db6 (diff)
downloadfatcat-eb6fb8e5fe1efb3fbb927d13075cf5a1b33aa83e.tar.gz
fatcat-eb6fb8e5fe1efb3fbb927d13075cf5a1b33aa83e.zip
rust 2018 edition!
Only the basics to get things to compile/test again in this commit.
-rw-r--r--rust/Cargo.toml1
-rw-r--r--rust/src/api_entity_crud.rs10
-rw-r--r--rust/src/api_helpers.rs8
-rw-r--r--rust/src/api_server.rs14
-rw-r--r--rust/src/api_wrappers.rs12
-rw-r--r--rust/src/auth.rs8
-rw-r--r--rust/src/database_models.rs6
-rw-r--r--rust/src/lib.rs4
-rw-r--r--rust/tests/test_api_server_client.rs3
-rw-r--r--rust/tests/test_api_server_http.rs267
-rw-r--r--rust/tests/test_old_python_tests.rs5
11 files changed, 168 insertions, 170 deletions
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 677a31e2..2d35dc6f 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "fatcat"
version = "0.1.0"
+edition = "2018"
authors = ["Bryan Newbold <bnewbold@archive.org>"]
description = "A scalable, versioned, API-oriented catalog of bibliographic entities and file metadata"
license = "AGPL 3.0"
diff --git a/rust/src/api_entity_crud.rs b/rust/src/api_entity_crud.rs
index 76fa9bba..44b421f9 100644
--- a/rust/src/api_entity_crud.rs
+++ b/rust/src/api_entity_crud.rs
@@ -1,11 +1,11 @@
-use api_helpers::*;
-use api_server::get_release_files;
+use crate::api_helpers::*;
+use crate::api_server::get_release_files;
use chrono;
-use database_models::*;
-use database_schema::*;
+use crate::database_models::*;
+use crate::database_schema::*;
use diesel::prelude::*;
use diesel::{self, insert_into};
-use errors::*;
+use crate::errors::*;
use fatcat_api_spec::models::*;
use sha1::Sha1;
use std::marker::Sized;
diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs
index 5ee529b9..55085403 100644
--- a/rust/src/api_helpers.rs
+++ b/rust/src/api_helpers.rs
@@ -1,10 +1,10 @@
-use api_entity_crud::EntityCrud;
+use crate::api_entity_crud::EntityCrud;
use data_encoding::BASE32_NOPAD;
-use database_models::*;
-use database_schema::*;
+use crate::database_models::*;
+use crate::database_schema::*;
use diesel;
use diesel::prelude::*;
-use errors::*;
+use crate::errors::*;
use fatcat_api_spec::models::*;
use regex::Regex;
use serde_json;
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 349c6a27..0377f970 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -1,18 +1,18 @@
//! API endpoint handlers
-use api_entity_crud::EntityCrud;
-use api_helpers::*;
-use auth::*;
+use crate::api_entity_crud::EntityCrud;
+use crate::api_helpers::*;
+use crate::auth::*;
use chrono;
-use database_models::*;
-use database_schema::*;
+use crate::database_models::*;
+use crate::database_schema::*;
use diesel::prelude::*;
use diesel::{self, insert_into};
-use errors::*;
+use crate::errors::*;
use fatcat_api_spec::models;
use fatcat_api_spec::models::*;
use std::str::FromStr;
-use ConnectionPool;
+use crate::ConnectionPool;
macro_rules! entity_batch_handler {
($post_batch_handler:ident, $model:ident) => {
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs
index f03d4041..69bdd88e 100644
--- a/rust/src/api_wrappers.rs
+++ b/rust/src/api_wrappers.rs
@@ -1,12 +1,12 @@
//! API endpoint handlers
-use api_entity_crud::EntityCrud;
-use api_helpers::*;
-use api_server::Server;
-use auth::*;
-use database_models::EntityEditRow;
+use crate::api_entity_crud::EntityCrud;
+use crate::api_helpers::*;
+use crate::api_server::Server;
+use crate::auth::*;
+use crate::database_models::EntityEditRow;
use diesel::Connection;
-use errors::*;
+use crate::errors::*;
use fatcat_api_spec::models;
use fatcat_api_spec::models::*;
use fatcat_api_spec::*;
diff --git a/rust/src/auth.rs b/rust/src/auth.rs
index d4e03ecf..da038b6b 100644
--- a/rust/src/auth.rs
+++ b/rust/src/auth.rs
@@ -5,13 +5,13 @@ use macaroon::{Format, Macaroon, Verifier};
use std::fmt;
use swagger::auth::{AuthData, Authorization, Scopes};
-use api_helpers::*;
+use crate::api_helpers::*;
use chrono::prelude::*;
-use database_models::*;
-use database_schema::*;
+use crate::database_models::*;
+use crate::database_schema::*;
use diesel;
use diesel::prelude::*;
-use errors::*;
+use crate::errors::*;
use std::collections::HashMap;
use std::str::FromStr;
diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs
index 59953f6b..ad9aaf29 100644
--- a/rust/src/database_models.rs
+++ b/rust/src/database_models.rs
@@ -1,9 +1,9 @@
#![allow(proc_macro_derive_resolution_fallback)]
-use api_helpers::uuid2fcid;
+use crate::api_helpers::uuid2fcid;
use chrono;
-use database_schema::*;
-use errors::*;
+use crate::database_schema::*;
+use crate::errors::*;
use fatcat_api_spec::models::{ChangelogEntry, Editgroup, Editor, EntityEdit};
use serde_json;
use uuid::Uuid;
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 0d9ef813..18550a5d 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -92,10 +92,10 @@ pub mod errors {
}
#[doc(hidden)]
-pub use errors::*;
+pub use crate::errors::*;
pub use self::errors::*;
-use auth::AuthConfectionary;
+use crate::auth::AuthConfectionary;
use diesel::pg::PgConnection;
use diesel::r2d2::ConnectionManager;
use dotenv::dotenv;
diff --git a/rust/tests/test_api_server_client.rs b/rust/tests/test_api_server_client.rs
index 7d76f3c5..3effc0a3 100644
--- a/rust/tests/test_api_server_client.rs
+++ b/rust/tests/test_api_server_client.rs
@@ -17,13 +17,12 @@ extern crate uuid;
use fatcat_api_spec::{ApiNoContext, ContextWrapperExt, Future};
mod helpers;
-use helpers::setup_client;
// Disabled due to hang
//#[test]
#[allow(dead_code)]
fn test_basic() {
- let (client, context, mut server) = setup_client();
+ let (client, context, mut server) = helpers::setup_client();
let client = client.with_context(context);
client.get_changelog_entry(1).wait().unwrap();
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(),
diff --git a/rust/tests/test_old_python_tests.rs b/rust/tests/test_old_python_tests.rs
index 0401f699..d607fa42 100644
--- a/rust/tests/test_old_python_tests.rs
+++ b/rust/tests/test_old_python_tests.rs
@@ -13,13 +13,12 @@ use fatcat_api_spec::models::*;
use fatcat_api_spec::*;
mod helpers;
-use helpers::setup_client;
// Disabled due to hang
//#[test]
#[allow(dead_code)]
fn test_api_rich_create() {
- let (client, context, mut server) = setup_client();
+ let (client, context, mut server) = helpers::setup_client();
let client = client.with_context(context);
let admin_id = "aaaaaaaaaaaabkvkaaaaaaaaae".to_string();
@@ -195,7 +194,7 @@ fn test_api_rich_create() {
//#[test]
#[allow(dead_code)]
fn test_merge_works() {
- let (client, context, mut server) = setup_client();
+ let (client, context, mut server) = helpers::setup_client();
let client = client.with_context(context);
let admin_id = "aaaaaaaaaaaabkvkaaaaaaaaae".to_string();