Commit ad332461 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Improve a bit phylo tests

parent bb43a634
...@@ -36,8 +36,9 @@ data-files: ...@@ -36,8 +36,9 @@ data-files:
test-data/ngrams/simple.json test-data/ngrams/simple.json
test-data/ngrams/simple.csv test-data/ngrams/simple.csv
test-data/phylo/bpa_phylo_test.json test-data/phylo/bpa_phylo_test.json
test-data/phylo/open_science.json test-data/phylo/cleopatre.golden.json
test-data/phylo/issue-290-small.golden.json test-data/phylo/issue-290-small.golden.json
test-data/phylo/open_science.json
test-data/phylo/small-phylo.golden.json test-data/phylo/small-phylo.golden.json
test-data/phylo/small_phylo_docslist.csv test-data/phylo/small_phylo_docslist.csv
test-data/phylo/small_phylo_ngramslist.csv test-data/phylo/small_phylo_ngramslist.csv
...@@ -188,6 +189,7 @@ library ...@@ -188,6 +189,7 @@ library
Gargantext.Core.Viz.Phylo Gargantext.Core.Viz.Phylo
Gargantext.Core.Viz.Phylo.API Gargantext.Core.Viz.Phylo.API
Gargantext.Core.Viz.Phylo.API.Tools Gargantext.Core.Viz.Phylo.API.Tools
Gargantext.Core.Viz.Phylo.Example
Gargantext.Core.Viz.Phylo.PhyloExport Gargantext.Core.Viz.Phylo.PhyloExport
Gargantext.Core.Viz.Phylo.PhyloMaker Gargantext.Core.Viz.Phylo.PhyloMaker
Gargantext.Core.Viz.Phylo.PhyloTools Gargantext.Core.Viz.Phylo.PhyloTools
...@@ -353,7 +355,6 @@ library ...@@ -353,7 +355,6 @@ library
Gargantext.Core.Viz.Graph.Tools.Infomap Gargantext.Core.Viz.Graph.Tools.Infomap
Gargantext.Core.Viz.Graph.Utils Gargantext.Core.Viz.Graph.Utils
Gargantext.Core.Viz.LegacyPhylo Gargantext.Core.Viz.LegacyPhylo
Gargantext.Core.Viz.Phylo.Example
Gargantext.Core.Viz.Phylo.Legacy.LegacyMain Gargantext.Core.Viz.Phylo.Legacy.LegacyMain
Gargantext.Core.Viz.Phylo.TemporalMatching Gargantext.Core.Viz.Phylo.TemporalMatching
Gargantext.Data.HashMap.Strict.Utils Gargantext.Data.HashMap.Strict.Utils
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -13,6 +13,7 @@ import Data.TreeDiff ...@@ -13,6 +13,7 @@ import Data.TreeDiff
import Data.Vector qualified as V import Data.Vector qualified as V
import Gargantext.Core.Viz.Phylo import Gargantext.Core.Viz.Phylo
import Gargantext.Core.Viz.Phylo.API.Tools (readPhylo, writePhylo) import Gargantext.Core.Viz.Phylo.API.Tools (readPhylo, writePhylo)
import Gargantext.Core.Viz.Phylo.Example qualified as Cleopatre
import Gargantext.Core.Viz.Phylo.PhyloExport import Gargantext.Core.Viz.Phylo.PhyloExport
import Gargantext.Core.Viz.Phylo.PhyloMaker (toPhylo, toPhyloWithoutLink) import Gargantext.Core.Viz.Phylo.PhyloMaker (toPhylo, toPhyloWithoutLink)
import Gargantext.Core.Viz.Phylo.PhyloTools import Gargantext.Core.Viz.Phylo.PhyloTools
...@@ -48,23 +49,30 @@ phyloConfig = PhyloConfig { ...@@ -48,23 +49,30 @@ phyloConfig = PhyloConfig {
, exportFilter = [ByBranchSize {_branch_size = 3.0}] , exportFilter = [ByBranchSize {_branch_size = 3.0}]
} }
tests :: TestTree tests :: HasCallStack => TestTree
tests = testGroup "Phylo" [ tests = testGroup "Phylo" [
testGroup "Export" [ testGroup "Export" [
testCase "ngramsToLabel respects encoding" test_ngramsToLabel_01 testCase "ngramsToLabel respects encoding" test_ngramsToLabel_01
, testCase "ngramsToLabel is rendered correctly in CustomAttribute" test_ngramsToLabel_02 , testCase "ngramsToLabel is rendered correctly in CustomAttribute" test_ngramsToLabel_02
] ]
, testGroup "toPhyloWithoutLink" [ , testGroup "toPhyloWithoutLink" [
testProperty "returns expected data" testSmallPhyloWithoutLinkExpectedOutput testProperty "returns expected data" testSmallPhyloWithoutLinkExpectedOutput
] , testProperty "phyloCleopatre returns expected data" testCleopatreWithoutLinkExpectedOutput
]
, testGroup "toPhylo" [ , testGroup "toPhylo" [
testProperty "returns expected data" testSmallPhyloExpectedOutput --testProperty "returns expected data" testSmallPhyloExpectedOutput
] ]
, testGroup "relatedComponents" [ , testGroup "relatedComponents" [
testCase "finds simple connection" testRelComp_Connected testCase "finds simple connection" testRelComp_Connected
] ]
] ]
testCleopatreWithoutLinkExpectedOutput :: HasCallStack => Property
testCleopatreWithoutLinkExpectedOutput = monadicIO $ do
actual <- pure $ toPhyloWithoutLink Cleopatre.docs Cleopatre.config
expected <- run $ readPhylo =<< getDataFileName "test-data/phylo/cleopatre.golden.json"
pure $ counterexample (show $ ansiWlEditExpr $ ediff' expected actual) (expected === actual)
testSmallPhyloWithoutLinkExpectedOutput :: Property testSmallPhyloWithoutLinkExpectedOutput :: Property
testSmallPhyloWithoutLinkExpectedOutput = monadicIO $ do testSmallPhyloWithoutLinkExpectedOutput = monadicIO $ do
bpaConfig <- run $ getDataFileName "bench-data/phylo/bpa-config.json" bpaConfig <- run $ getDataFileName "bench-data/phylo/bpa-config.json"
...@@ -85,8 +93,8 @@ testSmallPhyloWithoutLinkExpectedOutput = monadicIO $ do ...@@ -85,8 +93,8 @@ testSmallPhyloWithoutLinkExpectedOutput = monadicIO $ do
testSmallPhyloExpectedOutput :: Property testSmallPhyloExpectedOutput :: Property
testSmallPhyloExpectedOutput = monadicIO $ do testSmallPhyloExpectedOutput = monadicIO $ do
issue290PhyloSmall <- run $ setConfig phyloConfig <$> (readPhylo =<< getDataFileName "bench-data/phylo/issue-290-small.json") issue290PhyloSmall <- run $ setConfig phyloConfig <$> (readPhylo =<< getDataFileName "bench-data/phylo/issue-290-small.json")
expected <- run $ readPhylo =<< getDataFileName "test-data/phylo/issue-290-small.golden.json"
let actual = toPhylo issue290PhyloSmall let actual = toPhylo issue290PhyloSmall
expected <- run $ readPhylo =<< getDataFileName "test-data/phylo/issue-290-small.golden.json"
pure $ counterexample (show $ ansiWlEditExpr $ ediff' expected actual) (expected === actual) pure $ counterexample (show $ ansiWlEditExpr $ ediff' expected actual) (expected === actual)
test_ngramsToLabel_01 :: Assertion test_ngramsToLabel_01 :: Assertion
......
...@@ -29,7 +29,7 @@ import qualified Test.Core.Similarity as Similarity ...@@ -29,7 +29,7 @@ import qualified Test.Core.Similarity as Similarity
import Test.Tasty import Test.Tasty
import Test.Tasty.Hspec import Test.Tasty.Hspec
main :: IO () main :: HasCallStack => IO ()
main = do main = do
utilSpec <- testSpec "Utils" Utils.test utilSpec <- testSpec "Utils" Utils.test
clusteringSpec <- testSpec "Graph Clustering" Graph.test clusteringSpec <- testSpec "Graph Clustering" Graph.test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment