summaryrefslogtreecommitdiffstats
path: root/rust/tests/test_api_server_http.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-17 15:28:42 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-17 16:34:48 -0800
commit84c92a365620e1a0c3f36aa35395081bd1508c9c (patch)
treec847708ba117b2c4138f048b3cff119cfbbbbe88 /rust/tests/test_api_server_http.rs
parent21b01d1f3b1472bc028b0d0875ddb3d858d2e2d0 (diff)
downloadfatcat-84c92a365620e1a0c3f36aa35395081bd1508c9c.tar.gz
fatcat-84c92a365620e1a0c3f36aa35395081bd1508c9c.zip
add test for parameter parsing
Diffstat (limited to 'rust/tests/test_api_server_http.rs')
-rw-r--r--rust/tests/test_api_server_http.rs83
1 files changed, 83 insertions, 0 deletions
diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs
index 0ec2650a..75893933 100644
--- a/rust/tests/test_api_server_http.rs
+++ b/rust/tests/test_api_server_http.rs
@@ -1813,3 +1813,86 @@ fn test_editgroup_annotations() {
Some("special test annotation"),
);
}
+
+#[test]
+fn test_query_params() {
+ let (headers, router, _conn) = helpers::setup_http();
+
+ helpers::check_http_response(
+ request::get(
+ "http://localhost:9411/v0/changelog?limit=true",
+ headers.clone(),
+ &router,
+ ),
+ status::BadRequest,
+ Some("integer"),
+ );
+
+ helpers::check_http_response(
+ request::get(
+ &format!("http://localhost:9411/v0/editgroup/reviewable?since=asdf"),
+ headers.clone(),
+ &router,
+ ),
+ status::BadRequest,
+ Some("datetime"),
+ );
+
+ helpers::check_http_response(
+ request::get(
+ &format!("http://localhost:9411/v0/editgroup/reviewable?since=1999-06-05T12:34:00Z"),
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ None,
+ );
+
+ // Python3: datetime.datetime.utcnow().isoformat() + "Z"
+ helpers::check_http_response(
+ request::get(
+ &format!(
+ "http://localhost:9411/v0/editgroup/reviewable?since=2019-01-17T23:32:03.269010Z"
+ ),
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ None,
+ );
+
+ // Python3: datetime.datetime.now(datetime.timezone.utc).isoformat()
+ /* TODO: this doesn't work currently :(
+ helpers::check_http_response(
+ request::get(
+ &format!("http://localhost:9411/v0/editgroup/reviewable?since=2019-01-17T23:30:45.799289+00:00"),
+ headers.clone(),
+ &router,
+ ),
+ status::Ok,
+ None,
+ );
+ */
+
+ helpers::check_http_response(
+ request::post(
+ "http://localhost:9411/v0/container/batch?autoaccept=asdf",
+ headers.clone(),
+ r#"[{"name": "test journal"}, {"name": "another test journal"}]"#,
+ &router,
+ ),
+ status::BadRequest,
+ Some("boolean"),
+ );
+
+ helpers::check_http_response(
+ request::post(
+ "http://localhost:9411/v0/container/batch?autoaccept=True",
+ headers.clone(),
+ r#"[{"name": "test journal"}, {"name": "another test journal"}]"#,
+ &router,
+ ),
+ status::Created,
+ None,
+ );
+}