]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/SportInfo.hs
Add SportInfo support for MLB_Pitching_Strike_Outs_Leaders.dtd.
[dead/htsn-import.git] / src / TSN / XML / SportInfo.hs
index d47f1c1ba88ef6ebd2be2c0659b8bdab9e7630ee..42bdcfce75bf2a2bf3fb9f4508b66d61f5ad027d 100644 (file)
@@ -18,7 +18,7 @@
 module TSN.XML.SportInfo (
   dtds,
   parse_xml,
-  sportinfo_tests,
+  sport_info_tests,
   -- * WARNING: these are private but exported to silence warnings
   SportInfoConstructor(..) )
 where
@@ -71,82 +71,82 @@ dtds =
     "CBASK_AssistsXML.dtd",
     "Cbask_Awards_XML.dtd",
     "CBASK_BlocksXML.dtd",
-    "Cbask_Conf_Standings_XML.dtd", -- no dtd
-    "Cbask_DivII_III_Indv_Stats_XML.dtd", -- no dtd
-    "Cbask_DivII_Team_Stats_XML.dtd", -- no dtd
-    "Cbask_DivIII_Team_Stats_XML.dtd", -- no dtd
-    "CBASK_FGPctXML.dtd", -- no dtd
-    "CBASK_FoulsXML.dtd", -- no dtd
-    "CBASK_FTPctXML.dtd", -- no dtd
+    "Cbask_Conf_Standings_XML.dtd",
+    "Cbask_DivII_III_Indv_Stats_XML.dtd",
+    "Cbask_DivII_Team_Stats_XML.dtd",
+    "Cbask_DivIII_Team_Stats_XML.dtd",
+    "CBASK_FGPctXML.dtd",
+    "CBASK_FoulsXML.dtd",
+    "CBASK_FTPctXML.dtd",
     "Cbask_Indv_No_Avg_XML.dtd", -- no dtd
-    "Cbask_Indv_Scoring_XML.dtd", -- no dtd
+    "Cbask_Indv_Scoring_XML.dtd",
     "Cbask_Indv_Shooting_XML.dtd", -- no dtd
-    "CBASK_MinutesXML.dtd", -- no dtd
-    "Cbask_Polls_XML.dtd", -- no dtd
-    "CBASK_ReboundsXML.dtd", -- no dtd
-    "CBASK_ScoringLeadersXML.dtd", -- no dtd
+    "CBASK_MinutesXML.dtd",
+    "Cbask_Polls_XML.dtd",
+    "CBASK_ReboundsXML.dtd",
+    "CBASK_ScoringLeadersXML.dtd",
     "CBASK_StealsXML.dtd", -- no dtd
     "Cbask_Team_Scoring_Rebound_Margin_XML.dtd", -- no dtd
     "Cbask_Team_Scoring_XML.dtd", -- no dtd
     "Cbask_Team_Shooting_Pct_XML.dtd", -- no dtd
-    "Cbask_Team_ThreePT_Made_XML.dtd", -- no dtd
-    "Cbask_Team_ThreePT_PCT_XML.dtd", -- no dtd
-    "Cbask_Team_Win_Pct_XML.dtd", -- no dtd
-    "Cbask_Top_Twenty_Five_XML.dtd", -- no dtd
-    "CBASK_TopTwentyFiveResult_XML.dtd", -- no dtd
-    "Cbask_Tourn_Awards_XML.dtd", -- no dtd
-    "Cbask_Tourn_Champs_XML.dtd", -- no dtd
-    "Cbask_Tourn_Indiv_XML.dtd", -- no dtd
-    "Cbask_Tourn_Leaders_XML.dtd", -- no dtd
-    "Cbask_Tourn_MVP_XML.dtd", -- no dtd
-    "Cbask_Tourn_Records_XML.dtd", -- no dtd
-    "LeagueScheduleXML.dtd", -- no dtd
-    "minorscoresxml.dtd", -- no dtd
-    "Minor_Baseball_League_Leaders_XML.dtd", -- no dtd
-    "Minor_Baseball_Standings_XML.dtd", -- no dtd
-    "Minor_Baseball_Transactions_XML.dtd", -- no dtd
-    "mlbbattingavgxml.dtd", -- no dtd
-    "mlbdoublesleadersxml.dtd", -- no dtd
-    "MLBGamesPlayedXML.dtd", -- no dtd
-    "MLBGIDPXML.dtd", -- no dtd
-    "MLBHitByPitchXML.dtd", -- no dtd
-    "mlbhitsleadersxml.dtd", -- no dtd
-    "mlbhomerunsxml.dtd", -- no dtd
-    "MLBHRFreqXML.dtd", -- no dtd
-    "MLBIntWalksXML.dtd", -- no dtd
-    "MLBKORateXML.dtd", -- no dtd
-    "mlbonbasepctxml.dtd", -- no dtd
-    "MLBOPSXML.dtd", -- no dtd
-    "MLBPlateAppsXML.dtd", -- no dtd
-    "mlbrbisxml.dtd", -- no dtd
-    "mlbrunsleadersxml.dtd", -- no dtd
-    "MLBSacFliesXML.dtd", -- no dtd
-    "MLBSacrificesXML.dtd", -- no dtd
-    "MLBSBSuccessXML.dtd", -- no dtd
-    "mlbsluggingpctxml.dtd", -- no dtd
-    "mlbstandxml.dtd", -- no dtd
-    "mlbstandxml_preseason.dtd", -- no dtd
-    "mlbstolenbasexml.dtd", -- no dtd
-    "mlbtotalbasesleadersxml.dtd", -- no dtd
-    "mlbtriplesleadersxml.dtd", -- no dtd
-    "MLBWalkRateXML.dtd", -- no dtd
-    "mlbwalksleadersxml.dtd", -- no dtd
-    "MLBXtraBaseHitsXML.dtd", -- no dtd
-    "MLB_ERA_Leaders.dtd", -- no dtd
-    "MLB_Fielding_XML.dtd", -- no dtd
-    "MLB_Pitching_Appearances_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Balks_Leaders.dtd", -- no dtd
-    "MLB_Pitching_CG_Leaders.dtd", -- no dtd
-    "MLB_Pitching_ER_Allowed_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Hits_Allowed_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Hit_Batters_Leaders.dtd", -- no dtd
-    "MLB_Pitching_HR_Allowed_Leaders.dtd", -- no dtd
-    "MLB_Pitching_IP_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Runs_Allowed_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Saves_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Shut_Outs_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Starts_Leaders.dtd", -- no dtd
-    "MLB_Pitching_Strike_Outs_Leaders.dtd", -- no dtd
+    "Cbask_Team_ThreePT_Made_XML.dtd",
+    "Cbask_Team_ThreePT_PCT_XML.dtd",
+    "Cbask_Team_Win_Pct_XML.dtd",
+    "Cbask_Top_Twenty_Five_XML.dtd",
+    "CBASK_TopTwentyFiveResult_XML.dtd",
+    "Cbask_Tourn_Awards_XML.dtd",
+    "Cbask_Tourn_Champs_XML.dtd",
+    "Cbask_Tourn_Indiv_XML.dtd",
+    "Cbask_Tourn_Leaders_XML.dtd",
+    "Cbask_Tourn_MVP_XML.dtd",
+    "Cbask_Tourn_Records_XML.dtd",
+    "LeagueScheduleXML.dtd",
+    "minorscoresxml.dtd",
+    "Minor_Baseball_League_Leaders_XML.dtd",
+    "Minor_Baseball_Standings_XML.dtd",
+    "Minor_Baseball_Transactions_XML.dtd",
+    "mlbbattingavgxml.dtd",
+    "mlbdoublesleadersxml.dtd",
+    "MLBGamesPlayedXML.dtd",
+    "MLBGIDPXML.dtd",
+    "MLBHitByPitchXML.dtd",
+    "mlbhitsleadersxml.dtd",
+    "mlbhomerunsxml.dtd",
+    "MLBHRFreqXML.dtd",
+    "MLBIntWalksXML.dtd",
+    "MLBKORateXML.dtd",
+    "mlbonbasepctxml.dtd",
+    "MLBOPSXML.dtd",
+    "MLBPlateAppsXML.dtd",
+    "mlbrbisxml.dtd",
+    "mlbrunsleadersxml.dtd",
+    "MLBSacFliesXML.dtd",
+    "MLBSacrificesXML.dtd",
+    "MLBSBSuccessXML.dtd",
+    "mlbsluggingpctxml.dtd",
+    "mlbstandxml.dtd",
+    "mlbstandxml_preseason.dtd",
+    "mlbstolenbasexml.dtd",
+    "mlbtotalbasesleadersxml.dtd",
+    "mlbtriplesleadersxml.dtd",
+    "MLBWalkRateXML.dtd",
+    "mlbwalksleadersxml.dtd",
+    "MLBXtraBaseHitsXML.dtd",
+    "MLB_ERA_Leaders.dtd",
+    "MLB_Fielding_XML.dtd",
+    "MLB_Pitching_Appearances_Leaders.dtd",
+    "MLB_Pitching_Balks_Leaders.dtd",
+    "MLB_Pitching_CG_Leaders.dtd",
+    "MLB_Pitching_ER_Allowed_Leaders.dtd",
+    "MLB_Pitching_Hits_Allowed_Leaders.dtd",
+    "MLB_Pitching_Hit_Batters_Leaders.dtd",
+    "MLB_Pitching_HR_Allowed_Leaders.dtd",
+    "MLB_Pitching_IP_Leaders.dtd",
+    "MLB_Pitching_Runs_Allowed_Leaders.dtd",
+    "MLB_Pitching_Saves_Leaders.dtd",
+    "MLB_Pitching_Shut_Outs_Leaders.dtd",
+    "MLB_Pitching_Starts_Leaders.dtd",
+    "MLB_Pitching_Strike_Outs_Leaders.dtd",
     "MLB_Pitching_Walks_Leaders.dtd", -- no dtd
     "MLB_Pitching_WHIP_Leaders.dtd", -- no dtd
     "MLB_Pitching_Wild_Pitches_Leaders.dtd", -- no dtd
@@ -304,8 +304,8 @@ mkPersist tsn_codegen_config [groundhog|
 
 -- | A list of all tests for this module.
 --
-sportinfo_tests :: TestTree
-sportinfo_tests =
+sport_info_tests :: TestTree
+sport_info_tests =
   testGroup
     "SportInfo tests"
     [ test_parse_xml_succeeds,
@@ -314,22 +314,92 @@ sportinfo_tests =
 
 -- | Sample XML documents for SportInfo types.
 --
-sportinfo_test_files :: [FilePath]
-sportinfo_test_files =
-  [ "test/xml/sportinfo/CBASK_3PPctXML.xml",
-    "test/xml/sportinfo/Cbask_All_Tourn_Teams_XML.xml",
-    "test/xml/sportinfo/CBASK_AssistsXML.xml",
-    "test/xml/sportinfo/Cbask_Awards_XML.xml",
-    "test/xml/sportinfo/CBASK_BlocksXML.xml"
+sport_info_test_files :: [FilePath]
+sport_info_test_files =
+  map ("test/xml/sportinfo/" ++) [
+    "CBASK_3PPctXML.xml",
+    "Cbask_All_Tourn_Teams_XML.xml",
+    "CBASK_AssistsXML.xml",
+    "Cbask_Awards_XML.xml",
+    "CBASK_BlocksXML.xml",
+    "Cbask_Conf_Standings_XML.xml",
+    "Cbask_DivII_III_Indv_Stats_XML.xml",
+    "Cbask_DivII_Team_Stats_XML.xml",
+    "Cbask_DivIII_Team_Stats_XML.xml",
+    "CBASK_FGPctXML.xml",
+    "CBASK_FoulsXML.xml",
+    "CBASK_FTPctXML.xml",
+    "Cbask_Indv_Scoring_XML.xml",
+    "CBASK_MinutesXML.xml",
+    "Cbask_Polls_XML.xml",
+    "CBASK_ReboundsXML.xml",
+    "CBASK_ScoringLeadersXML.xml",
+    "Cbask_Team_ThreePT_Made_XML.xml",
+    "Cbask_Team_ThreePT_PCT_XML.xml",
+    "Cbask_Team_Win_Pct_XML.xml",
+    "Cbask_Top_Twenty_Five_XML.xml",
+    "CBASK_TopTwentyFiveResult_XML.xml",
+    "Cbask_Tourn_Awards_XML.xml",
+    "Cbask_Tourn_Champs_XML.xml",
+    "Cbask_Tourn_Indiv_XML.xml",
+    "Cbask_Tourn_Leaders_XML.xml",
+    "Cbask_Tourn_MVP_XML.xml",
+    "Cbask_Tourn_Records_XML.xml",
+    "LeagueScheduleXML.xml",
+    "minorscoresxml.xml",
+    "Minor_Baseball_League_Leaders_XML.xml",
+    "Minor_Baseball_Standings_XML.xml",
+    "Minor_Baseball_Transactions_XML.xml",
+    "mlbbattingavgxml.xml",
+    "mlbdoublesleadersxml.xml",
+    "MLBGamesPlayedXML.xml",
+    "MLBGIDPXML.xml",
+    "MLBHitByPitchXML.xml",
+    "mlbhitsleadersxml.xml",
+    "mlbhomerunsxml.xml",
+    "MLBHRFreqXML.xml",
+    "MLBIntWalksXML.xml",
+    "MLBKORateXML.xml",
+    "mlbonbasepctxml.xml",
+    "MLBOPSXML.xml",
+    "MLBPlateAppsXML.xml",
+    "mlbrbisxml.xml",
+    "mlbrunsleadersxml.xml",
+    "MLBSacFliesXML.xml",
+    "MLBSacrificesXML.xml",
+    "MLBSBSuccessXML.xml",
+    "mlbsluggingpctxml.xml",
+    "mlbstandxml.xml",
+    "mlbstandxml_preseason.xml",
+    "mlbstolenbasexml.xml",
+    "mlbtotalbasesleadersxml.xml",
+    "mlbtriplesleadersxml.xml",
+    "MLBWalkRateXML.xml",
+    "mlbwalksleadersxml.xml",
+    "MLBXtraBaseHitsXML.xml",
+    "MLB_ERA_Leaders.xml",
+    "MLB_Pitching_Appearances_Leaders.xml",
+    "MLB_Pitching_Balks_Leaders.xml",
+    "MLB_Pitching_CG_Leaders.xml",
+    "MLB_Pitching_ER_Allowed_Leaders.xml",
+    "MLB_Pitching_Hits_Allowed_Leaders.xml",
+    "MLB_Pitching_Hit_Batters_Leaders.xml",
+    "MLB_Pitching_HR_Allowed_Leaders.xml",
+    "MLB_Pitching_IP_Leaders.xml",
+    "MLB_Pitching_Runs_Allowed_Leaders.xml",
+    "MLB_Pitching_Saves_Leaders.xml",
+    "MLB_Pitching_Shut_Outs_Leaders.xml",
+    "MLB_Pitching_Starts_Leaders.xml",
+    "MLB_Pitching_Strike_Outs_Leaders.xml"
   ]
 
 
 
--- | Make sure we can parse every element of 'sportinfo_test_files'.
+-- | Make sure we can parse every element of 'sport_info_test_files'.
 --
 test_parse_xml_succeeds :: TestTree
 test_parse_xml_succeeds =
-  testGroup "parse_xml" $ map check sportinfo_test_files
+  testGroup "parse_xml" $ map check sport_info_test_files
   where
     check t = testCase t $ do
       x <- unsafe_read_document t
@@ -341,14 +411,14 @@ test_parse_xml_succeeds =
       actual @?= expected
 
 
--- | Ensure that each element of 'sportinfo_test_files' can be imported
+-- | Ensure that each element of 'sport_info_test_files' can be imported
 --   by counting the total number of database records (after
 --   importing) and comparing it against the length of
---   'sportinfo_test_files'.
+--   'sport_info_test_files'.
 --
 test_dbimport_succeeds :: TestTree
 test_dbimport_succeeds = testCase "dbimport succeeds" $ do
-  xmltrees <- mapM unsafe_read_document sportinfo_test_files
+  xmltrees <- mapM unsafe_read_document sport_info_test_files
   let msgs = rights $ map (parse_xml "dummy") xmltrees
   actual <- withSqliteConn ":memory:" $ runDbConn $ do
                 runMigration silentMigrationLogger $ do
@@ -358,4 +428,4 @@ test_dbimport_succeeds = testCase "dbimport succeeds" $ do
 
   actual @?= expected
   where
-    expected = length sportinfo_test_files
+    expected = length sport_info_test_files