aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2017-01-13 16:49:43 +0100
committerFélix Sipma <felix.sipma@no-log.org>2017-01-13 16:50:04 +0100
commitd9cd01def7234e5a9315c75875f6115cacd2327f (patch)
tree6e9ff02e04cd6e12e15dd7263fb3e0afd447b8d0
parent77b4d727fde62ad82db15ab8c76e1c62989d9a96 (diff)
add RSS1 feed parsing test
-rw-r--r--test/Spec.hs81
-rw-r--r--test/files/rss10.xml45
2 files changed, 124 insertions, 2 deletions
diff --git a/test/Spec.hs b/test/Spec.hs
index f742a4f..3f431da 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -7,6 +7,7 @@ import Test.Hspec hiding (shouldBe)
import Test.Hspec.Expectations.Pretty (shouldBe)
import Parse (cursorFromFile)
import Atom (parseAtomFeed)
+import RSS1 (parseRSS1Feed)
import Control.Monad.Logger (runStderrLoggingT)
import Types
@@ -15,11 +16,15 @@ main :: IO ()
main = hspec spec
spec :: SpecWith ()
-spec = describe "Feed parsing" $
- it "can parse an atom feed" $ do
+spec = describe "Feed parsing" $ do
+ it "can parse an Atom feed" $ do
c <- liftIO $ cursorFromFile "test/files/atom.xml"
mf <- runStderrLoggingT (parseAtomFeed "http://example.com" c)
mf `shouldBe` Just atomFeed
+ it "can parse an RSS1 feed" $ do
+ c <- liftIO $ cursorFromFile "test/files/rss10.xml"
+ mf <- runStderrLoggingT (parseRSS1Feed "http://example.com" c)
+ mf `shouldBe` Just rss1Feed
atomFeed = Feed {
feedId = "http://example.com",
@@ -84,3 +89,75 @@ atomFeed = Feed {
}
]
}
+
+rss1Feed = Feed {
+ feedId = "http://example.com",
+ feedTitle = "Planet Example",
+ feedUpdated = read "2015-07-31 16:04:00 UTC",
+ feedAuthors = [],
+ feedLinks = [
+ Link {
+ linkHref = "http://planet.example.com/",
+ linkRel = Nothing
+ }
+ ],
+ feedEntries = [
+ Entry {
+ entryId = "",
+ entryTitle = "Blabla v0.3",
+ entryUpdated = read "2015-07-31 16:04:00 UTC",
+ entryAuthors = [
+ Person {
+ personName = "Example Author",
+ personURI = Nothing,
+ personEmail = Nothing
+ }
+ ],
+ entryContent = Just (HtmlContent "<p>Blablabla</p>"),
+ entryLinks = [
+ Link {
+ linkHref = "http://blog.example.com/2015/07/31#Bla-release",
+ linkRel = Nothing
+ }
+ ]
+ },
+ Entry {
+ entryId = "",
+ entryTitle = "Another Example",
+ entryUpdated = read "2015-07-31 14:45:30 UTC",
+ entryAuthors = [
+ Person {
+ personName = "Example Author 2",
+ personURI = Nothing,
+ personEmail = Nothing
+ }
+ ],
+ entryContent = Just (HtmlContent "<p><This is an example</p>"),
+ entryLinks = [
+ Link {
+ linkHref = "https://example.com/2015/07/31/my-example/",
+ linkRel = Nothing
+ }
+ ]
+ },
+ Entry {
+ entryId = "",
+ entryTitle = "Example: 4",
+ entryUpdated = read "2015-07-31 07:15:18 UTC",
+ entryAuthors = [
+ Person {
+ personName = "Other Author",
+ personURI = Nothing,
+ personEmail = Nothing
+ }
+ ],
+ entryContent = Just (HtmlContent "<p>Blo</p>"),
+ entryLinks = [
+ Link {
+ linkHref = "http://blog.example.com/example-4.html",
+ linkRel = Nothing
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/files/rss10.xml b/test/files/rss10.xml
new file mode 100644
index 0000000..bcef359
--- /dev/null
+++ b/test/files/rss10.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns="http://purl.org/rss/1.0/"
+>
+<channel rdf:about="http://planet.example.com/">
+ <title>Planet Example</title>
+ <link>http://planet.example.com/</link>
+ <description>Planet Example - http://planet.example.com/</description>
+
+ <items>
+ <rdf:Seq>
+ <rdf:li rdf:resource="http://blog.example.com/2015/07/31#Bla-release"/>
+ <rdf:li rdf:resource="https://example.com/?p=3300"/>
+ <rdf:li rdf:resource="tag:blog.example.com,2015-07-31:example-4.html"/>
+ </rdf:Seq>
+ </items>
+</channel>
+
+<item rdf:about="http://blog.example.com/2015/07/31#Bla-release">
+ <title>Blabla v0.3</title>
+ <link>http://blog.example.com/2015/07/31#Bla-release</link>
+ <content:encoded>&lt;p&gt;Blablabla&lt;/p&gt;</content:encoded>
+ <dc:date>2015-07-31T16:04:00+00:00</dc:date>
+ <dc:creator>Example Author</dc:creator>
+</item>
+<item rdf:about="https://example.com/?p=3300">
+ <title>Another Example</title>
+ <link>https://example.com/2015/07/31/my-example/</link>
+ <content:encoded>&lt;p&gt;&lt;This is an example&lt;/p&gt;</content:encoded>
+ <dc:date>2015-07-31T14:45:30+00:00</dc:date>
+ <dc:creator>Example Author 2</dc:creator>
+</item>
+<item rdf:about="tag:blog.familiekainz.at,2015-07-31:duck-challenge-week-4.html">
+ <title>Example: 4</title>
+ <link>http://blog.example.com/example-4.html</link>
+ <content:encoded>&lt;p&gt;Blo&lt;/p&gt;</content:encoded>
+ <dc:date>2015-07-31T07:15:18+00:00</dc:date>
+ <dc:creator>Other Author</dc:creator>
+</item>
+
+</rdf:RDF>