-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Client type extensions and add tests:
- Fix direct package content hash not using "\n" as line endings - Add `AsIndexType()` directly on Author/OntologyAnnotation - Add tests to catch these types of bugs in the future
- Loading branch information
Showing
9 changed files
with
283 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## v0.0.7 | ||
- Further TypeExtension improvements and fixes | ||
|
||
## v0.0.6 | ||
- Fix some missing fields in type extensions | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
module ReferenceObjects | ||
|
||
open Utils | ||
open AVPRIndex | ||
open AVPRClient | ||
|
||
let date = System.DateTime.ParseExact("2021-01-01", "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) | ||
|
||
let testDate = System.DateTimeOffset.Parse("01/01/2024") | ||
|
||
module Author = | ||
|
||
let mandatoryFieldsClient = AVPRClient.Author(FullName = "test") | ||
|
||
let allFieldsClient = | ||
AVPRClient.Author( | ||
FullName = "test", | ||
Email = "[email protected]", | ||
Affiliation = "testaffiliation", | ||
AffiliationLink = "test.com" | ||
) | ||
|
||
let mandatoryFieldsIndex = AVPRIndex.Domain.Author(FullName = "test") | ||
|
||
let allFieldsIndex = | ||
AVPRIndex.Domain.Author( | ||
FullName = "test", | ||
Email = "[email protected]", | ||
Affiliation = "testaffiliation", | ||
AffiliationLink = "test.com" | ||
) | ||
|
||
module OntologyAnnotation = | ||
|
||
let mandatoryFieldsClient = AVPRClient.OntologyAnnotation(Name = "test") | ||
|
||
let allFieldsClient = AVPRClient.OntologyAnnotation( | ||
Name = "test", | ||
TermSourceREF = "REF", | ||
TermAccessionNumber = "TAN" | ||
) | ||
|
||
let mandatoryFieldsIndex = AVPRIndex.Domain.OntologyAnnotation(Name = "test") | ||
|
||
let allFieldsIndex = AVPRIndex.Domain.OntologyAnnotation( | ||
Name = "test", | ||
TermSourceREF = "REF", | ||
TermAccessionNumber = "TAN" | ||
) | ||
|
||
module ValidationPackageMetadata = | ||
|
||
let mandatoryFields = ValidationPackageMetadata( | ||
Name = "name", | ||
Summary = "summary" , | ||
Description = "description" , | ||
MajorVersion = 1, | ||
MinorVersion = 0, | ||
PatchVersion = 0 | ||
) | ||
|
||
let allFields = ValidationPackageMetadata( | ||
Name = "name", | ||
Summary = "summary" , | ||
Description = "description" , | ||
MajorVersion = 1, | ||
MinorVersion = 0, | ||
PatchVersion = 0, | ||
Publish = true, | ||
Authors = [|Author.allFieldsIndex|], | ||
Tags = [|OntologyAnnotation.allFieldsIndex|], | ||
ReleaseNotes = "releasenotes", | ||
CQCHookEndpoint = "hookendpoint" | ||
) | ||
|
||
module PackageContentHash = | ||
open System | ||
open System.IO | ||
open System.Text | ||
open System.Security.Cryptography | ||
|
||
let expected_hash = | ||
let md5 = MD5.Create() | ||
"fixtures/test_validation_package_all_fields.fsx" | ||
|> File.ReadAllText | ||
|> fun s -> s.ReplaceLineEndings("\n") | ||
|> Encoding.UTF8.GetBytes | ||
|> md5.ComputeHash | ||
|> Convert.ToHexString | ||
|
||
let allFields = AVPRClient.PackageContentHash( | ||
PackageName = "name", | ||
PackageMajorVersion = 1, | ||
PackageMinorVersion = 0, | ||
PackagePatchVersion = 0, | ||
Hash = expected_hash | ||
) | ||
|
||
|
||
module ValidationPackage = | ||
|
||
open System.IO | ||
|
||
let expected_content = | ||
|
||
"fixtures/test_validation_package_all_fields.fsx" | ||
|> File.ReadAllBytes | ||
|
||
|
||
let allFields = AVPRClient.ValidationPackage( | ||
Name = "name", | ||
Summary = "summary" , | ||
Description = "description" , | ||
MajorVersion = 1, | ||
MinorVersion = 0, | ||
PatchVersion = 0, | ||
PackageContent = expected_content, | ||
ReleaseDate = date, | ||
Authors = [|Author.allFieldsClient|], | ||
Tags = [|OntologyAnnotation.allFieldsClient|], | ||
ReleaseNotes = "releasenotes", | ||
CQCHookEndpoint = "hookendpoint" | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
namespace TypeExtensionsTests | ||
|
||
open System | ||
open System.IO | ||
open System.Text | ||
open Xunit | ||
open AVPRClient | ||
|
||
open System.Security.Cryptography | ||
|
||
module ValidationPackageIndex = | ||
|
||
let test_validation_package_all_fields = AVPRIndex.Domain.ValidationPackageIndex.create( | ||
repoPath = "fixtures/test_validation_package_all_fields.fsx", | ||
fileName = "test_validation_package_all_fields.fsx", | ||
lastUpdated = ReferenceObjects.date, | ||
contentHash = ReferenceObjects.PackageContentHash.expected_hash, | ||
metadata = ReferenceObjects.ValidationPackageMetadata.allFields | ||
) | ||
|
||
[<Fact>] | ||
let ``toValidationpackage with release date`` () = | ||
let actual = test_validation_package_all_fields.toValidationPackage(ReferenceObjects.date) | ||
Assert.Equivalent(actual, ReferenceObjects.ValidationPackage.allFields) | ||
|
||
[<Fact>] | ||
let ``toPackageContentHash without direct file hash`` () = | ||
let actual = test_validation_package_all_fields.toPackageContentHash() | ||
Assert.Equivalent(ReferenceObjects.PackageContentHash.allFields, actual) | ||
|
||
[<Fact>] | ||
let ``toPackageContentHash with direct file hash`` () = | ||
let actual = test_validation_package_all_fields.toPackageContentHash(HashFileDirectly = true) | ||
Assert.Equivalent(ReferenceObjects.PackageContentHash.allFields, actual) | ||
|
||
module Author = | ||
|
||
open System.Collections | ||
open System.Collections.Generic | ||
|
||
[<Fact>] | ||
let ``AsIndexType with mandatory fields`` () = | ||
let actual = ReferenceObjects.Author.mandatoryFieldsClient.AsIndexType() | ||
Assert.Equivalent(actual, ReferenceObjects.Author.mandatoryFieldsClient) | ||
|
||
[<Fact>] | ||
let ``AsIndexType with all fields`` () = | ||
let actual = ReferenceObjects.Author.allFieldsClient.AsIndexType() | ||
Assert.Equivalent(actual, ReferenceObjects.Author.allFieldsClient) | ||
|
||
[<Fact>] | ||
let ``AsIndexType with mandatory fields on collection`` () = | ||
let actual = [|ReferenceObjects.Author.mandatoryFieldsClient|].AsIndexType() | ||
Assert.Equivalent(actual, [|ReferenceObjects.Author.mandatoryFieldsClient|]) | ||
|
||
[<Fact>] | ||
let ``AsIndexType with all fields on collection`` () = | ||
let actual = [|ReferenceObjects.Author.allFieldsClient|].AsIndexType() | ||
Assert.Equivalent(actual, [|ReferenceObjects.Author.allFieldsClient|]) | ||
|
||
module OntologyAnnotation = | ||
|
||
[<Fact>] | ||
let ``AsIndexType with mandatory fields`` () = | ||
let actual = ReferenceObjects.OntologyAnnotation.mandatoryFieldsClient.AsIndexType() | ||
Assert.Equivalent(actual, ReferenceObjects.OntologyAnnotation.mandatoryFieldsClient) | ||
|
||
[<Fact>] | ||
let ``AsIndexType with all fields`` () = | ||
let actual = ReferenceObjects.OntologyAnnotation.allFieldsClient.AsIndexType() | ||
Assert.Equivalent(actual, ReferenceObjects.OntologyAnnotation.allFieldsClient) | ||
|
||
[<Fact>] | ||
let ``AsIndexType with mandatory fields on collection`` () = | ||
let actual = [|ReferenceObjects.OntologyAnnotation.mandatoryFieldsClient|].AsIndexType() | ||
Assert.Equivalent(actual, [|ReferenceObjects.OntologyAnnotation.mandatoryFieldsClient|]) | ||
|
||
[<Fact>] | ||
let ``AsIndexType with all fields on collection`` () = | ||
let actual = [|ReferenceObjects.OntologyAnnotation.allFieldsClient|].AsIndexType() | ||
Assert.Equivalent(actual, [|ReferenceObjects.OntologyAnnotation.allFieldsClient|]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Utils | ||
|
24 changes: 24 additions & 0 deletions
24
tests/ClientTests/fixtures/test_validation_package_all_fields.fsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(* | ||
--- | ||
Name: name | ||
Summary: summary | ||
Description = description | ||
MajorVersion: 1 | ||
MinorVersion: 0 | ||
PatchVersion: 0 | ||
Publish: true | ||
Authors: | ||
- FullName: test | ||
Email: [email protected] | ||
Affiliation: testaffiliation | ||
AffiliationLink: test.com | ||
Tags: | ||
- Name: test | ||
TermSourceREF: REF | ||
TermAccessionNumber: TAN | ||
ReleaseNotes: releasenotes | ||
CQCHookEndpoint: hookendpoint | ||
--- | ||
*) | ||
|
||
printfn "yes" |