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 @@ ...@@ -10,7 +10,7 @@
"_csv_limit": 150000, "_csv_limit": 150000,
"tag": "Csv" "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, "defaultMode": false,
"exportFilter": [ "exportFilter": [
{ {
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
}, },
"findAncestors": true, "findAncestors": true,
"listParser": "V3", "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/", "outputPath": "data/",
"phyloName": "Phylo Name", "phyloName": "Phylo Name",
"phyloQuality": { "phyloQuality": {
...@@ -1640,4 +1640,4 @@ ...@@ -1640,4 +1640,4 @@
"style": "filled" "style": "filled"
}, },
"pd_listId": 187482 "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 { ...@@ -56,15 +56,15 @@ phyloConfig = PhyloConfig {
, exportFilter = [ByBranchSize {_branch_size = 3.0}] , exportFilter = [ByBranchSize {_branch_size = 3.0}]
} }
tests :: HasCallStack => TestTree tests :: 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 testCase "returns expected data" testSmallPhyloWithoutLinkExpectedOutput
, testProperty "phyloCleopatre returns expected data" testCleopatreWithoutLinkExpectedOutput , testCase "phyloCleopatre returns expected data" testCleopatreWithoutLinkExpectedOutput
] ]
, testGroup "phylo2dot2json" [ , testGroup "phylo2dot2json" [
testCase "is deterministic" testPhylo2dot2json testCase "is deterministic" testPhylo2dot2json
...@@ -78,28 +78,31 @@ tests = testGroup "Phylo" [ ...@@ -78,28 +78,31 @@ tests = testGroup "Phylo" [
] ]
] ]
testCleopatreWithoutLinkExpectedOutput :: HasCallStack => Property testCleopatreWithoutLinkExpectedOutput :: Assertion
testCleopatreWithoutLinkExpectedOutput = monadicIO $ do testCleopatreWithoutLinkExpectedOutput = do
actual <- pure $ toPhyloWithoutLink Cleopatre.docs Cleopatre.config let actual = toPhyloWithoutLink Cleopatre.docs Cleopatre.config
expected <- run $ readPhylo =<< getDataFileName "test-data/phylo/cleopatre.golden.json" expected <- readPhylo =<< getDataFileName "test-data/phylo/cleopatre.golden.json"
pure $ counterexample (show $ ansiWlEditExpr $ ediff' expected actual) (expected === actual) assertBool (show $ ansiWlEditExpr $ ediff' expected actual) (expected == actual)
testSmallPhyloWithoutLinkExpectedOutput :: Property testSmallPhyloWithoutLinkExpectedOutput :: Assertion
testSmallPhyloWithoutLinkExpectedOutput = monadicIO $ do testSmallPhyloWithoutLinkExpectedOutput = do
bpaConfig <- run $ getDataFileName "bench-data/phylo/bpa-config.json" bpaConfig <- getDataFileName "bench-data/phylo/bpa-config.json"
corpusPath' <- run $ getDataFileName "test-data/phylo/small_phylo_docslist.csv" corpusPath' <- getDataFileName "test-data/phylo/small_phylo_docslist.csv"
listPath' <- run $ getDataFileName "test-data/phylo/small_phylo_ngramslist.csv" listPath' <- getDataFileName "test-data/phylo/small_phylo_ngramslist.csv"
(Right config) <- fmap (\pcfg -> pcfg { corpusPath = corpusPath' (Right config) <- fmap (\pcfg -> pcfg { corpusPath = corpusPath'
, listPath = listPath' , listPath = listPath'
}) <$> (run $ eitherDecodeFileStrict' bpaConfig) }) <$> (eitherDecodeFileStrict' bpaConfig)
mapList <- run $ fileToList (listParser config) (listPath config) mapList <- fileToList (listParser config) (listPath config)
corpus <- run $ fileToDocsDefault (corpusParser config) corpus <- fileToDocsDefault (corpusParser config)
(corpusPath config) (corpusPath config)
[Year 3 1 5,Month 3 1 5,Week 4 2 5] [Year 3 1 5,Month 3 1 5,Week 4 2 5]
mapList mapList
actual <- pure $ toPhyloWithoutLink corpus config actual <- phylo2dot2json (toPhyloWithoutLink corpus config)
expected <- run $ readPhylo =<< getDataFileName "test-data/phylo/small-phylo.golden.json" expected_e <- JSON.eitherDecodeFileStrict' =<< getDataFileName "test-data/phylo/small-phylo.golden.json"
pure $ counterexample (show $ ansiWlEditExpr $ ediff' expected actual) (expected === actual) case expected_e of
Left err -> fail err
Right (expected :: JSON.Value) -> do
assertBool (show $ ansiWlEditExpr $ ediff' expected actual) (expected == actual)
testPhylo2dot2json :: Assertion testPhylo2dot2json :: Assertion
testPhylo2dot2json = do testPhylo2dot2json = do
......
...@@ -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 :: HasCallStack => IO () main :: 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