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
|
module Text.Atom.Tests
( atomTests
) where
import Prelude.Compat
import Data.Maybe (isJust)
import Test.Framework (Test, mutuallyExclusive, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit (Assertion, assertBool)
import Text.XML
import Text.Atom.Feed (TextContent(TextString), entryLinks, nullEntry, nullLink)
import Text.Feed.Export (xmlFeed)
import Text.Feed.Import (parseFeedFromFile)
import Text.Feed.Query
import Text.Feed.Types
import Text.RSS.Utils
import Paths_feed
atomTests :: Test
atomTests =
testGroup
"Text.Atom"
[mutuallyExclusive $ testGroup "Atom" [testFullAtomParse, testAtomAlternate]]
testFullAtomParse :: Test
testFullAtomParse = testCase "parse a complete atom file" testAtom
where
testAtom :: Assertion
testAtom = do
contents <- parseFeedFromFile =<< getDataFileName "tests/files/atom.xml"
let res = fmap (renderText def) . (>>= elementToDoc) . fmap xmlFeed $ contents
assertBool "Atom Parsing" $ isJust res
testAtomAlternate :: Test
testAtomAlternate = testCase "*unspecified* link relation means 'alternate'" testAlt
where
testAlt :: Assertion
testAlt =
let nullent = nullEntry "" (TextString "") ""
item = AtomItem nullent {entryLinks = [nullLink ""]}
in assertBool "unspecified means alternate" $ isJust $ getItemLink item
|