From e07b0ef1a6320c1160c1f8930247ec27b04915ab Mon Sep 17 00:00:00 2001 From: Heinrich Lukas Weil Date: Tue, 10 Oct 2023 13:58:31 +0200 Subject: [PATCH] investigation xlsx writer now only considers registered studies --- src/ISA/ISA.Spreadsheet/ArcInvestigation.fs | 2 +- tests/ISA/ISA.Json.Tests/Json.Tests.fs | 14 ++++++++++++++ .../InvestigationFileTests.fs | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/ISA/ISA.Spreadsheet/ArcInvestigation.fs b/src/ISA/ISA.Spreadsheet/ArcInvestigation.fs index f6427fb9..492abf11 100644 --- a/src/ISA/ISA.Spreadsheet/ArcInvestigation.fs +++ b/src/ISA/ISA.Spreadsheet/ArcInvestigation.fs @@ -194,7 +194,7 @@ module ArcInvestigation = yield SparseRow.fromValues [contactsLabel] yield! Contacts.toRows (Some contactsLabelPrefix) (List.ofArray investigation.Contacts) - for study in (List.ofSeq investigation.Studies) do + for study in investigation.RegisteredStudies do yield SparseRow.fromValues [studyLabel] yield! Studies.toRows study None } diff --git a/tests/ISA/ISA.Json.Tests/Json.Tests.fs b/tests/ISA/ISA.Json.Tests/Json.Tests.fs index 9fc163e6..64bdaee8 100644 --- a/tests/ISA/ISA.Json.Tests/Json.Tests.fs +++ b/tests/ISA/ISA.Json.Tests/Json.Tests.fs @@ -1266,6 +1266,20 @@ let testInvestigationFile = Expect.equal i.Remarks List.empty "Remark list should be an empty list." ) + testCase "OnlyConsiderRegisteredStudies" (fun () -> + let isa = ArcInvestigation("MyInvestigation") + let registeredStudyIdentifier = "RegisteredStudy" + let registeredStudy = ArcStudy(registeredStudyIdentifier) + let unregisteredStudyIdentifier = "UnregisteredStudy" + let unregisteredStudy = ArcStudy(unregisteredStudyIdentifier) + + isa.AddStudy(unregisteredStudy) + isa.AddRegisteredStudy(registeredStudy) + + let result = ArcInvestigation.toJsonString isa |> ArcInvestigation.fromJsonString + + Expect.sequenceEqual result.RegisteredStudyIdentifiers [registeredStudyIdentifier] "Only the registered study should be written and read" + ) testCase "FullInvestigation" (fun () -> let comment = diff --git a/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs index 176cb5cf..ae918ee3 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs @@ -47,6 +47,20 @@ let private testInvestigationWriterComponents = wb.AddWorksheet(sheet) Expect.isSome (wb.TryGetWorksheetByName "Investigation") "Worksheet should be added to workbook" ) + testCase "OnlyConsiderRegisteredStudies" (fun () -> + let isa = ArcInvestigation("MyInvestigation") + let registeredStudyIdentifier = "RegisteredStudy" + let registeredStudy = ArcStudy(registeredStudyIdentifier) + let unregisteredStudyIdentifier = "UnregisteredStudy" + let unregisteredStudy = ArcStudy(unregisteredStudyIdentifier) + + isa.AddStudy(unregisteredStudy) + isa.AddRegisteredStudy(registeredStudy) + + let result = ArcInvestigation.toFsWorkbook isa |> ArcInvestigation.fromFsWorkbook + + Expect.sequenceEqual result.RegisteredStudyIdentifiers [registeredStudyIdentifier] "Only the registered study should be written and read" + )