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
119
Issues
119
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
d9ff9a1b
Commit
d9ff9a1b
authored
Jun 02, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test case to reproduce
#217
parent
e42661a8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
7 deletions
+48
-7
gargantext.cabal
gargantext.cabal
+2
-0
package.yaml
package.yaml
+2
-0
Query.hs
src-test/Ngrams/Query.hs
+41
-7
Types.hs
src/Gargantext/API/Ngrams/Types.hs
+3
-0
No files found.
gargantext.cabal
View file @
d9ff9a1b
...
...
@@ -901,12 +901,14 @@ test-suite garg-test
, gargantext-prelude
, hspec
, parsec
, patches-class
, quickcheck-instances
, tasty
, tasty-hunit
, text
, time
, unordered-containers
, validity
default-language: Haskell2010
test-suite jobqueue-test
...
...
package.yaml
View file @
d9ff9a1b
...
...
@@ -520,11 +520,13 @@ tests:
-
quickcheck-instances
-
time
-
parsec
-
patches-class
-
duckling
-
tasty
-
tasty-hunit
-
text
-
unordered-containers
-
validity
jobqueue-test
:
main
:
Main.hs
source-dirs
:
tests/queue
...
...
src-test/Ngrams/Query.hs
View file @
d9ff9a1b
...
...
@@ -3,16 +3,19 @@
module
Ngrams.Query
where
import
Control.Monad
import
Gargantext.Prelude
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams.Types
import
Data.Coerce
import
Data.Monoid
import
qualified
Data.Text
as
T
import
qualified
Data.Map.Strict
as
Map
import
Data.Map.Strict
(
Map
)
import
Gargantext.Core.Types.Query
import
Data.Monoid
import
Gargantext.API.Ngrams.Types
(
mSetFromList
)
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Query
import
Gargantext.Prelude
import
qualified
Data.Map.Strict
as
Map
import
qualified
Data.Patch.Class
as
Patch
import
qualified
Data.Validity
as
Validity
import
qualified
Data.Text
as
T
import
Ngrams.Query.PaginationCorpus
import
Test.Tasty
...
...
@@ -61,6 +64,8 @@ unitTests = testGroup "Query tests"
,
testCase
"Simple pagination on CandidateTerm (limit < total terms)"
test_pagination04
,
testCase
"paginating QuantumComputing corpus works (MapTerms)"
test_paginationQuantum
,
testCase
"paginating QuantumComputing corpus works (CandidateTerm)"
test_paginationQuantum_02
-- -- Patching
,
testCase
"I can apply a patch to term mapTerms to stopTerms (issue #217)"
test_217
]
-- Let's test that if we request elements sorted in
...
...
@@ -297,3 +302,32 @@ test_paginationQuantum_02 = do
,
_nsq_orderBy
=
Nothing
,
_nsq_searchQuery
=
mockQueryFn
Nothing
}
issue217Corpus
::
NgramsTableMap
issue217Corpus
=
Map
.
fromList
[
(
"advantages"
,
NgramsRepoElement
1
MapTerm
Nothing
Nothing
(
mSetFromList
[
"advantage"
]))
,
(
"advantage"
,
NgramsRepoElement
1
MapTerm
(
Just
"advantages"
)
(
Just
"advantages"
)
mempty
)
]
patched217Corpus
::
NgramsTableMap
patched217Corpus
=
Map
.
fromList
[
(
"advantages"
,
NgramsRepoElement
1
StopTerm
Nothing
Nothing
(
mSetFromList
[
"advantage"
]))
,
(
"advantage"
,
NgramsRepoElement
1
StopTerm
(
Just
"advantages"
)
(
Just
"advantages"
)
mempty
)
]
-- In this patch we simulate turning the subtree composed by 'advantages' and 'advantage'
-- from map terms to stop terms.
patch217
::
NgramsTablePatch
patch217
=
mkNgramsTablePatch
$
Map
.
fromList
[
(
NgramsTerm
"advantages"
,
NgramsPatch
{
_patch_children
=
mempty
,
_patch_list
=
Patch
.
Replace
MapTerm
StopTerm
}
)
]
test_217
::
Assertion
test_217
=
do
-- Check the patch is applicable
Validity
.
validationIsValid
(
Patch
.
applicable
patch217
(
Just
issue217Corpus
))
@?=
True
Patch
.
act
patch217
(
Just
issue217Corpus
)
@?=
Just
patched217Corpus
src/Gargantext/API/Ngrams/Types.hs
View file @
d9ff9a1b
...
...
@@ -555,6 +555,9 @@ instance Action NgramsPatch (Maybe NgramsRepoElement) where
newtype
NgramsTablePatch
=
NgramsTablePatch
(
PatchMap
NgramsTerm
NgramsPatch
)
deriving
(
Eq
,
Show
,
Generic
,
ToJSON
,
FromJSON
,
Semigroup
,
Monoid
,
Validity
,
Transformable
)
mkNgramsTablePatch
::
Map
NgramsTerm
NgramsPatch
->
NgramsTablePatch
mkNgramsTablePatch
=
NgramsTablePatch
.
PM
.
fromMap
instance
Serialise
NgramsTablePatch
instance
Serialise
(
PatchMap
NgramsTerm
NgramsPatch
)
...
...
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