X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FHeartbeat.hs;h=89b91adb4605a35a1b6203c0ec2d578f0488b154;hb=refs%2Ftags%2F0.0.5;hp=588c75c6a54006f14dc1185bc18ac7f3f7087f7c;hpb=4cdcdbe593c30f6434a25896951a1a4dfcc2b1ca;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/Heartbeat.hs b/src/TSN/XML/Heartbeat.hs index 588c75c..89b91ad 100644 --- a/src/TSN/XML/Heartbeat.hs +++ b/src/TSN/XML/Heartbeat.hs @@ -3,8 +3,10 @@ -- | Handle documents defined by Heartbeat.dtd. -- module TSN.XML.Heartbeat ( - heartbeat_tests, - verify ) + dtd, + verify, + -- * Tests + heartbeat_tests ) where -- System imports. @@ -14,7 +16,6 @@ import Test.Tasty.HUnit ( (@?=), testCase ) import Text.XML.HXT.Core ( PU, unpickleDoc, - XmlPickler(..), XmlTree, xpTriple, xpElem, @@ -27,8 +28,14 @@ import TSN.DbImport ( ImportResult(..) ) import Xml ( pickle_unpickle, unpickleable ) +-- | The DTD to which this module corresponds. +-- +dtd :: String +dtd = "Heartbeat.dtd" + -- | The data structure that holds the XML representation of a -- Heartbeat message. +-- data Message = Message { xml_file_id :: Int, @@ -39,6 +46,7 @@ data Message = -- | A (un)pickler that turns a Heartbeat XML file into a 'Message' -- and vice-versa. +-- pickle_message :: PU Message pickle_message = xpElem "message" $ @@ -61,11 +69,15 @@ verify :: XmlTree -> IO ImportResult verify xml = do let root_element = unpickleDoc pickle_message xml return $ case root_element of - Nothing -> ImportFailed "Could not unpickle document in import_generic." + Nothing -> ImportFailed "Could not unpickle document to be verified." Just _ -> ImportSkipped "Heartbeat received. Thump." +-- +-- Tasty Tests +-- --- * Tasty Tests +-- | A list of all tests for this module. +-- heartbeat_tests :: TestTree heartbeat_tests = testGroup @@ -74,8 +86,9 @@ heartbeat_tests = test_unpickle_succeeds ] --- | Warning: succeess of this test does not mean that unpickling --- succeeded. +-- | If we unpickle something and then pickle it, we should wind up +-- with the same thing we started with. WARNING: success of this +-- test does not mean that unpickling succeeded. -- test_pickle_of_unpickle_is_identity :: TestTree test_pickle_of_unpickle_is_identity =