Skip to content

Whitespace tests for Terms and TypeDefs #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OBO.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{13CB
global.json = global.json
LICENSE = LICENSE
playground.fsx = playground.fsx
playgroundInput.fsx = playgroundInput.fsx
README.md = README.md
RELEASE_NOTES.md = RELEASE_NOTES.md
EndProjectSection
Expand Down
9 changes: 8 additions & 1 deletion build/TestTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ open Fake.DotNet
open ProjectInfo
open BasicTasks


let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()

let runTests = BuildTask.create "RunTests" [clean; build] {
testProjects
|> Seq.iter (fun testProject ->
Expand All @@ -15,14 +18,17 @@ let runTests = BuildTask.create "RunTests" [clean; build] {
Logger = Some "console;verbosity=detailed"
Configuration = DotNet.BuildConfiguration.fromString configuration
NoBuild = true
MSBuildParams = {
standardParams with
DisableInternalBinLog = true
}
}
) testProject
)
}

// to do: use this once we have actual tests
let runTestsWithCodeCov = BuildTask.create "RunTestsWithCodeCov" [clean; build] {
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
testProjects
|> Seq.iter(fun testProject ->
Fake.DotNet.DotNet.test(fun testParams ->
Expand All @@ -35,6 +41,7 @@ let runTestsWithCodeCov = BuildTask.create "RunTestsWithCodeCov" [clean; build]
"AltCoverCobertura","../../codeCov.xml"
"AltCoverForce","true"
]
DisableInternalBinLog = true
};
Logger = Some "console;verbosity=detailed"
}
Expand Down
21 changes: 21 additions & 0 deletions playgroundInput.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#I "src/OBO.NET/bin/Debug/netstandard2.0"
#I "src/OBO.NET/bin/Release/netstandard2.0"
#I "src/OBO.NET.CodeGeneration/bin/Debug/netstandard2.0"
#I "src/OBO.NET.CodeGeneration/bin/Release/netstandard2.0"

#r "OBO.NET.dll"
//#r "OBO.NET.CodeGeneration.dll"

#r "nuget: ARCtrl.Core"
#r "nuget: FSharpAux"

open OBO.NET
open OBO.NET.DBXref
open ARCtrl
open FSharpAux
//open OBO.NET.CodeGeneration


let res = OboOntology.fromFile true @"C:\Repos\CSBiology\OBO.NET\tests\OBO.NET.Tests\References\WhitespaceAfterTerm.obo"

let res2 = OboOntology.fromFile true @"C:\Repos\CSBiology\OBO.NET\tests\OBO.NET.Tests\References\WhitespaceAfterTypeDef.obo"
2 changes: 2 additions & 0 deletions tests/OBO.NET.Tests/OBO.NET.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
</PropertyGroup>

<ItemGroup>
<None Include="References\WhitespaceAfterTypeDef.obo" />
<None Include="References\WhitespaceAfterTerm.obo" />
<None Include="References\IncorrectHeaderTags.obo" />
<None Include="References\DuplicateHeaderTags.obo" />
<None Include="references\CorrectHeaderTags.obo" />
Expand Down
10 changes: 10 additions & 0 deletions tests/OBO.NET.Tests/OboOntology.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ module OboOntologyTests =
let testFile1Path = Path.Combine(__SOURCE_DIRECTORY__, "References", "CorrectHeaderTags.obo")
let testFile2Path = Path.Combine(__SOURCE_DIRECTORY__, "References", "IncorrectHeaderTags.obo")
let testFile3Path = Path.Combine(__SOURCE_DIRECTORY__, "References", "DuplicateHeaderTags.obo")
let testFile4Path = Path.Combine(__SOURCE_DIRECTORY__, "References", "WhitespaceAfterTerm.obo")
let testFile5Path = Path.Combine(__SOURCE_DIRECTORY__, "References", "WhitespaceAfterTypeDef.obo")
let testFile1 = try OboOntology.fromFile false testFile1Path |> Some with _ -> None
let testFile2 = try OboOntology.fromFile false testFile2Path |> Some with _ -> None
let testFile3 = try OboOntology.fromFile false testFile3Path |> Some with _ -> None
let testFile4 = try OboOntology.fromFile false testFile4Path |> Some with _ -> None
let testFile5 = try OboOntology.fromFile false testFile5Path |> Some with _ -> None

testList "fromFile" [
testCase "can read files" <| fun _ ->
Expect.isSome testFile1 $"Could not read testFile1: {testFile1Path}"
Expect.isSome testFile2 $"Could not read testFile2: {testFile2Path}"
Expect.isSome testFile3 $"Could not read testFile3: {testFile3Path}"
Expect.isSome testFile4 $"Could not read testFile4: {testFile4Path}"
Expect.isSome testFile5 $"Could not read testFile5: {testFile5Path}"
testCase "reads correct headers correctly" <| fun _ ->
let formatVersionActual = Option.map (fun o -> o.FormatVersion) testFile1
let dataVersionActual = Option.map (fun o -> o.DataVersion) testFile1 |> Option.flatten
Expand Down Expand Up @@ -129,6 +135,10 @@ module OboOntologyTests =
testCase "reads Typedefs correctly" <| fun _ ->
let typedefsExpected = List.init 2 (fun i -> OboTypeDef.Create($"Test:000{i + 3}", "", "")) |> Some
Expect.equal (Option.map (fun o -> o.TypeDefs) testFile1) typedefsExpected "Terms did not match"
testCase "reads Terms with whitespace correctly" <| fun _ ->
Expect.equal testFile4.Value.Terms.Length 4 "Number of terms did not match"
testCase "reads TypeDefs with whitespace correctly" <| fun _ ->
Expect.equal testFile5.Value.TypeDefs.Length 4 "Number of typedefs did not match"
]

let testOntology = OboOntology.Create([testTerm1; testTerm2; testTerm3; testTerm4; testTerm5], [], "", TreatXrefsAsEquivalents = ["check"])
Expand Down
43 changes: 43 additions & 0 deletions tests/OBO.NET.Tests/References/WhitespaceAfterTerm.obo
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
format-version: 0.0.1
data-version: 0.0.1
ontology: CL
date: 01:01:1970 00:00
saved-by: Oliver Maus
auto-generated-by: TalkGPT
subsetdef: GO_SLIM "GO Slim"
subsetdef: GO_BASIC "GO Basic"
import: http://purl.obolibrary.org/obo/go.owl
import: http://purl.obolibrary.org/obo/cl.owl
synonymtypedef: UK_SPELLING "British spelling" EXACT
synonymtypedef: US_SPELLING "American spelling" EXACT
idspace: GO urn:lsid:bioontology.org:GO: "gene ontology terms"
idspace: GO urn:lsid:bioontology.org:GO: "gene ontology types"
default-relationship-id-prefix: OBO_REL
id-mapping: part_of OBO_REL:part_of
id-mapping: has_a OBO_REL:has_a
remark: test1
remark: test2
treat-xrefs-as-equivalent: CL
treat-xrefs-as-equivalent: GO
treat-xrefs-as-genus-differentia: CL part_of NCBITaxon:7955
treat-xrefs-as-genus-differentia: CL part_of NCBITaxon:7956
treat-xrefs-as-relationship: MA homologous_to
treat-xrefs-as-relationship: MA analogous_to
treat-xrefs-as-is_a: CL
treat-xrefs-as-is_a: GO
relax-unique-identifier-assumption-for-namespace: my_combined_ontology
relax-unique-identifier-assumption-for-namespace: my_combined_ontology2
relax-unique-label-assumption-for-namespace: my_combined_ontology
relax-unique-label-assumption-for-namespace: my_combined_ontology2

[Term]
id: Test:0001

[Term]
id: Test:0002

[Term]
id: Test:0003

[Term]
id: Test:0004
43 changes: 43 additions & 0 deletions tests/OBO.NET.Tests/References/WhitespaceAfterTypeDef.obo
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
format-version: 0.0.1
data-version: 0.0.1
ontology: CL
date: 01:01:1970 00:00
saved-by: Oliver Maus
auto-generated-by: TalkGPT
subsetdef: GO_SLIM "GO Slim"
subsetdef: GO_BASIC "GO Basic"
import: http://purl.obolibrary.org/obo/go.owl
import: http://purl.obolibrary.org/obo/cl.owl
synonymtypedef: UK_SPELLING "British spelling" EXACT
synonymtypedef: US_SPELLING "American spelling" EXACT
idspace: GO urn:lsid:bioontology.org:GO: "gene ontology terms"
idspace: GO urn:lsid:bioontology.org:GO: "gene ontology types"
default-relationship-id-prefix: OBO_REL
id-mapping: part_of OBO_REL:part_of
id-mapping: has_a OBO_REL:has_a
remark: test1
remark: test2
treat-xrefs-as-equivalent: CL
treat-xrefs-as-equivalent: GO
treat-xrefs-as-genus-differentia: CL part_of NCBITaxon:7955
treat-xrefs-as-genus-differentia: CL part_of NCBITaxon:7956
treat-xrefs-as-relationship: MA homologous_to
treat-xrefs-as-relationship: MA analogous_to
treat-xrefs-as-is_a: CL
treat-xrefs-as-is_a: GO
relax-unique-identifier-assumption-for-namespace: my_combined_ontology
relax-unique-identifier-assumption-for-namespace: my_combined_ontology2
relax-unique-label-assumption-for-namespace: my_combined_ontology
relax-unique-label-assumption-for-namespace: my_combined_ontology2

[Typedef]
id: Test:0001

[Typedef]
id: Test:0002

[Typedef]
id: Test:0003

[Typedef]
id: Test:0004
Loading