diff options
Diffstat (limited to 'src/test/haskell')
-rw-r--r-- | src/test/haskell/Ads.hs | 73 | ||||
-rw-r--r-- | src/test/haskell/Main.hs | 69 |
2 files changed, 75 insertions, 67 deletions
diff --git a/src/test/haskell/Ads.hs b/src/test/haskell/Ads.hs index 85a5471..fc934e1 100644 --- a/src/test/haskell/Ads.hs +++ b/src/test/haskell/Ads.hs @@ -8,41 +8,44 @@ import Model.Ad (Ad (..)) leboncoin :: [Ad] leboncoin = - [ Ad {name = "Chambre style hotel", location = "Dinan", price = Just "265 €", url = "https://www.leboncoin.fr/locations/1450271298.htm?ca=6_s"} - , Ad {name = "Centre ville", location = "Brest", price = Just "420 €", url = "https://www.leboncoin.fr/locations/1450271056.htm?ca=6_s"} - , Ad {name = "T3, Morlaix proche centre ville et port plaisance", location = "Morlaix", price = Just "395 €", url = "https://www.leboncoin.fr/locations/1407544500.htm?ca=6_s"} - , Ad {name = "Appartement meuble", location = "Rennes", price = Just "565 €", url = "https://www.leboncoin.fr/locations/1377975959.htm?ca=6_s"} - , Ad {name = "A louer T3", location = "La Chapelle-Janson", price = Just "420 €", url = "https://www.leboncoin.fr/locations/1450270098.htm?ca=6_s"} - , 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é à 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"} - , Ad {name = "Centre historique, t2 meuble", location = "Vannes", price = Just "440 €", url = "https://www.leboncoin.fr/locations/1450263864.htm?ca=6_s"} - , Ad {name = "appartement t3 parking privé", location = "Pontrieux", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1450251207.htm?ca=6_s"} - , Ad {name = "T1 Bis espace couchage indépendant", location = "Brest", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450263863.htm?ca=6_s"} - , Ad {name = "Grand T2 boulevard Gambetta", location = "Brest", price = Just "400 €", url = "https://www.leboncoin.fr/locations/1450263306.htm?ca=6_s"} - , Ad {name = "chambre meublée", location = "Bourg-des-Comptes", price = Just "300 €", url = "https://www.leboncoin.fr/locations/1450246530.htm?ca=6_s"} - , Ad {name = "Un studio de charme au centre de Landerneau", location = "Landerneau", price = Just "310 €", url = "https://www.leboncoin.fr/locations/1433376198.htm?ca=6_s"} - , Ad {name = "Appartement T2 plein centre.", location = "Pluméliau", price = Just "385 €", url = "https://www.leboncoin.fr/locations/1450262744.htm?ca=6_s"} - , Ad {name = "Recherche l'appartement parfait", location = "Rennes", price = Just "360 €", url = "https://www.leboncoin.fr/locations/1450260894.htm?ca=6_s"} - , Ad {name = "Location appartement meuble", location = "Saint-Malo", price = Just "510 €", url = "https://www.leboncoin.fr/locations/1421964890.htm?ca=6_s"} - , Ad {name = "Maison neuve Lambezelec", location = "Plabennec", price = Just "900 €", url = "https://www.leboncoin.fr/locations/1450259912.htm?ca=6_s"} - , Ad {name = "Chambre kitchenette chez l'habitant", location = "Brest", price = Just "320 €", url = "https://www.leboncoin.fr/locations/1450258838.htm?ca=6_s"} - , Ad {name = "Studio 20m2 Rennes Ouest", location = "Rennes", price = Just "395 €", url = "https://www.leboncoin.fr/locations/1450258223.htm?ca=6_s"} - , Ad {name = "Maison Ploufragan", location = "Ploufragan", price = Just "680 €", url = "https://www.leboncoin.fr/locations/1450257866.htm?ca=6_s"} - , Ad {name = "Studio centre villes Rennes", location = "Rennes", price = Just "425 €", url = "https://www.leboncoin.fr/locations/1450257277.htm?ca=6_s"} - , Ad {name = "Grand T2 Saint-Brieuc proche Renan", location = "Saint-Brieuc", price = Just "375 €", url = "https://www.leboncoin.fr/locations/1450257042.htm?ca=6_s"} - , Ad {name = "Location maison T3", location = "Langueux", price = Just "569 €", url = "https://www.leboncoin.fr/locations/1439054110.htm?ca=6_s"} - , Ad {name = "Chambre", location = "Vannes", price = Just "150 €", url = "https://www.leboncoin.fr/locations/1450255229.htm?ca=6_s"} - , Ad {name = "Appartement meublé 2 ch centre Brest", location = "Brest", price = Just "750 €", url = "https://www.leboncoin.fr/locations/1450255216.htm?ca=6_s"} - , Ad {name = "Brest Base Navale/porte Caffa - possible meublé", location = "Brest", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1433862279.htm?ca=6_s"} - , Ad {name = "Appartement Rennes", location = "Rennes", price = Just "390 €", url = "https://www.leboncoin.fr/locations/1450254830.htm?ca=6_s"} - , Ad {name = "Location Appartement Villejean", location = "Rennes", price = Just "400 €", url = "https://www.leboncoin.fr/locations/1450253542.htm?ca=6_s"} - , Ad {name = "Maison de bourg 3 chambres Bédée", location = "Bédée", price = Just "570 €", url = "https://www.leboncoin.fr/locations/1450252631.htm?ca=6_s"} + [ Ad {name = "Appartement libre de suite", location = "Meaux 77100", price = Just "870 €", url = "https:/locations/1666147031.htm/"} + , Ad {name = "Appartement 2 pièces aux Clayes sous Bois", location = "Les Clayes-sous-Bois 78340", price = Just "790 €", url = "https:/locations/1669740131.htm/"} + , Ad {name = "APPARTEMENT T2 - 33 m\178 - MONTROUGE (92)", location = "Montrouge 92120", price = Just "960 €", url = "https:/locations/1669731506.htm/"} + , Ad {name = "2 chambres à louer / Sèvres (92) proche Paris", location = "Sèvres 92310", price = Just "490 €", url = "https:/locations/1665328647.htm/"} + , Ad {name = "Location Appartement Montreuil", location = "Montreuil 93100", price = Just "970 €", url = "https:/locations/1669739489.htm/"} + , Ad {name = "Chambre pour étudiante dans appartement Cergy préf", location = "Cergy 95000", price = Just "480 €", url = "https:/locations/1669738832.htm/"} + , Ad {name = "Transporteur déménagement", location = "Paris 75019", price = Just "1 €", url = "https:/locations/1669738226.htm/"} + , Ad {name = "Loue appartement", location = "Condécourt 95450", price = Just "750 €", url = "https:/locations/1669737696.htm/"} + , Ad {name = "Place de parking VERSAILLES RIVE DROITE", location = "Versailles 78000", price = Just "70 €", url = "https:/locations/1669737014.htm/"} + , Ad {name = "Recherche chambre à louer", location = "Lognes 77185", price = Just "300 €", url = "https:/locations/1669737144.htm/"} + , Ad {name = "Appartement 2 pièce splendide 36m2 Paris 13", location = "Paris 75013", price = Just "910 €", url = "https:/locations/1669616026.htm/"} + , Ad {name = "Place de parking sécurisée", location = "Issy-les-Moulineaux 92130", price = Just "100 €", url = "https:/locations/1666255917.htm/"} + , Ad {name = "2 pièces 35m2 meublé 800 Euro(s) CC 8 mois max", location = "Argenteuil 95100", price = Just "800 €", url = "https:/locations/1669735875.htm/"} + , Ad {name = "Parking à louer rue st maur", location = "Paris 75011", price = Just "108 €", url = "https:/locations/1657100196.htm/"} + , Ad {name = "Box 13m2 securisé", location = "Bagnolet 93170", price = Just "95 €", url = "https:/locations/1669735007.htm/"} + , Ad {name = "Chambre en rez de chaussée", location = "Maisons-Laffitte 78600", price = Just "425 €", url = "https:/locations/1669734792.htm/"} + , Ad {name = "A louer maison f4", location = "Champagne-sur-Oise 95660", price = Just "1 350 €", url = "https:/locations/1669734636.htm/"} + , Ad {name = "2 pièces à Paris 20ème 36m2 Libre de suite", location = "Paris 75020", price = Just "950 €", url = "https:/locations/1669240126.htm/"} + , Ad {name = "Loue box garage", location = "Les Clayes-sous-Bois 78340", price = Just "130 €", url = "https:/locations/1669733972.htm/"} + , Ad {name = "Mets en sous location F2 dans le récents", location = "Créteil 94000", price = Just "980 €", url = "https:/locations/1669733841.htm/"} + , Ad {name = "Parking à 5mn de l'aéroport chez particulier", location = "Orly 94310", price = Just "5 €", url = "https:/locations/1669733667.htm/"} + , Ad {name = "2 pieces gare de l est", location = "Paris 75010", price = Just "1 015 €", url = "https:/locations/1669619541.htm/"} + , Ad {name = "Chambre meublée pr étudiant saison univ2019-2020", location = "Saint-Ouen-l'Aumône 95310", price = Just "430 €", url = "https:/locations/1669730619.htm/"} + , Ad {name = "Location studio à Levallois", location = "Levallois-Perret 92300", price = Just "700 €", url = "https:/locations/1669729351.htm/"} + , Ad {name = "Coloc à 3 val de fontenay recherche femme", location = "Fontenay-sous-Bois 94120", price = Just "500 €", url = "https:/locations/1669729707.htm/"} + , Ad {name = "Cave cimenté et seche dans résidence récente", location = "Pantin 93500", price = Just "70 €", url = "https:/locations/1669729874.htm/"} + , Ad {name = "bel appartement lumineux avec jardin", location = "Corbeil-Essonnes 91100", price = Just "850 €", url = "https:/locations/1669729645.htm/"} + , Ad {name = "Pavillon", location = "Igny 91430", price = Just "1 500 €", url = "https:/locations/1669627532.htm/"} + , Ad {name = "Parking à louer rue de Tocqueville 75017", location = "Paris 75017", price = Just "170 €", url = "https:/locations/1669728766.htm/"} + , Ad {name = "Studio duplex", location = "Montlhéry 91310", price = Just "660 €", url = "https:/locations/1669728747.htm/"} + , Ad {name = "Appartement F2 à Bois D'Arcy", location = "Bois-d'Arcy 78390", price = Just "730 €", url = "https:/locations/1669728345.htm/"} + , Ad {name = "maison 2 pièces 50 m2", location = "Epinay-sur-Seine 93800", price = Just "800 €", url = "https:/locations/1669728424.htm/"} + , Ad {name = "Appartement 3 pièces 80m\178", location = "Brunoy 91800", price = Just "1 242 €", url = "https:/locations/1639808089.htm/"} + , Ad {name = "Location appartement refait à neuf proche Paris", location = "Montreuil 93100", price = Just "900 €", url = "https:/locations/1669727321.htm/"} + , Ad {name = "Location Studio Photo Video", location = "Ivry-sur-Seine 94200", price = Just "350 €", url = "https:/locations/1669727197.htm/"} + , Ad {name = "Maison avec jardinet", location = "Champagne-sur-Seine 77430", price = Nothing, url = "https:/locations/1667510230.htm/"} + , Ad {name = "Parking proche Place Gambetta Paris 20", location = "Paris 75020", price = Nothing, url = "https:/locations/1640071173.htm/"} + , Ad {name = "Appt 80m2.3/4 pièces.75013 limite 75005", location = "Paris 75005", price = Nothing, url = "https:/locations/1665224562.htm/"} ] ouestFrance :: [Ad] diff --git a/src/test/haskell/Main.hs b/src/test/haskell/Main.hs index a8cfae9..ba6d466 100644 --- a/src/test/haskell/Main.hs +++ b/src/test/haskell/Main.hs @@ -1,16 +1,19 @@ -import Data.Maybe (catMaybes) -import qualified Data.Text.IO as T +import Data.Maybe (catMaybes) +import qualified Data.Text.IO as T +import qualified Network.HTTP.Conduit as H import Test.Hspec import qualified Ads import qualified FetchAd -import Model.Ad (Ad (..)) -import qualified Parser.LeboncoinParser as LeboncoinParser -import qualified Parser.OuestFranceParser as OuestFranceParser -import qualified Parser.SeLogerParser as SeLogerParser +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 + manager <- H.newManager H.tlsManagerSettings + hspec $ do describe "LeboncoinParser" $ do @@ -22,34 +25,36 @@ main = do LeboncoinParser.parse ads `shouldBe` Ads.leboncoin it "should parse ads from remote page" $ do - ads <- FetchAd.leboncoin ["https://www.leboncoin.fr/locations/offres/ile_de_france/?th=1"] - checkAds ads - - describe "OuestFranceParser" $ do - - it "should parse no results from empty string" $ do - OuestFranceParser.parse "" `shouldBe` [] - - it "should parse ads from page" $ do - rawOuestFranceAds <- T.readFile "src/test/resources/ouestFrance.html" - OuestFranceParser.parse rawOuestFranceAds `shouldBe` Ads.ouestFrance - - it "should parse ads from remote page" $ do - ads <- FetchAd.ouestFrance ["https://www.ouestfrance-immo.com/louer/appartement/rennes-35-35000/"] + ads <- FetchAd.leboncoin + manager + ["https://www.leboncoin.fr/annonces/offres/ile_de_france/"] checkAds ads - describe "SeLogerParser" $ do - - it "should parse no results from empty string" $ do - SeLogerParser.parse "" `shouldBe` [] - - it "should parse ads from page" $ do - ads <- T.readFile "src/test/resources/seLoger.html" - SeLogerParser.parse ads `shouldBe` Ads.seLoger - - it "should parse ads from remote page" $ do - ads <- FetchAd.seLoger ["https://www.seloger.com/list.htm?tri=initial&idtypebien=2,1&idtt=2,5&naturebien=1,2,4&ci=690123"] - checkAds ads + -- describe "OuestFranceParser" $ do + -- + -- it "should parse no results from empty string" $ do + -- OuestFranceParser.parse "" `shouldBe` [] + -- + -- it "should parse ads from page" $ do + -- rawOuestFranceAds <- T.readFile "src/test/resources/ouestFrance.html" + -- OuestFranceParser.parse rawOuestFranceAds `shouldBe` Ads.ouestFrance + -- + -- it "should parse ads from remote page" $ do + -- ads <- FetchAd.ouestFrance ["https://www.ouestfrance-immo.com/louer/appartement/rennes-35-35000/"] + -- checkAds ads + -- + -- describe "SeLogerParser" $ do + -- + -- it "should parse no results from empty string" $ do + -- SeLogerParser.parse "" `shouldBe` [] + -- + -- it "should parse ads from page" $ do + -- ads <- T.readFile "src/test/resources/seLoger.html" + -- SeLogerParser.parse ads `shouldBe` Ads.seLoger + -- + -- it "should parse ads from remote page" $ do + -- ads <- FetchAd.seLoger ["https://www.seloger.com/list.htm?tri=initial&idtypebien=2,1&idtt=2,5&naturebien=1,2,4&ci=690123"] + -- checkAds ads checkAds :: [Ad] -> IO () checkAds ads = do |