blob: ba6d4660eb43961c0497e565d087c6fbc32e0ad7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
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
main :: IO ()
main = do
manager <- H.newManager H.tlsManagerSettings
hspec $ do
describe "LeboncoinParser" $ do
it "should parse no results from empty string" $ do
LeboncoinParser.parse "" `shouldBe` []
it "should parse ads from local page" $ do
ads <- T.readFile "src/test/resources/leboncoin.html"
LeboncoinParser.parse ads `shouldBe` Ads.leboncoin
it "should parse ads from remote page" $ do
ads <- FetchAd.leboncoin
manager
["https://www.leboncoin.fr/annonces/offres/ile_de_france/"]
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
length ads `shouldSatisfy` (\n -> n > 10)
(length . catMaybes . map price $ ads) `shouldSatisfy` (\n -> n > 10)
|