Permalink
Browse files

Parser output improvements.

  • Loading branch information...
1 parent 7ead97c commit e14324dd13cf6f0e36a7bece09377c82987a1f11 lb1programmer committed Oct 27, 2012
Showing with 22 additions and 2 deletions.
  1. +22 −2 tests/testParser.py
View
@@ -55,8 +55,9 @@ def checkItems(self,mediaItems):
def testParseAgriculture(self):
url = "http://itunes.apple.com/WebObjects/DZR.woa/wa/viewPodcast?cc=us&id=387961518"
text = self.o.open(url).read()
+ file('Food and Sustainable Agriculture.html','w').write(text)
parsed_html = Parser(url, "text/HTML", text)
-
+
self.assertEqual(parsed_html.Redirect, '')
self.assertEqual(parsed_html.Title, 'Food and Sustainable Agriculture')
self.assertEqual(len(parsed_html.mediaItems), 7)
@@ -70,6 +71,8 @@ def testParseGeorgeFox(self):
url = "https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/georgefox.edu.01651902695"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('Top Downloads.xml','w').write(text)
+ file('Top Downloads.html','w').write(parsed_html.HTML)
# FIXME: Maybe it could be smarter about finding the title...
self.assertEqual(parsed_html.Redirect, '')
@@ -81,6 +84,8 @@ def testMain(self):
url = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?id=27753"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('iTunesU.xml','w').write(text)
+ file('iTunesU.html','w').write(parsed_html.HTML)
# FIXME: Maybe it could be smarter about finding the title...
self.assertEqual(parsed_html.Redirect, '')
@@ -92,6 +97,8 @@ def testParseFHSU(self):
url = "http://deimos.apple.com/WebObjects/Core.woa/Browse/fhsu.edu"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('FHSU.xml','w').write(text)
+ file('FHSU.html','w').write(parsed_html.HTML)
# FIXME: Maybe it could be smarter about finding the title...
self.assertEqual(parsed_html.Redirect, '')
@@ -104,6 +111,8 @@ def testParseFHSUPresident(self):
url = "http://deimos.apple.com/WebObjects/Core.woa/Browse/fhsu.edu.1152205441"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('FHSUPres.xml','w').write(text)
+ file('FHSUPres.html','w').write(parsed_html.HTML)
# FIXME: Maybe it could be smarter about finding the title...
self.assertEqual(parsed_html.Redirect, '')
@@ -121,6 +130,8 @@ def testParseSIUC(self):
url = "http://deimos3.apple.com/WebObjects/Core.woa/Browse/siuc.edu?ignore.mscache=9669968"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('SIUC.xml','w').write(text)
+ file('SIUC.html','w').write(parsed_html.HTML)
# FIXME: Maybe it could be smarter about finding the title...
self.assertEqual(parsed_html.Redirect, '')
@@ -138,6 +149,8 @@ def testParseSJSU(self):
url = "http://deimos3.apple.com/WebObjects/Core.woa/Browse/sjsu.edu?ignore.mscache=3176353"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('SJSU.xml','w').write(text)
+ file('SJSU.html','w').write(parsed_html.HTML)
# FIXME: Maybe it could be smarter about finding the title...
self.assertEqual(parsed_html.Redirect, '')
@@ -149,6 +162,8 @@ def testParseWithTabs(self):
url = "https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/georgefox.edu.1285568794"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('Tabs.xml','w').write(text)
+ file('Tabs.html','w').write(parsed_html.HTML)
self.assertEqual(parsed_html.Redirect, '')
self.assertEqual(parsed_html.Title,
@@ -180,12 +195,15 @@ def testWebRedirect(self):
url = "http://www2.ohlone.edu/cgi-bin/itunespub/itunes_public.pl"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text)
+ file('ohlone.html','w').write(parsed_html.HTML)
assert parsed_html.Redirect.startswith('itmss://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/ohlone.edu')
def test_XML_feed(self):
url = "https://deimos.apple.com/WebObjects/Core.woa/Feed/itunes.stanford.edu-dz.11153667080.011153667082"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/xml", text)
+
+ file('iDevelopment.html','w').write(parsed_html.HTML)
self.assertEqual(parsed_html.Redirect, '')
self.assertEqual(parsed_html.Title, 'iPad and iPhone Application Development (SD)')
@@ -196,6 +214,7 @@ def testMulticorePage(self):
url = "http://itunes.apple.com/us/course/multicore-programming-primer/id495066021"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/html", text)
+ file('Multicore.html','w').write(text)
self.assertEqual(parsed_html.Redirect, '')
self.assertEqual(parsed_html.Title, 'Multicore Programming Primer')
@@ -207,7 +226,8 @@ def testDumpParsedHTML(self):
url = "http://deimos3.apple.com/WebObjects/Core.woa/Browse/georgefox.edu.8155705810.08155705816.8223066656?i=1688428005"
text = self.o.open(url).read()
parsed_html = Parser(url, "text/HTML", text).HTML
- file("parsed_test.html", "w").write(parsed_html)
+ file("gfu.html", "w").write(text)
+ file("gfu.html", "w").write(parsed_html)
self.assertTrue(parsed_html.find("<html") != -1)
self.assertTrue(parsed_html.find("<a href=") != -1)
self.assertTrue(parsed_html.find("<img src=") != -1)

0 comments on commit e14324d

Please sign in to comment.