Skip to content

Commit 065af02

Browse files
author
Brendan O'Connell
committed
Add tests, fix format errors
1 parent 104bb70 commit 065af02

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

thoth-export-server/src/csv/kbart_oclc.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ impl TryFrom<Work> for KbartOclcRow {
153153
num_last_issue_online: None,
154154
title_url: work.landing_page.unwrap(),
155155
first_author,
156-
title_id: work.doi.map(|d| d.to_string()).or_else(|| Some(work.work_id.to_string())),
156+
title_id: work
157+
.doi
158+
.map(|d| d.to_string())
159+
.or_else(|| Some(work.work_id.to_string())),
157160
embargo_info: None,
158161
coverage_depth: "fulltext".to_string(),
159162
notes: None,
@@ -482,9 +485,9 @@ mod tests {
482485
KbartOclc.generate(&[test_work.clone()], QuoteStyle::Necessary, DELIMITER_TAB);
483486
assert_eq!(to_test, Ok(test_result.to_string()));
484487

485-
// Remove DOI: no title_id
488+
// Remove DOI: title_id falls back to work_id
486489
test_work.doi = None;
487-
test_result.title_id = "".to_string();
490+
test_result.title_id = "00000000-0000-0000-aaaa-000000000001".to_string();
488491
// Remove paperback publication: date_monograph_published_print (for hardback)
489492
// still appears, but no print_identifier (paperback ISBN) is present
490493
test_work.publications.remove(2);
@@ -541,5 +544,18 @@ mod tests {
541544
"Missing Publication Date".to_string(),
542545
))
543546
);
547+
548+
// Reinstate publication date but remove license: ditto
549+
test_work.publication_date = chrono::NaiveDate::from_ymd_opt(1999, 12, 31);
550+
test_work.license = None;
551+
let to_test =
552+
KbartOclc.generate(&[test_work.clone()], QuoteStyle::Necessary, DELIMITER_TAB);
553+
assert_eq!(
554+
to_test,
555+
Err(ThothError::IncompleteMetadataRecord(
556+
KBART_ERROR.to_string(),
557+
"Missing License".to_string(),
558+
))
559+
);
544560
}
545561
}

0 commit comments

Comments
 (0)