summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
746bca1)
Add a News test case with an empty SMS element.
xml_url :: Maybe String,
xml_teams :: [NewsTeam],
xml_locations :: [Location],
xml_url :: Maybe String,
xml_teams :: [NewsTeam],
xml_locations :: [Location],
+ xml_sms :: Maybe String,
xml_editor :: Maybe String,
xml_text :: Maybe String, -- Text and continue seem to show up in pairs,
xml_continue :: Maybe String, -- either both present or both missing.
xml_editor :: Maybe String,
xml_text :: Maybe String, -- Text and continue seem to show up in pairs,
xml_continue :: Maybe String, -- either both present or both missing.
db_mid :: MsgId,
db_sport :: String,
db_url :: Maybe String,
db_mid :: MsgId,
db_sport :: String,
db_url :: Maybe String,
+ db_sms :: Maybe String,
db_editor :: Maybe String,
db_text :: Maybe String,
db_continue :: Maybe String,
db_editor :: Maybe String,
db_text :: Maybe String,
db_continue :: Maybe String,
(xpElem "url" $ xpOption xpText)
(xpList pickle_news_team)
(xpList pickle_location)
(xpElem "url" $ xpOption xpText)
(xpList pickle_news_team)
(xpList pickle_location)
+ (xpElem "SMS" $ xpOption xpText)
(xpOption (xpElem "Editor" xpText))
(xpOption (xpElem "text" xpText))
pickle_continue
(xpOption (xpElem "Editor" xpText))
(xpOption (xpElem "text" xpText))
pickle_continue
"test/xml/newsxml.xml",
check "pickle composed with unpickle is the identity (with Editor)"
"test/xml/newsxml.xml",
check "pickle composed with unpickle is the identity (with Editor)"
- "test/xml/newsxml-with-editor.xml" ]
+ "test/xml/newsxml-with-editor.xml",
+
+ check "pickle composed with unpickle is the identity (empty SMS)"
+ "test/xml/newsxml-empty-sms.xml" ]
where
check desc path = testCase desc $ do
(expected, actual) <- pickle_unpickle pickle_message path
where
check desc path = testCase desc $ do
(expected, actual) <- pickle_unpickle pickle_message path
"test/xml/newsxml.xml",
check "unpickling succeeds (with Editor)"
"test/xml/newsxml.xml",
check "unpickling succeeds (with Editor)"
- "test/xml/newsxml-with-editor.xml" ]
+ "test/xml/newsxml-with-editor.xml",
+
+ check "unpickling succeeds (empty SMS)"
+ "test/xml/newsxml-empty-sms.xml" ]
where
check desc path = testCase desc $ do
actual <- unpickleable path pickle_message
where
check desc path = testCase desc $ do
actual <- unpickleable path pickle_message
[ check "deleting news deletes its children"
"test/xml/newsxml.xml"
4 -- 2 news_teams and 2 news_locations that should remain.
[ check "deleting news deletes its children"
"test/xml/newsxml.xml"
4 -- 2 news_teams and 2 news_locations that should remain.
+ ,
+ check "deleting news deletes its children (empty SMS)"
+ "test/xml/newsxml-empty-sms.xml"
+ 4 -- 2 news_teams and 2 news_locations
]
where
check desc path expected = testCase desc $ do
]
where
check desc path expected = testCase desc $ do
# and a newsxml that aren't really supposed to import.
find ./test/xml -maxdepth 1 -name '*.xml' | wc -l
>>>
# and a newsxml that aren't really supposed to import.
find ./test/xml -maxdepth 1 -name '*.xml' | wc -l
>>>
>>>= 0
# Run the imports again; we should get complaints about the duplicate
>>>= 0
# Run the imports again; we should get complaints about the duplicate
# occurrences of the string 'ERROR'.
./dist/build/htsn-import/htsn-import -c 'shelltest.sqlite3' test/xml/*.xml 2>&1 | grep ERROR | wc -l
>>>
# occurrences of the string 'ERROR'.
./dist/build/htsn-import/htsn-import -c 'shelltest.sqlite3' test/xml/*.xml 2>&1 | grep ERROR | wc -l
>>>
>>>= 0
# Finally, clean up after ourselves.
>>>= 0
# Finally, clean up after ourselves.
--- /dev/null
+<?xml version="1.0" standalone="no" ?>\r<!DOCTYPE message PUBLIC "-//TSN//DTD News 1.0/EN" "newsxml.dtd">\r<message>\r<XML_File_ID>21904559</XML_File_ID>\r<heading>AFN;UTAH-UCLA</heading>\r<msg_id EventId="">0</msg_id>\r<category>News</category>\r<sport>CFOOT</sport>\r<url></url>\r<team>UCLA</team>\r<team>UTAH</team>\r<location>\r<city>U-C-L-A</city>\r<state>CA</state>\r<country>USA</country>\r</location>\r<location>\r<city>Utah</city>\r<state>UT</state>\r<country>USA</country>\r</location>\r<SMS></SMS>\r<text>\r Pasadena, CA (SportsNetwork.com) -\r</text>\r<continue>\r</continue>\r<time_stamp> October 1, 2014, at 11:11 AM ET </time_stamp>\r</message>\r
\ No newline at end of file