Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Haskell Gargantext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gargantext
Haskell Gargantext
Commits
d9ff9a1b
Commit
d9ff9a1b
authored
2 years ago
by
Alfredo Di Napoli
Browse files
Options
Downloads
Patches
Plain Diff
Add test case to reproduce #217
parent
e42661a8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gargantext.cabal
+2
-0
2 additions, 0 deletions
gargantext.cabal
package.yaml
+2
-0
2 additions, 0 deletions
package.yaml
src-test/Ngrams/Query.hs
+41
-7
41 additions, 7 deletions
src-test/Ngrams/Query.hs
src/Gargantext/API/Ngrams/Types.hs
+3
-0
3 additions, 0 deletions
src/Gargantext/API/Ngrams/Types.hs
with
48 additions
and
7 deletions
gargantext.cabal
+
2
−
0
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
...
...
This diff is collapsed.
Click to expand it.
package.yaml
+
2
−
0
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
...
...
This diff is collapsed.
Click to expand it.
src-test/Ngrams/Query.hs
+
41
−
7
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
This diff is collapsed.
Click to expand it.
src/Gargantext/API/Ngrams/Types.hs
+
3
−
0
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment