Skip to content

Commit ee85f94

Browse files
committed
test: fix tests structures
1 parent 62687e8 commit ee85f94

2 files changed

Lines changed: 32 additions & 15 deletions

File tree

thoth-export-server/src/bibtex/bibtex_thoth.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ impl TryFrom<Work> for BibtexThothEntry {
124124
contributions.sort_by(|a, b| a.contribution_ordinal.cmp(&b.contribution_ordinal));
125125
let (author, editor) = extract_authors_and_editors(contributions)?;
126126

127-
let shorttitle = Some(work.titles[0].title.clone());
127+
let shorttitle = work.titles[0]
128+
.subtitle
129+
.as_ref()
130+
.map(|_| work.titles[0].title.clone());
128131
let (entry_type, booktitle, chapter, pages) = match work.work_type {
129132
WorkType::BOOK_CHAPTER => {
130133
let (booktitle, chapter, pages) = work

thoth-export-server/src/json/json_thoth.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,6 @@ mod tests {
391391
relation_ordinal: 1,
392392
related_work: WorkRelationsRelatedWork {
393393
work_status: WorkStatus::ACTIVE,
394-
titles: vec![thoth_client::WorkRelationsRelatedWorkTitles {
395-
title_id: Uuid::from_str("00000000-0000-0000-CCCC-000000000001").unwrap(),
396-
locale_code: thoth_client::LocaleCode::EN,
397-
full_title: "Related work title".to_string(),
398-
title: "N/A".to_string(),
399-
subtitle: None,
400-
canonical: true,
401-
}],
402394
edition: None,
403395
doi: None,
404396
publication_date: None,
@@ -414,6 +406,14 @@ mod tests {
414406
page_count: None,
415407
page_interval: None,
416408
landing_page: None,
409+
titles: vec![thoth_client::WorkRelationsRelatedWorkTitles {
410+
title_id: Uuid::from_str("00000000-0000-0000-CCCC-000000000001").unwrap(),
411+
locale_code: thoth_client::LocaleCode::EN,
412+
full_title: "Related work title".to_string(),
413+
title: "N/A".to_string(),
414+
subtitle: None,
415+
canonical: true,
416+
}],
417417
imprint: WorkRelationsRelatedWorkImprint {
418418
crossmark_doi: None,
419419
publisher: WorkRelationsRelatedWorkImprintPublisher {
@@ -455,9 +455,6 @@ mod tests {
455455
const TEST_RESULT: &str = r#"
456456
"workId": "00000000-0000-0000-aaaa-000000000001",
457457
"workStatus": "ACTIVE",
458-
"fullTitle": "Book Title: Book Subtitle",
459-
"title": "Book Title",
460-
"subtitle": "Book Subtitle",
461458
"workType": "MONOGRAPH",
462459
"reference": null,
463460
"edition": 1,
@@ -486,6 +483,16 @@ mod tests {
486483
"oclc": "987654321",
487484
"coverUrl": "https://www.book.com/cover",
488485
"coverCaption": "This is a cover caption",
486+
"titles": [
487+
{
488+
"titleId": "00000000-0000-0000-cccc-000000000001",
489+
"localeCode": "EN",
490+
"fullTitle": "Book Title: Book Subtitle",
491+
"title": "Book Title",
492+
"subtitle": "Book Subtitle",
493+
"canonical": true
494+
}
495+
],
489496
"imprint": {
490497
"imprintName": "OA Editions Imprint",
491498
"imprintUrl": null,
@@ -771,9 +778,6 @@ mod tests {
771778
"relationType": "HAS_CHILD",
772779
"relationOrdinal": 1,
773780
"relatedWork": {
774-
"fullTitle": "Related work title",
775-
"title": "N/A",
776-
"subtitle": null,
777781
"edition": null,
778782
"doi": null,
779783
"publicationDate": null,
@@ -790,6 +794,16 @@ mod tests {
790794
"pageCount": null,
791795
"pageInterval": null,
792796
"landingPage": null,
797+
"titles": [
798+
{
799+
"titleId": "00000000-0000-0000-cccc-000000000001",
800+
"localeCode": "EN",
801+
"fullTitle": "Related work title",
802+
"title": "N/A",
803+
"subtitle": null,
804+
"canonical": true
805+
}
806+
],
793807
"imprint": {
794808
"crossmarkDoi": null,
795809
"publisher": {

0 commit comments

Comments
 (0)