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
150
Issues
150
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
0cc0f9e6
Commit
0cc0f9e6
authored
Sep 04, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for adding language to Corpus
parent
fcdfc898
Pipeline
#4555
passed with stages
in 38 minutes and 15 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
6 deletions
+41
-6
gargantext.cabal
gargantext.cabal
+1
-1
Update.hs
src/Gargantext/API/Node/Corpus/Update.hs
+3
-2
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+1
-1
Operations.hs
test/Database/Operations.hs
+36
-2
No files found.
gargantext.cabal
View file @
0cc0f9e6
...
@@ -58,6 +58,7 @@ library
...
@@ -58,6 +58,7 @@ library
Gargantext.API.Node
Gargantext.API.Node
Gargantext.API.Node.Corpus.New
Gargantext.API.Node.Corpus.New
Gargantext.API.Node.Corpus.Types
Gargantext.API.Node.Corpus.Types
Gargantext.API.Node.Corpus.Update
Gargantext.API.Node.File
Gargantext.API.Node.File
Gargantext.API.Node.Share
Gargantext.API.Node.Share
Gargantext.API.Prelude
Gargantext.API.Prelude
...
@@ -175,7 +176,6 @@ library
...
@@ -175,7 +176,6 @@ library
Gargantext.API.Node.Corpus.New.File
Gargantext.API.Node.Corpus.New.File
Gargantext.API.Node.Corpus.New.Types
Gargantext.API.Node.Corpus.New.Types
Gargantext.API.Node.Corpus.Searx
Gargantext.API.Node.Corpus.Searx
Gargantext.API.Node.Corpus.Update
Gargantext.API.Node.Document.Export
Gargantext.API.Node.Document.Export
Gargantext.API.Node.Document.Export.Types
Gargantext.API.Node.Document.Export.Types
Gargantext.API.Node.DocumentsFromWriteNodes
Gargantext.API.Node.DocumentsFromWriteNodes
...
...
src/Gargantext/API/Node/Corpus/Update.hs
View file @
0cc0f9e6
...
@@ -7,17 +7,18 @@ import Control.Lens
...
@@ -7,17 +7,18 @@ import Control.Lens
import
Control.Monad
import
Control.Monad
import
Data.Proxy
import
Data.Proxy
import
Gargantext.Core
import
Gargantext.Core
import
Gargantext.Database.Action.Flow.Types
import
Gargantext.Database.Admin.Types.Hyperdata.Corpus
import
Gargantext.Database.Admin.Types.Hyperdata.Corpus
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Utils.Jobs
import
Gargantext.Utils.Jobs
-- | Updates the 'HyperdataCorpus' with the input 'Lang'.
-- | Updates the 'HyperdataCorpus' with the input 'Lang'.
addLanguageToCorpus
::
(
FlowCmdM
env
err
m
,
MonadJobStatus
m
)
addLanguageToCorpus
::
(
HasNodeError
err
,
DbCmd'
env
err
m
,
MonadJobStatus
m
)
=>
CorpusId
=>
CorpusId
->
Lang
->
Lang
->
m
()
->
m
()
...
...
src/Gargantext/Database/Query/Table/Node.hs
View file @
0cc0f9e6
...
@@ -260,7 +260,7 @@ getNode nId = do
...
@@ -260,7 +260,7 @@ getNode nId = do
Just
r
->
pure
r
Just
r
->
pure
r
getNodeWith
::
(
HasNodeError
err
,
JSONB
a
)
getNodeWith
::
(
HasNodeError
err
,
JSONB
a
)
=>
NodeId
->
proxy
a
->
Cmd
err
(
Node
a
)
=>
NodeId
->
proxy
a
->
DB
Cmd
err
(
Node
a
)
getNodeWith
nId
_
=
do
getNodeWith
nId
_
=
do
maybeNode
<-
headMay
<$>
runOpaQuery
(
selectNode
(
pgNodeId
nId
))
maybeNode
<-
headMay
<$>
runOpaQuery
(
selectNode
(
pgNodeId
nId
))
case
maybeNode
of
case
maybeNode
of
...
...
test/Database/Operations.hs
View file @
0cc0f9e6
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE TypeFamilies #-}
module
Database.Operations
(
module
Database.Operations
(
tests
tests
...
@@ -44,6 +45,13 @@ import Test.Hspec
...
@@ -44,6 +45,13 @@ import Test.Hspec
import
Test.QuickCheck.Monadic
import
Test.QuickCheck.Monadic
import
Test.Tasty.HUnit
hiding
(
assert
)
import
Test.Tasty.HUnit
hiding
(
assert
)
import
Test.Tasty.QuickCheck
import
Test.Tasty.QuickCheck
import
Gargantext.API.Node.Corpus.Update
import
Gargantext.Core
import
Gargantext.Utils.Jobs
import
qualified
Gargantext.API.Admin.EnvTypes
as
EnvTypes
import
Gargantext.API.Admin.EnvTypes
import
Gargantext.API.Prelude
import
Gargantext.API.Admin.Orchestrator.Types
-- | Keeps a log of usernames we have already generated, so that our
-- | Keeps a log of usernames we have already generated, so that our
-- roundtrip tests won't fail.
-- roundtrip tests won't fail.
...
@@ -89,6 +97,21 @@ newtype TestMonad a = TestMonad { runTestMonad :: ReaderT TestEnv IO a }
...
@@ -89,6 +97,21 @@ newtype TestMonad a = TestMonad { runTestMonad :: ReaderT TestEnv IO a }
,
MonadIO
,
MonadIO
)
)
instance
MonadJobStatus
TestMonad
where
type
JobHandle
TestMonad
=
EnvTypes
.
ConcreteJobHandle
GargError
type
JobType
TestMonad
=
GargJob
type
JobOutputType
TestMonad
=
JobLog
type
JobEventType
TestMonad
=
JobLog
getLatestJobStatus
_
=
TestMonad
(
pure
noJobLog
)
withTracer
_
jh
n
=
n
jh
markStarted
_
_
=
TestMonad
$
pure
()
markProgress
_
_
=
TestMonad
$
pure
()
markFailure
_
_
_
=
TestMonad
$
pure
()
markComplete
_
=
TestMonad
$
pure
()
markFailed
_
_
=
TestMonad
$
pure
()
addMoreSteps
_
_
=
TestMonad
$
pure
()
data
DBHandle
=
DBHandle
{
data
DBHandle
=
DBHandle
{
_DBHandle
::
Pool
PG
.
Connection
_DBHandle
::
Pool
PG
.
Connection
,
_DBTmp
::
Tmp
.
DB
,
_DBTmp
::
Tmp
.
DB
...
@@ -158,6 +181,7 @@ tests = sequential $ aroundAll withTestDB $ describe "Database" $ do
...
@@ -158,6 +181,7 @@ tests = sequential $ aroundAll withTestDB $ describe "Database" $ do
it
"Read/Write roundtrip"
prop_userCreationRoundtrip
it
"Read/Write roundtrip"
prop_userCreationRoundtrip
describe
"Corpus creation"
$
do
describe
"Corpus creation"
$
do
it
"Simple write/read"
corpusReadWrite01
it
"Simple write/read"
corpusReadWrite01
it
"Can add language to Corpus"
corpusAddLanguage
data
ExpectedActual
a
=
data
ExpectedActual
a
=
Expected
a
Expected
a
...
@@ -224,5 +248,15 @@ corpusReadWrite01 env = do
...
@@ -224,5 +248,15 @@ corpusReadWrite01 env = do
[
corpusId
]
<-
mk
(
Just
"Test_Corpus"
)
(
Nothing
::
Maybe
HyperdataCorpus
)
parentId
uid
[
corpusId
]
<-
mk
(
Just
"Test_Corpus"
)
(
Nothing
::
Maybe
HyperdataCorpus
)
parentId
uid
liftIO
$
corpusId
`
shouldBe
`
NodeId
409
liftIO
$
corpusId
`
shouldBe
`
NodeId
409
-- Retrieve the corpus by Id
-- Retrieve the corpus by Id
[
corpusId'
]
<-
getCorporaWithParentId
parentId
[
corpus
]
<-
getCorporaWithParentId
parentId
liftIO
$
corpusId
`
shouldBe
`
(
_node_id
corpusId'
)
liftIO
$
corpusId
`
shouldBe
`
(
_node_id
corpus
)
corpusAddLanguage
::
TestEnv
->
Assertion
corpusAddLanguage
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
parentId
<-
getRootId
(
UserName
"alfredo"
)
[
corpus
]
<-
getCorporaWithParentId
parentId
liftIO
$
(
_hc_lang
.
_node_hyperdata
$
corpus
)
`
shouldBe
`
Just
EN
-- defaults to English
addLanguageToCorpus
(
_node_id
corpus
)
IT
[
corpus'
]
<-
getCorporaWithParentId
parentId
liftIO
$
(
_hc_lang
.
_node_hyperdata
$
corpus'
)
`
shouldBe
`
Just
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