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
159
Issues
159
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
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
e2f4891a
Commit
e2f4891a
authored
Jun 12, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic Hal tests
parent
cc436c77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
Hal.hs
src/Gargantext/Core/Text/Corpus/API/Hal.hs
+4
-1
Query.hs
test/Test/Core/Text/Corpus/Query.hs
+41
-1
No files found.
src/Gargantext/Core/Text/Corpus/API/Hal.hs
View file @
e2f4891a
...
...
@@ -96,12 +96,15 @@ get la (convertQuery -> q) ml = do
eDocs
<-
HAL
.
getMetadataWith
[
getHalQuery
q
]
(
Just
0
)
(
fromIntegral
.
getLimit
<$>
ml
)
la
either
(
panic
.
pack
.
show
)
(
\
d
->
mapM
(
toDoc'
la
)
$
HAL
.
_docs
d
)
eDocs
halOptions
::
HAL
.
HalCrawlerOptions
halOptions
=
HAL
.
HalCrawlerOptions
False
1000
getC
::
Maybe
ISO639
.
ISO639_1
->
Corpus
.
Query
->
Maybe
Corpus
.
Limit
->
IO
(
Either
ClientError
(
Maybe
Integer
,
ConduitT
()
HyperdataDocument
IO
()
))
getC
la
(
convertQuery
->
q
)
ml
=
do
eRes
<-
HAL
.
getMetadataWith
C
[
getHalQuery
q
]
(
Just
0
)
(
fromIntegral
.
getLimit
<$>
ml
)
la
eRes
<-
HAL
.
getMetadataWith
LangC
halOptions
[
getHalQuery
q
]
(
Just
0
)
(
fromIntegral
.
getLimit
<$>
ml
)
la
pure
$
(
\
(
len
,
docsC
)
->
(
len
,
docsC
.|
mapMC
(
toDoc'
la
)))
<$>
eRes
toDoc'
::
Maybe
ISO639
.
ISO639_1
->
HAL
.
Corpus
->
IO
HyperdataDocument
...
...
test/Test/Core/Text/Corpus/Query.hs
View file @
e2f4891a
...
...
@@ -8,7 +8,7 @@ import Data.BoolExpr
import
Data.Conduit
import
Data.Maybe
import
Data.String
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
)
,
toISO639
)
import
Gargantext.Core.Text.Corpus.Query
import
Gargantext.Core.Types
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
...
...
@@ -116,6 +116,11 @@ tests = withResource pubmedSettings (const (pure ())) $ \getPubmedKey ->
testCase
"It searches for
\"
brain
\"
"
(
testIstexRealWorld_01
getPubmedKey
)
,
testCase
"It searches for
\"
brain
\"
AND NOT
\"
neural
\"
"
(
testIstexRealWorld_02
getPubmedKey
)
]
-- .. ditto for HAL
,
testGroup
"HAL real queries (skipped if PUBMED_API_KEY env var not set)"
[
testCase
"It searches for
\"
Haskell
\"
"
(
testHalRealWorld_01
getPubmedKey
)
,
testCase
"It searches for
\"
Haskell
\"
AND NOT
\"
Agda
\"
"
(
testHalRealWorld_02
getPubmedKey
)
]
]
-- | Checks that the 'RawQuery' can be translated into the expected 'BoolExpr' form,
...
...
@@ -503,3 +508,38 @@ testIstexRealWorld_02 getPubmedKey = do
case
hyperDocs
of
[]
->
fail
"No documents found."
(
x
:
_
)
->
isJust
(
_hd_title
x
)
@?=
True
--
-- HAL integration tests
--
testHalRealWorld_01
::
IO
(
Maybe
PubmedApiKey
)
->
Assertion
testHalRealWorld_01
getPubmedKey
=
do
mb_key
<-
getPubmedKey
case
mb_key
of
Nothing
->
pure
()
Just
_
->
withValidQuery
"Haskell"
$
\
query
->
do
res
<-
Hal
.
getC
(
toISO639
EN
)
query
(
Just
1
)
case
res
of
Left
err
->
fail
(
show
err
)
Right
(
_
,
cnd
)
->
do
hyperDocs
<-
sourceToList
cnd
case
hyperDocs
of
[]
->
fail
"No documents found."
(
x
:
_
)
->
assertBool
(
"found: "
<>
show
(
_hd_title
x
))
(
isJust
(
_hd_title
x
))
testHalRealWorld_02
::
IO
(
Maybe
PubmedApiKey
)
->
Assertion
testHalRealWorld_02
getPubmedKey
=
do
mb_key
<-
getPubmedKey
case
mb_key
of
Nothing
->
pure
()
Just
_
->
withValidQuery
"Haskell AND NOT Agda"
$
\
query
->
do
res
<-
Hal
.
getC
(
toISO639
EN
)
query
(
Just
1
)
case
res
of
Left
err
->
fail
(
show
err
)
Right
(
_
,
cnd
)
->
do
hyperDocs
<-
sourceToList
cnd
case
hyperDocs
of
[]
->
fail
"No documents found."
(
x
:
_
)
->
isJust
(
_hd_title
x
)
@?=
True
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