From 9fc335c6aebfcb83b8cf6be354f169a237920ad0 Mon Sep 17 00:00:00 2001 From: John Conway Date: Thu, 9 May 2019 22:13:26 +0100 Subject: [RSS] Added Tests, fixes, rewrites --- tests/test_atom | Bin 493736 -> 493736 bytes tests/test_rss | Bin 0 -> 449976 bytes tests/test_rss.nim | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test_rss.xml | 59 +++++++++++++++++++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100755 tests/test_rss create mode 100644 tests/test_rss.nim create mode 100644 tests/test_rss.xml (limited to 'tests') diff --git a/tests/test_atom b/tests/test_atom index 6df3143..2c75d21 100755 Binary files a/tests/test_atom and b/tests/test_atom differ diff --git a/tests/test_rss b/tests/test_rss new file mode 100755 index 0000000..7521afe Binary files /dev/null and b/tests/test_rss differ diff --git a/tests/test_rss.nim b/tests/test_rss.nim new file mode 100644 index 0000000..b5dc044 --- /dev/null +++ b/tests/test_rss.nim @@ -0,0 +1,88 @@ +# This is just an example to get you started. You may wish to put all of your +# tests into a single file, or separate them into multiple `test1`, `test2` +# etc. files (better names are recommended, just make sure the name starts with +# the letter 't'). +# +# To run these tests, simply execute `nimble test`. + +import unittest + +import marshal + +import feednim +import ../src/feednim/Rss + +test "Read Valid Rss Feed": + let feed = "./tests/test_rss.xml".loadRss() + + check feed.title == "Bloggs's Planes Trains and Automobiles" + + check feed.link == "http://joe.bloggs" + + check feed.description == "About Trains, Planes, and Automobiles." + + check feed.language == "en-uk" + check feed.copyright == "Copyright Joe and Jane Bloggs" + check feed.managingEditor == "mail@joe.bloggs (Joe Bloggs)" + check feed.webMaster == "master@joe.bloggs (Joe Bloggs)" + check feed.pubDate == "Sat, 07 Sep 2002 00:00:01 GMT" + check feed.lastBuildDate == "Sat, 07 Sep 2002 00:00:01 GMT" + + var feed_categories_0:string = feed.categories[0] + var feed_categories_1:string = feed.categories[1] + var feed_categories_2:string = feed.categories[2] + check feed.categories[0].domain == "http://awesomecategories.org" + check feed_categories_0 == "Planes" + check feed_categories_1 == "Trains" + check feed_categories_2 == "Automobiles" + + check feed.generator == "Jester" + check feed.docs == "http://blogs.law.harvard.edu/tech/rss" + + check feed.cloud.domain == "rpc.sys.com" + check feed.cloud.port == "80" + check feed.cloud.path == "/RPC2" + check feed.cloud.registerProcedure == "pingMe" + check feed.cloud.protocol == "soap" + + check feed.ttl == 60 + + check feed.image.url == "http://joe.bloggs/mug.jpg" + check feed.image.title == "Bloggs's Planes Trains and Automobiles" + check feed.image.link == "http://joe.bloggs" + + check feed.rating == "AO" + + check feed.skipHours[0] == 0 + check feed.skipHours[1] == 1 + check feed.skipHours[2] == 2 + check feed.skipHours[3] == 3 + check feed.skipHours[4] == 4 + + check feed.skipDays[0] == "Saturday" + check feed.skipDays[1] == "Sunday" + + check feed.textInput.title == "Search" + check feed.textInput.description == "Search for Trains!" + check feed.textInput.name == "Search Term" + check feed.textInput.link == "http://joe.bloggs/search.cgi" + + check feed.items[0].title == "Aeroplanes not Airplanes" + check feed.items[0].link == "http://joe.bloggs/posts/1" + check feed.items[0].pubDate == "Sat, 07 Sep 2002 00:00:01 GMT" + check feed.items[0].description == "Aero- not air-, fools!" + check feed.items[0].author == "jane@joe.bloggs (Jane Bloggs)" + + var feed_items_0_category_0:string = feed.items[0].categories[0] + check feed.items[0].categories[0].domain == "http://awesomecategories.org" + check feed_items_0_category_0 == "Words" + + check feed.items[0].comments == "http://joe.bloggs/posts/1/comments" + check feed.items[0].enclosure.url == "http://www.scripting.com/mp3s/weatherReportSuite.mp3" + check feed.items[0].enclosure.length == "12216320" + check feed.items[0].enclosure.enclosureType == "audio/mpeg" + check feed.items[0].guid == "http://joe.bloggs/posts/1" + + var feed_items_0_source:string = feed.items[0].source + check feed.items[0].source.url == "http://dictionary.com" + check feed_items_0_source == "The Dictionary" diff --git a/tests/test_rss.xml b/tests/test_rss.xml new file mode 100644 index 0000000..4432d9e --- /dev/null +++ b/tests/test_rss.xml @@ -0,0 +1,59 @@ + + + + Bloggs's Planes Trains and Automobiles + + http://joe.bloggs + + About Trains, Planes, and Automobiles. + + en-uk + Copyright Joe and Jane Bloggs + mail@joe.bloggs (Joe Bloggs) + master@joe.bloggs (Joe Bloggs) + Sat, 07 Sep 2002 00:00:01 GMT + Sat, 07 Sep 2002 00:00:01 GMT + + Planes + Trains + Automobiles + + Jester + http://blogs.law.harvard.edu/tech/rss + + + + 60 + + http://joe.bloggs/mug.jpg + Bloggs's Planes Trains and Automobiles + http://joe.bloggs + + + AO + + 01234 + SaturdaySunday + + + Search + Search for Trains! + Search Term + http://joe.bloggs/search.cgi + + + + Aeroplanes not Airplanes + http://joe.bloggs/posts/1 + Sat, 07 Sep 2002 00:00:01 GMT + Aero- not air-, fools! + jane@joe.bloggs (Jane Bloggs) + Words + http://joe.bloggs/posts/1/comments + + http://joe.bloggs/posts/1 + The Dictionary + + + + \ No newline at end of file -- cgit v1.2.3