Commit 17ae8abd authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Add proper Arbitrary instances for Phylo

parent b544b3c5
Pipeline #5790 failed with stages
in 103 minutes and 57 seconds
......@@ -40,6 +40,7 @@ import Gargantext.Core.Utils.Prefix (unPrefixSwagger)
import Gargantext.Prelude
import Test.QuickCheck
import Test.QuickCheck.Instances.Text()
import Test.QuickCheck.Instances.Vector()
---------------------
-- | PhyloConfig | --
......@@ -311,6 +312,8 @@ data Software =
instance ToSchema Software where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_software_")
instance Arbitrary Software where
arbitrary = pure defaultSoftware
......@@ -330,8 +333,6 @@ data PhyloParam =
instance ToSchema PhyloParam where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_phyloParam_")
defaultPhyloParam :: PhyloParam
defaultPhyloParam =
PhyloParam { _phyloParam_version = pack "v3"
......@@ -376,6 +377,9 @@ data PhyloFoundations = PhyloFoundations
, _foundations_rootsInGroups :: Map Int [PhyloGroupId] -- map of roots associated to groups
} deriving (Generic, Show, Eq, ToExpr)
instance Arbitrary PhyloFoundations where
arbitrary = PhyloFoundations <$> arbitrary <*> arbitrary
data PhyloCounts = PhyloCounts
{ coocByDate :: !(Map Date Cooc)
, docsByDate :: !(Map Date Double)
......@@ -394,6 +398,15 @@ instance ToSchema PhyloCounts where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_")
instance ToSchema PhyloSources where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_")
instance Arbitrary PhyloCounts where
arbitrary = PhyloCounts <$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
instance Arbitrary PhyloSources where
arbitrary = PhyloSources <$> arbitrary
---------------------------
-- | Coocurency Matrix | --
......@@ -454,6 +467,9 @@ data PhyloPeriod =
instance ToSchema PhyloPeriod where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_phylo_")
instance Arbitrary PhyloPeriod where
arbitrary = PhyloPeriod <$> arbitrary <*> arbitrary <*> arbitrary
---------------
-- | Scale | --
......@@ -476,6 +492,8 @@ data PhyloScale =
instance ToSchema PhyloScale where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_phylo_")
instance Arbitrary PhyloScale where
arbitrary = PhyloScale <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
type PhyloGroupId = (PhyloScaleId, Int)
......@@ -511,7 +529,28 @@ data PhyloGroup =
instance ToSchema PhyloGroup where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_phylo_")
instance Arbitrary PhyloGroup where
arbitrary = PhyloGroup <$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
-- | Weight : A generic mesure that can be associated with an Id
type Weight = Double
......@@ -757,3 +796,6 @@ instance Arbitrary Order where
instance Arbitrary Filter where
arbitrary = ByBranchSize <$> arbitrary
instance Arbitrary PhyloParam where
arbitrary = pure defaultPhyloParam
......@@ -39,7 +39,6 @@ import Gargantext.Prelude
import Network.HTTP.Media ((//), (/:))
import Prelude qualified
import Servant
import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
import Web.HttpApiData (readTextData)
import Gargantext.Database.Query.Table.Node.Error
......@@ -195,10 +194,6 @@ putPhylo = undefined
-- | Instances
-- instance Arbitrary Phylo where arbitrary = elements [phylo]
instance Arbitrary PhyloGroup where arbitrary = elements []
-- instance Arbitrary PhyloView where arbitrary = elements [phyloView]
-- instance Arbitrary PhyloConfig where arbitrary = elements []
instance FromHttpApiData DisplayMode where parseUrlPiece = readTextData
instance FromHttpApiData ExportMode where parseUrlPiece = readTextData
instance FromHttpApiData Filiation where parseUrlPiece = readTextData
......
......@@ -20,7 +20,6 @@ import Control.Concurrent
import Control.Concurrent.Async
import Control.Concurrent.Async qualified as Async
import Control.Concurrent.STM
import Data.List (isInfixOf)
import Data.Sequence ((|>), fromList)
import Data.Time
import Debug.RecoverRTTI (anythingToString)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment