Commit 500ed199 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Deterministic Phylo tests

parent 14284bc3
Pipeline #5815 failed with stages
......@@ -10,7 +10,7 @@
"_csv_limit": 150000,
"tag": "Csv"
},
"corpusPath": "/Users/adinapoli/work/clients/CNRS/haskell-gargantext/adinapoli-wip2/./test-data/phylo/GarganText_DocsList-nodeId-187481.csv",
"corpusPath": "test-data/phylo/GarganText_DocsList-nodeId-187481.csv",
"defaultMode": false,
"exportFilter": [
{
......@@ -35,7 +35,7 @@
},
"findAncestors": true,
"listParser": "V3",
"listPath": "/Users/adinapoli/work/clients/CNRS/haskell-gargantext/adinapoli-wip2/./test-data/phylo/GarganText_NgramsList-187482.csv",
"listPath": "test-data/phylo/GarganText_NgramsList-187482.csv",
"outputPath": "data/",
"phyloName": "Phylo Name",
"phyloQuality": {
......@@ -1640,4 +1640,4 @@
"style": "filled"
},
"pd_listId": 187482
}
\ No newline at end of file
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -56,15 +56,15 @@ phyloConfig = PhyloConfig {
, exportFilter = [ByBranchSize {_branch_size = 3.0}]
}
tests :: HasCallStack => TestTree
tests :: TestTree
tests = testGroup "Phylo" [
testGroup "Export" [
testCase "ngramsToLabel respects encoding" test_ngramsToLabel_01
, testCase "ngramsToLabel is rendered correctly in CustomAttribute" test_ngramsToLabel_02
]
, testGroup "toPhyloWithoutLink" [
testProperty "returns expected data" testSmallPhyloWithoutLinkExpectedOutput
, testProperty "phyloCleopatre returns expected data" testCleopatreWithoutLinkExpectedOutput
testCase "returns expected data" testSmallPhyloWithoutLinkExpectedOutput
, testCase "phyloCleopatre returns expected data" testCleopatreWithoutLinkExpectedOutput
]
, testGroup "phylo2dot2json" [
testCase "is deterministic" testPhylo2dot2json
......@@ -78,28 +78,31 @@ tests = testGroup "Phylo" [
]
]
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)
testCleopatreWithoutLinkExpectedOutput :: Assertion
testCleopatreWithoutLinkExpectedOutput = do
let actual = toPhyloWithoutLink Cleopatre.docs Cleopatre.config
expected <- readPhylo =<< getDataFileName "test-data/phylo/cleopatre.golden.json"
assertBool (show $ ansiWlEditExpr $ ediff' expected actual) (expected == actual)
testSmallPhyloWithoutLinkExpectedOutput :: Property
testSmallPhyloWithoutLinkExpectedOutput = monadicIO $ do
bpaConfig <- run $ getDataFileName "bench-data/phylo/bpa-config.json"
corpusPath' <- run $ getDataFileName "test-data/phylo/small_phylo_docslist.csv"
listPath' <- run $ getDataFileName "test-data/phylo/small_phylo_ngramslist.csv"
testSmallPhyloWithoutLinkExpectedOutput :: Assertion
testSmallPhyloWithoutLinkExpectedOutput = do
bpaConfig <- getDataFileName "bench-data/phylo/bpa-config.json"
corpusPath' <- getDataFileName "test-data/phylo/small_phylo_docslist.csv"
listPath' <- getDataFileName "test-data/phylo/small_phylo_ngramslist.csv"
(Right config) <- fmap (\pcfg -> pcfg { corpusPath = corpusPath'
, listPath = listPath'
}) <$> (run $ eitherDecodeFileStrict' bpaConfig)
mapList <- run $ fileToList (listParser config) (listPath config)
corpus <- run $ fileToDocsDefault (corpusParser config)
(corpusPath config)
[Year 3 1 5,Month 3 1 5,Week 4 2 5]
mapList
actual <- pure $ toPhyloWithoutLink corpus config
expected <- run $ readPhylo =<< getDataFileName "test-data/phylo/small-phylo.golden.json"
pure $ counterexample (show $ ansiWlEditExpr $ ediff' expected actual) (expected === actual)
}) <$> (eitherDecodeFileStrict' bpaConfig)
mapList <- fileToList (listParser config) (listPath config)
corpus <- fileToDocsDefault (corpusParser config)
(corpusPath config)
[Year 3 1 5,Month 3 1 5,Week 4 2 5]
mapList
actual <- phylo2dot2json (toPhyloWithoutLink corpus config)
expected_e <- JSON.eitherDecodeFileStrict' =<< getDataFileName "test-data/phylo/small-phylo.golden.json"
case expected_e of
Left err -> fail err
Right (expected :: JSON.Value) -> do
assertBool (show $ ansiWlEditExpr $ ediff' expected actual) (expected == actual)
testPhylo2dot2json :: Assertion
testPhylo2dot2json = do
......
......@@ -29,7 +29,7 @@ import qualified Test.Core.Similarity as Similarity
import Test.Tasty
import Test.Tasty.Hspec
main :: HasCallStack => IO ()
main :: IO ()
main = do
utilSpec <- testSpec "Utils" Utils.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