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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
75488abc
Commit
75488abc
authored
May 08, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more pagination tests
parent
7b955a56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
160 additions
and
4 deletions
+160
-4
gargantext.cabal
gargantext.cabal
+2
-1
Main.hs
src-test/Main.hs
+0
-3
Query.hs
src-test/Ngrams/Query.hs
+38
-0
PaginationCorpus.hs
src-test/Ngrams/Query/PaginationCorpus.hs
+120
-0
No files found.
gargantext.cabal
View file @
75488abc
...
...
@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack
name: gargantext
version: 0.0.6.9.9.4.1
version:
0.0.6.9.9.4.1
synopsis: Search, map, share
description: Please see README.md
category: Data
...
...
@@ -849,6 +849,7 @@ test-suite garg-test
Ngrams.Metrics
Ngrams.NLP
Ngrams.Query
Ngrams.Query.PaginationCorpus
Parsers.Date
Parsers.Types
Parsers.WOS
...
...
src-test/Main.hs
View file @
75488abc
...
...
@@ -10,15 +10,12 @@ Portability : POSIX
import
Gargantext.Prelude
import
Gargantext.Core
(
Lang
(
..
))
import
qualified
Core.Utils
as
Utils
--import qualified Ngrams.Lang.Fr as Fr
--import qualified Ngrams.Lang as Lang
import
qualified
Ngrams.Lang.Occurrences
as
Occ
import
qualified
Ngrams.NLP
as
NLP
import
qualified
Ngrams.Query
as
NgramsQuery
import
qualified
Ngrams.Metrics
as
Metrics
import
qualified
Parsers.Date
as
PD
-- import qualified Graph.Distance as GD
import
qualified
Graph.Clustering
as
Graph
...
...
src-test/Ngrams/Query.hs
View file @
75488abc
...
...
@@ -11,6 +11,7 @@ import Data.Map.Strict (Map)
import
Gargantext.Core.Types.Query
import
Gargantext.Core.Types.Main
import
Ngrams.Query.PaginationCorpus
import
Test.Tasty
import
Test.Tasty.HUnit
...
...
@@ -47,6 +48,9 @@ unitTests = testGroup "Query tests"
,
testCase
"Simple query (listType = StopTerm)"
testFlat04
-- Full text search
,
testCase
"Simple query (search with match)"
testFlat05
-- Pagination
,
testCase
"Simple pagination on MapTerm"
test_pagination01
,
testCase
"Simple pagination on MapTerm (limit < total terms)"
test_pagination02
]
-- Let's test that if we request elements sorted in
...
...
@@ -132,3 +136,37 @@ testFlat05 = do
,
_nsq_orderBy
=
Just
TermDesc
,
_nsq_searchQuery
=
mockQueryFn
(
Just
"curry"
)
}
-- Pagination tests
-- In this test, I'm asking for 5 /map terms/, and as the
-- corpus has only 2, that's what I should get back.
test_pagination01
::
Assertion
test_pagination01
=
do
let
res
=
searchTableNgrams
paginationCorpus
searchQuery
res
@?=
VersionedWithCount
0
4
(
NgramsTable
[
implementationElem
,
languagesElem
,
termsElem
,
proofElem
]
)
where
searchQuery
=
NgramsSearchQuery
{
_nsq_limit
=
Limit
5
,
_nsq_offset
=
Nothing
,
_nsq_listType
=
Just
MapTerm
,
_nsq_minSize
=
Nothing
,
_nsq_maxSize
=
Nothing
,
_nsq_orderBy
=
Just
ScoreDesc
,
_nsq_searchQuery
=
mockQueryFn
Nothing
}
test_pagination02
::
Assertion
test_pagination02
=
do
let
res
=
searchTableNgrams
paginationCorpus
searchQuery
res
@?=
VersionedWithCount
0
4
(
NgramsTable
[
implementationElem
,
languagesElem
,
termsElem
]
)
where
searchQuery
=
NgramsSearchQuery
{
_nsq_limit
=
Limit
3
,
_nsq_offset
=
Nothing
,
_nsq_listType
=
Just
MapTerm
,
_nsq_minSize
=
Nothing
,
_nsq_maxSize
=
Nothing
,
_nsq_orderBy
=
Just
ScoreDesc
,
_nsq_searchQuery
=
mockQueryFn
Nothing
}
src-test/Ngrams/Query/PaginationCorpus.hs
0 → 100644
View file @
75488abc
module
Ngrams.Query.PaginationCorpus
where
import
Data.Map.Strict
(
Map
)
import
Gargantext.API.Ngrams
import
Gargantext.Core.Types.Main
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Prelude
import
qualified
Data.Map.Strict
as
Map
import
qualified
Data.Set
as
Set
implementationElem
::
NgramsElement
implementationElem
=
NgramsElement
{
_ne_ngrams
=
"implementation"
,
_ne_size
=
1
,
_ne_list
=
MapTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
,
NodeId
3
,
NodeId
4
,
NodeId
5
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[
"code"
,
"functions"
,
"language"
,
"programs"
]
}
languagesElem
::
NgramsElement
languagesElem
=
NgramsElement
{
_ne_ngrams
=
NgramsTerm
{
unNgramsTerm
=
"languages"
}
,
_ne_size
=
1
,
_ne_list
=
MapTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
,
NodeId
3
,
NodeId
4
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[
"approach"
,
"use"
]
}
termsElem
::
NgramsElement
termsElem
=
NgramsElement
{
_ne_ngrams
=
NgramsTerm
{
unNgramsTerm
=
"terms"
}
,
_ne_size
=
1
,
_ne_list
=
MapTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
,
NodeId
3
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[
"algorithm"
,
"evaluation"
,
"monad"
,
"programmers"
]
}
proofElem
::
NgramsElement
proofElem
=
NgramsElement
{
_ne_ngrams
=
NgramsTerm
{
unNgramsTerm
=
"proof"
}
,
_ne_size
=
1
,
_ne_list
=
MapTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[
"proofs"
]
}
sideEffectsElem
::
NgramsElement
sideEffectsElem
=
NgramsElement
{
_ne_ngrams
=
NgramsTerm
{
unNgramsTerm
=
"side effects"
}
,
_ne_size
=
1
,
_ne_list
=
StopTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
,
NodeId
3
,
NodeId
4
,
NodeId
5
,
NodeId
6
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[ ]
}
ooElem
::
NgramsElement
ooElem
=
NgramsElement
{
_ne_ngrams
=
NgramsTerm
{
unNgramsTerm
=
"object oriented"
}
,
_ne_size
=
1
,
_ne_list
=
StopTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
,
NodeId
3
,
NodeId
4
,
NodeId
5
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[
"null pointer exception"
]
}
haskellElem
::
NgramsElement
haskellElem
=
NgramsElement
{
_ne_ngrams
=
NgramsTerm
{
unNgramsTerm
=
"haskell"
}
,
_ne_size
=
1
,
_ne_list
=
CandidateTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
,
NodeId
3
,
NodeId
4
,
NodeId
5
,
NodeId
6
,
NodeId
7
,
NodeId
8
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[ ]
}
concHaskellElem
::
NgramsElement
concHaskellElem
=
NgramsElement
{
_ne_ngrams
=
NgramsTerm
{
unNgramsTerm
=
"concurrent haskell"
}
,
_ne_size
=
1
,
_ne_list
=
CandidateTerm
,
_ne_occurrences
=
Set
.
fromList
[
NodeId
1
,
NodeId
2
,
NodeId
3
,
NodeId
4
,
NodeId
5
]
,
_ne_root
=
Nothing
,
_ne_parent
=
Nothing
,
_ne_children
=
mSetFromList
[
"Simon Marlow"
]
}
-- | A big (for the sake of the tests anyway) corpus which has
-- * 4 @MapTerm@s
-- * 4 @StopTerm@s
-- * 2 @CandidateTerm@s
paginationCorpus
::
Versioned
(
Map
NgramsTerm
NgramsElement
)
paginationCorpus
=
Versioned
0
$
Map
.
fromList
[
-- Map terms
(
"implementation"
,
implementationElem
)
,
(
"languages"
,
languagesElem
)
,
(
"terms"
,
termsElem
)
,
(
"proof"
,
proofElem
)
-- Stop terms
,
(
"side effects"
,
sideEffectsElem
)
,
(
"object oriented"
,
ooElem
)
-- Candidate terms
,
(
"haskell"
,
haskellElem
)
,
(
"concurrent haskell"
,
concHaskellElem
)
]
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