summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-22 01:35:29 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-22 01:35:29 +0800
commitaa4dba4f70749b459c3922ce68610c4d78e644e6 (patch)
treeb4bd720a1946802da343aac02532b55e71de5762 /tests
parent3cc0b4dcfeed042e5a69628c6b7f45580ad1e2f9 (diff)
downloadfund-lab-aa4dba4f70749b459c3922ce68610c4d78e644e6.tar.gz
Fix bond quote probe to use live convertible-bond spot data (3d-15)
Diffstat (limited to 'tests')
-rw-r--r--tests/FundLab.Api.Tests/BondQuoteProbeTests.fs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs b/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs
index a94bf58..442ed7c 100644
--- a/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs
+++ b/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs
@@ -70,6 +70,33 @@ type BondQuoteProbeTests(fixture: PostgresFixture) =
| Error failure -> failwithf "expected a bond quote, got %A" failure
[<Fact>]
+ member _.``probe parses a spot-shaped payload where maturity is unknown``() =
+ let json = BondQuoteProbeSupport.payload "110075" (Some "南航转债") (Some "106.368") None
+
+ let probe =
+ AkshareBondQuoteProbe(BondQuoteProbeSupport.collectorReturning (fun () -> Ok json)) :> IBondQuoteProbe
+
+ match probe.GetQuote("110075", CancellationToken.None) with
+ | Ok quote ->
+ Assert.Equal("110075", quote.Code)
+ Assert.Equal<string option>(Some "南航转债", quote.Name)
+ Assert.Equal<decimal option>(Some 106.368m, quote.Price)
+ Assert.Equal<DateOnly option>(None, quote.MaturityDate)
+ | Error failure -> failwithf "expected a bond quote, got %A" failure
+
+ [<Fact>]
+ member _.``probe surfaces a no valid quote collector failure``() =
+ let probe =
+ AkshareBondQuoteProbe(
+ BondQuoteProbeSupport.collectorReturning (fun () -> Error "AKShare collector failed: no valid quote for 999999")
+ )
+ :> IBondQuoteProbe
+
+ match probe.GetQuote("999999", CancellationToken.None) with
+ | Error(MarketDataCollectorUnavailable message) -> Assert.Contains("no valid quote for 999999", message)
+ | other -> failwithf "expected MarketDataCollectorUnavailable, got %A" other
+
+ [<Fact>]
member _.``probe rejects a malformed bond code without touching the collector``() =
let probe =
AkshareBondQuoteProbe(BondQuoteProbeSupport.collectorReturning (fun () -> failwith "collector should not be called"))