Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
69fa22f7
Commit
69fa22f7
authored
Jun 20, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Phylo golden tests
parent
e1418b58
Pipeline
#4244
failed with stages
in 38 minutes and 18 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7500 additions
and
11 deletions
+7500
-11
gargantext.cabal
gargantext.cabal
+2
-0
package.yaml
package.yaml
+2
-0
JSON.hs
src-test/Offline/JSON.hs
+22
-0
Phylo.hs
src/Gargantext/Core/Types/Phylo.hs
+16
-11
bpa_phylo_test.json
test-data/phylo/bpa_phylo_test.json
+6140
-0
open_science.json
test-data/phylo/open_science.json
+1318
-0
No files found.
gargantext.cabal
View file @
69fa22f7
...
@@ -26,6 +26,8 @@ data-files:
...
@@ -26,6 +26,8 @@ data-files:
ekg-assets/chart_line_add.png
ekg-assets/chart_line_add.png
ekg-assets/cross.png
ekg-assets/cross.png
test-data/ngrams/GarganText_NgramsTerms-QuantumComputing.json
test-data/ngrams/GarganText_NgramsTerms-QuantumComputing.json
test-data/phylo/bpa_phylo_test.json
test-data/phylo/open_science.json
library
library
exposed-modules:
exposed-modules:
...
...
package.yaml
View file @
69fa22f7
...
@@ -45,6 +45,8 @@ data-files:
...
@@ -45,6 +45,8 @@ data-files:
-
ekg-assets/chart_line_add.png
-
ekg-assets/chart_line_add.png
-
ekg-assets/cross.png
-
ekg-assets/cross.png
-
test-data/ngrams/GarganText_NgramsTerms-QuantumComputing.json
-
test-data/ngrams/GarganText_NgramsTerms-QuantumComputing.json
-
test-data/phylo/bpa_phylo_test.json
-
test-data/phylo/open_science.json
library
:
library
:
source-dirs
:
src
source-dirs
:
src
ghc-options
:
ghc-options
:
...
...
src-test/Offline/JSON.hs
View file @
69fa22f7
...
@@ -16,8 +16,11 @@ import Test.Tasty
...
@@ -16,8 +16,11 @@ import Test.Tasty
import
Test.Tasty.HUnit
import
Test.Tasty.HUnit
import
Test.Tasty.QuickCheck
import
Test.Tasty.QuickCheck
import
Text.RawString.QQ
import
Text.RawString.QQ
import
qualified
Data.ByteString
as
B
import
qualified
Data.ByteString.Lazy.Char8
as
C8
import
qualified
Data.ByteString.Lazy.Char8
as
C8
import
Paths_gargantext
jsonRoundtrip
::
(
Show
a
,
FromJSON
a
,
ToJSON
a
,
Eq
a
)
=>
a
->
Property
jsonRoundtrip
::
(
Show
a
,
FromJSON
a
,
ToJSON
a
,
Eq
a
)
=>
a
->
Property
jsonRoundtrip
a
=
jsonRoundtrip
a
=
counterexample
(
"Parsed JSON: "
<>
C8
.
unpack
(
encode
a
))
$
eitherDecode
(
encode
a
)
===
Right
a
counterexample
(
"Parsed JSON: "
<>
C8
.
unpack
(
encode
a
))
$
eitherDecode
(
encode
a
)
===
Right
a
...
@@ -33,6 +36,9 @@ tests = testGroup "JSON" [
...
@@ -33,6 +36,9 @@ tests = testGroup "JSON" [
,
testProperty
"GraphDataData"
(
jsonRoundtrip
@
GraphDataData
)
,
testProperty
"GraphDataData"
(
jsonRoundtrip
@
GraphDataData
)
,
testProperty
"ObjectData"
(
jsonRoundtrip
@
ObjectData
)
,
testProperty
"ObjectData"
(
jsonRoundtrip
@
ObjectData
)
,
testProperty
"PhyloData"
(
jsonRoundtrip
@
PhyloData
)
,
testProperty
"PhyloData"
(
jsonRoundtrip
@
PhyloData
)
,
testProperty
"LayerData"
(
jsonRoundtrip
@
LayerData
)
,
testCase
"can parse bpa_phylo_test.json"
testParseBpaPhylo
,
testCase
"can parse open_science.json"
testOpenSciencePhylo
]
]
]
]
...
@@ -46,3 +52,19 @@ testWithQueryFrontend = do
...
@@ -46,3 +52,19 @@ testWithQueryFrontend = do
-- instances, this test would fail, and we will be notified.
-- instances, this test would fail, and we will be notified.
cannedWithQueryPayload
::
String
cannedWithQueryPayload
::
String
cannedWithQueryPayload
=
[
r
|
{"query":"Haskell","node_id":138,"lang":"EN","flowListWith":{"type":"MyListsFirst"},"datafield":"External Arxiv","databases":"Arxiv"}
|]
cannedWithQueryPayload
=
[
r
|
{"query":"Haskell","node_id":138,"lang":"EN","flowListWith":{"type":"MyListsFirst"},"datafield":"External Arxiv","databases":"Arxiv"}
|]
testParseBpaPhylo
::
Assertion
testParseBpaPhylo
=
do
pth
<-
getDataFileName
"test-data/phylo/bpa_phylo_test.json"
jsonBlob
<-
B
.
readFile
pth
case
eitherDecodeStrict'
@
GraphData
jsonBlob
of
Left
err
->
error
err
Right
_
->
pure
()
testOpenSciencePhylo
::
Assertion
testOpenSciencePhylo
=
do
pth
<-
getDataFileName
"test-data/phylo/open_science.json"
jsonBlob
<-
B
.
readFile
pth
case
eitherDecodeStrict'
@
PhyloData
jsonBlob
of
Left
err
->
error
err
Right
_
->
pure
()
src/Gargantext/Core/Types/Phylo.hs
View file @
69fa22f7
...
@@ -33,6 +33,7 @@ import Control.Applicative ((<|>))
...
@@ -33,6 +33,7 @@ import Control.Applicative ((<|>))
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.Types
import
Data.Aeson.Types
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Maybe
import
Data.Monoid
import
Data.Monoid
import
Data.Swagger
import
Data.Swagger
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
...
@@ -395,7 +396,7 @@ instance ToJSON LayerData where
...
@@ -395,7 +396,7 @@ instance ToJSON LayerData where
instance
FromJSON
LayerData
where
instance
FromJSON
LayerData
where
parseJSON
=
withObject
"LayerData"
$
\
o
->
do
parseJSON
=
withObject
"LayerData"
$
\
o
->
do
_ld_nodes
<-
o
.:
"nodes"
_ld_nodes
<-
fromMaybe
mempty
<$>
(
o
.:?
"nodes"
)
pure
$
LayerData
{
..
}
pure
$
LayerData
{
..
}
data
NodeCommonData
=
data
NodeCommonData
=
...
@@ -447,6 +448,7 @@ data EdgeData
...
@@ -447,6 +448,7 @@ data EdgeData
=
GroupToAncestor
!
GvId
!
EdgeCommonData
!
GroupToAncestorData
=
GroupToAncestor
!
GvId
!
EdgeCommonData
!
GroupToAncestorData
|
GroupToGroup
!
GvId
!
EdgeCommonData
!
GroupToGroupData
|
GroupToGroup
!
GvId
!
EdgeCommonData
!
GroupToGroupData
|
BranchToGroup
!
GvId
!
EdgeCommonData
!
BranchToGroupData
|
BranchToGroup
!
GvId
!
EdgeCommonData
!
BranchToGroupData
|
PeriodToPeriod
!
GvId
!
EdgeCommonData
deriving
(
Show
,
Eq
,
Generic
)
deriving
(
Show
,
Eq
,
Generic
)
data
GroupToAncestorData
data
GroupToAncestorData
...
@@ -516,13 +518,15 @@ instance FromJSON GvId where
...
@@ -516,13 +518,15 @@ instance FromJSON GvId where
instance
ToJSON
EdgeData
where
instance
ToJSON
EdgeData
where
toJSON
=
\
case
toJSON
=
\
case
GroupToAncestor
gvid
commonData
edgeTypeData
GroupToAncestor
gvid
commonData
edgeTypeData
->
mkEdge
"ancestorLink"
gvid
commonData
edgeTypeData
->
mkEdge
(
Just
"ancestorLink"
)
gvid
commonData
edgeTypeData
GroupToGroup
gvid
commonData
edgeTypeData
GroupToGroup
gvid
commonData
edgeTypeData
->
mkEdge
"link"
gvid
commonData
edgeTypeData
->
mkEdge
(
Just
"link"
)
gvid
commonData
edgeTypeData
BranchToGroup
gvid
commonData
edgeTypeData
BranchToGroup
gvid
commonData
edgeTypeData
->
mkEdge
"branchLink"
gvid
commonData
edgeTypeData
->
mkEdge
(
Just
"branchLink"
)
gvid
commonData
edgeTypeData
PeriodToPeriod
gvid
commonData
->
mkEdge
Nothing
gvid
commonData
(
Object
mempty
)
mkEdge
::
ToJSON
a
=>
Text
->
GvId
->
EdgeCommonData
->
a
->
Value
mkEdge
::
ToJSON
a
=>
Maybe
Text
->
GvId
->
EdgeCommonData
->
a
->
Value
mkEdge
edgeType
gvid
commonData
edgeTypeData
=
mkEdge
edgeType
gvid
commonData
edgeTypeData
=
let
commonDataJSON
=
toJSON
commonData
let
commonDataJSON
=
toJSON
commonData
edgeTypeDataJSON
=
toJSON
edgeTypeData
edgeTypeDataJSON
=
toJSON
edgeTypeData
...
@@ -537,18 +541,19 @@ mkEdge edgeType gvid commonData edgeTypeData =
...
@@ -537,18 +541,19 @@ mkEdge edgeType gvid commonData edgeTypeData =
instance
FromJSON
EdgeData
where
instance
FromJSON
EdgeData
where
parseJSON
=
withObject
"EdgeData"
$
\
o
->
do
parseJSON
=
withObject
"EdgeData"
$
\
o
->
do
edgeType
<-
o
.:
"edgeType"
edgeType
<-
o
.:
?
"edgeType"
gvid
<-
o
.:
"_gvid"
gvid
<-
o
.:
"_gvid"
_ed_color
<-
o
.:
"color"
_ed_color
<-
o
.:
"color"
_ed_head
<-
o
.:
"head"
_ed_head
<-
o
.:
"head"
_ed_pos
<-
o
.:
"pos"
_ed_pos
<-
o
.:
"pos"
_ed_tail
<-
o
.:
"tail"
_ed_tail
<-
o
.:
"tail"
_ed_width
<-
o
.:
"width"
_ed_width
<-
o
.:
"width"
case
(
edgeType
::
Text
)
of
case
(
edgeType
::
Maybe
Text
)
of
"ancestorLink"
->
GroupToAncestor
<$>
pure
gvid
<*>
pure
EdgeCommonData
{
..
}
<*>
parseJSON
(
Object
o
)
Just
"ancestorLink"
->
GroupToAncestor
<$>
pure
gvid
<*>
pure
EdgeCommonData
{
..
}
<*>
parseJSON
(
Object
o
)
"link"
->
GroupToGroup
<$>
pure
gvid
<*>
pure
EdgeCommonData
{
..
}
<*>
parseJSON
(
Object
o
)
Just
"link"
->
GroupToGroup
<$>
pure
gvid
<*>
pure
EdgeCommonData
{
..
}
<*>
parseJSON
(
Object
o
)
"branchLink"
->
BranchToGroup
<$>
pure
gvid
<*>
pure
EdgeCommonData
{
..
}
<*>
parseJSON
(
Object
o
)
Just
"branchLink"
->
BranchToGroup
<$>
pure
gvid
<*>
pure
EdgeCommonData
{
..
}
<*>
parseJSON
(
Object
o
)
_
->
fail
$
"EdgeData: unrecognised edgeType for Phylo graph: "
<>
T
.
unpack
edgeType
Just
unknownEdgeType
->
fail
$
"EdgeData: unrecognised edgeType for Phylo graph: "
<>
T
.
unpack
unknownEdgeType
Nothing
->
pure
$
PeriodToPeriod
gvid
EdgeCommonData
{
..
}
instance
ToJSON
EdgeCommonData
where
instance
ToJSON
EdgeCommonData
where
toJSON
EdgeCommonData
{
..
}
=
object
toJSON
EdgeCommonData
{
..
}
=
object
...
...
test-data/phylo/bpa_phylo_test.json
0 → 100644
View file @
69fa22f7
This diff is collapsed.
Click to expand it.
test-data/phylo/open_science.json
0 → 100644
View file @
69fa22f7
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment