aboutsummaryrefslogtreecommitdiff
path: root/src/test/haskell
diff options
context:
space:
mode:
authorJoris2018-06-18 23:15:12 +0200
committerJoris2018-06-18 23:15:12 +0200
commit318292532a877c308403c45795d229fad659d900 (patch)
tree16e4695cc316a28bff4f0a9ae42e779ecce82a31 /src/test/haskell
parent96bbdbbe9b22b3c3e96998cc18a3b68c9db66da9 (diff)
Add seLoger parser
Diffstat (limited to 'src/test/haskell')
-rw-r--r--src/test/haskell/Main.hs37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/test/haskell/Main.hs b/src/test/haskell/Main.hs
index ccafba4..ba09b78 100644
--- a/src/test/haskell/Main.hs
+++ b/src/test/haskell/Main.hs
@@ -4,11 +4,13 @@ import Test.Hspec
import Model.Ad (Ad (..))
import qualified Parser.LeboncoinParser as LeboncoinParser
import qualified Parser.OuestFranceParser as OuestFranceParser
+import qualified Parser.SeLogerParser as SeLogerParser
main :: IO ()
main = do
rawLeboncoinAds <- T.readFile "src/test/resources/leboncoin.html"
rawOuestFranceAds <- T.readFile "src/test/resources/ouestFrance.html"
+ rawSeLogerParser <- T.readFile "src/test/resources/seLoger.html"
hspec $ do
describe "LeboncoinParser" $ do
@@ -26,8 +28,8 @@ main = do
, Ad {name = "locations garage / garde meuble", location = "Landerneau", price = Just "50 €", url = "https://www.leboncoin.fr/locations/1450174538.htm?ca=6_s"}
, Ad {name = "Studio meublé", location = "Lanester", price = Just "290 €", url = "https://www.leboncoin.fr/locations/1450268170.htm?ca=6_s"}
, Ad {name = "Ergué-Gabéric - Maison - 3 chambres -", location = "Ergué-Gabéric", price = Just "655 €", url = "https://www.leboncoin.fr/locations/1450267530.htm?ca=6_s"}
- , Ad {name = "Studio meublé \224 2 mn de la gare", location = "Rennes", price = Just "475 €", url = "https://www.leboncoin.fr/locations/1450267333.htm?ca=6_s"}
- , Ad {name = "Chambre \224 louer chez l,habitant", location = "Rennes", price = Just "450 €", url = "https://www.leboncoin.fr/locations/1450266273.htm?ca=6_s"}
+ , Ad {name = "Studio meublé à 2 mn de la gare", location = "Rennes", price = Just "475 €", url = "https://www.leboncoin.fr/locations/1450267333.htm?ca=6_s"}
+ , Ad {name = "Chambre à louer chez l,habitant", location = "Rennes", price = Just "450 €", url = "https://www.leboncoin.fr/locations/1450266273.htm?ca=6_s"}
, Ad {name = "Appartement 3 pièces 63 m\178", location = "Brest", price = Just "600 €", url = "https://www.leboncoin.fr/locations/1426927284.htm?ca=6_s"}
, Ad {name = "recherche location", location = "Plaintel", price = Just "550 €", url = "https://www.leboncoin.fr/locations/1450265866.htm?ca=6_s"}
, Ad {name = "Studio rénové - Centre Ville Lorient", location = "Lorient", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450265154.htm?ca=6_s"}
@@ -90,3 +92,34 @@ main = do
]
OuestFranceParser.parse rawOuestFranceAds `shouldBe` ads
+
+ describe "SeLogerParser" $ do
+
+ it "should parse no results from empty string" $ do
+ SeLogerParser.parse "" `shouldBe` []
+
+ it "should parse ads from page" $ do
+ let ads =
+ [ Ad {name = "Appartement", location = "Paris 20ème", price = Just "1 219 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-20eme-75/plaine/134448375.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 16ème", price = Just "1 500 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/muette-sud/134049627.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 3ème", price = Just "1 595 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-3eme-75/arts-et-metiers/76038037.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 15ème", price = Just "1 612 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-15eme-75/citroen-boucicaut/135038561.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 16ème", price = Just "1 650 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/auteuil-sud/133027227.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 16ème", price = Just "1 875 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/chaillot/127190787.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 8ème", price = Just "1 985 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-8eme-75/saint-philippe-du-roule/127109353.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 1er", price = Just "2 090 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-1er-75/ile-de-la-cite/133982099.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 16ème", price = Just "2 240 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-16eme-75/porte-dauphine/118523093.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 17ème", price = Just "2 400 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-17eme-75/champerret-berthier/134621503.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 6ème", price = Just "2 055 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-6eme-75/saint-germain-des-pres/130192167.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 14ème", price = Just "1 300 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-14eme-75/jean-moulin-porte-d-orleans/133269543.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 16ème", price = Just "3 500 €", url = "https:https://www.bellesdemeures.com/annonces/locations/appartement/paris-16eme-75/133260359.htm?bd=CartoToList_SL&furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&cmp=INTSL_ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 17ème", price = Just "1 890 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-17eme-75/134972009.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 18ème", price = Just "1 390 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-18eme-75/clignancourt-jules-joffrin/134735501.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 6ème", price = Just "1 600 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-6eme-75/saint-germain-des-pres/134437989.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 11ème", price = Just "1 980 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-11eme-75/bastille-popincourt/134314607.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 13ème", price = Just "901 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-13eme-75/olympiades-choisy/134428153.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 12ème", price = Just "1 250 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-12eme-75/aligre-gare-de-lyon/133908165.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ , Ad {name = "Appartement", location = "Paris 17ème", price = Just "1 100 €", url = "https:https://www.seloger.com/annonces/locations/appartement/paris-17eme-75/legendre-levis/134131479.htm?furnished=0&places=%5b%7bcp%3a75%7d%5d&projects=1&qsversion=1.0&rooms=2&types=1&bd=ListToDetail"}
+ ]
+
+ SeLogerParser.parse rawSeLogerParser `shouldBe` ads