Skip to content

Commit a3bc2f5

Browse files
committed
Test "propname" requests
1 parent 1b5a133 commit a3bc2f5

File tree

1 file changed

+68
-4
lines changed

1 file changed

+68
-4
lines changed

src/tests.rs

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::consts::{DAV_XML_CONTENT_TYPE, YAML_CONTENT_TYPE};
44
use axum::body::Bytes;
55
use http_body_util::BodyExt; // for `collect`
66
use indoc::indoc;
7-
use testutils::{CollectionEntry, CollectionPage, Link, Resource, Trinary};
7+
use testutils::{CollectionEntry, CollectionPage, Link, Resource, ResourceProps, Trinary};
88
use tower::{Service, ServiceExt}; // for `ready`
99

1010
fn fill_html_footer(html: &str) -> String {
@@ -122,12 +122,10 @@ impl<'a> Propfinder<'a> {
122122
}
123123
}
124124

125-
/*
126125
fn body(mut self, body: &'static str) -> Self {
127126
self.body = Some(body);
128127
self
129128
}
130-
*/
131129

132130
fn depth(mut self, depth: &'static str) -> Self {
133131
self.depth = Some(depth);
@@ -182,6 +180,11 @@ impl PropfindResponse {
182180
testutils::parse_propfind_response(body).unwrap()
183181
}
184182

183+
fn into_propnames(self) -> Vec<ResourceProps> {
184+
let body = std::str::from_utf8(self.0.body()).unwrap();
185+
testutils::parse_propname_response(body).unwrap()
186+
}
187+
185188
fn assert_body(self, expected: &str) -> Self {
186189
let body = std::str::from_utf8(self.0.body()).unwrap();
187190
assert_eq!(body, expected);
@@ -1468,7 +1471,7 @@ async fn propfind_version_toplevel() {
14681471
href: "/dandisets/000001/releases/0.210512.1623/".into(),
14691472
creation_date: Trinary::Set("2021-05-12T16:23:14.388489Z".into()),
14701473
display_name: Trinary::Set("0.210512.1623".into()),
1471-
content_length: Trinary::Set(42489179,),
1474+
content_length: Trinary::Set(42489179),
14721475
content_type: Trinary::Void,
14731476
last_modified: Trinary::Set("Wed, 12 May 2021 16:23:19 GMT".into()),
14741477
etag: Trinary::Void,
@@ -1560,3 +1563,64 @@ async fn propfind_asset_folder() {
15601563
]
15611564
);
15621565
}
1566+
1567+
#[tokio::test]
1568+
async fn propfind_propname() {
1569+
let mut app = MockApp::new().await;
1570+
let props = app
1571+
.propfind("/dandisets/000001/releases/0.210512.1623/")
1572+
.body(r#"<?xml version="1.0" encoding="utf-8"?><propfind xmlns="DAV:"><propname /></propfind>"#)
1573+
.send()
1574+
.await
1575+
.success()
1576+
.into_propnames();
1577+
pretty_assertions::assert_eq!(
1578+
props,
1579+
vec![
1580+
ResourceProps {
1581+
href: "/dandisets/000001/releases/0.210512.1623/".into(),
1582+
creation_date: true,
1583+
display_name: true,
1584+
content_length: true,
1585+
content_type: false,
1586+
last_modified: true,
1587+
etag: false,
1588+
language: false,
1589+
resource_type: true,
1590+
},
1591+
ResourceProps {
1592+
href: "/dandisets/000001/releases/0.210512.1623/participants.tsv".into(),
1593+
creation_date: true,
1594+
display_name: true,
1595+
content_length: true,
1596+
content_type: true,
1597+
last_modified: true,
1598+
etag: true,
1599+
language: false,
1600+
resource_type: true,
1601+
},
1602+
ResourceProps {
1603+
href: "/dandisets/000001/releases/0.210512.1623/sub-RAT123/".into(),
1604+
creation_date: false,
1605+
display_name: true,
1606+
content_length: false,
1607+
content_type: false,
1608+
last_modified: false,
1609+
etag: false,
1610+
language: false,
1611+
resource_type: true,
1612+
},
1613+
ResourceProps {
1614+
href: "/dandisets/000001/releases/0.210512.1623/dandiset.yaml".into(),
1615+
creation_date: false,
1616+
display_name: true,
1617+
content_length: true,
1618+
content_type: true,
1619+
last_modified: false,
1620+
etag: false,
1621+
language: false,
1622+
resource_type: true,
1623+
},
1624+
]
1625+
);
1626+
}

0 commit comments

Comments
 (0)