Commit 69989fff authored by Joris's avatar Joris

Update ouestfrance and seloger tests

parent 88a2f0c2
......@@ -26,4 +26,4 @@ parseAd tags = do
[] -> Nothing
xs -> Just $ innerText xs
url <- getTagAttribute "<a>" "href" tags
return (Ad name location price (T.concat ["https:", url]))
return (Ad name location price (T.concat ["https://www.leboncoin.fr", url]))
This diff is collapsed.
module ParserSpec (spec) where
import Data.Maybe (catMaybes)
import qualified Data.Text.IO as T
import qualified Network.Wreq.Session as Session
import Data.Maybe (catMaybes)
import qualified Data.Text.IO as T
import qualified Network.Wreq.Session as Session
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
spec :: Spec
spec = do
describe "Parser" $ do
session <- runIO Session.newSession
describe "LeBonCoin" $ do
it "should parse no results from empty string" $ do
......@@ -31,31 +32,35 @@ spec = do
["https://www.leboncoin.fr/annonces/offres/ile_de_france/"]
checkAds ads
-- describe "OuestFrance" $ 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 "SeLoger" $ 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 "OuestFrance" $ 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
session
["https://www.ouestfrance-immo.com/louer/appartement/rennes-35-35000/"]
checkAds ads
describe "SeLoger" $ 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
session
["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
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
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