diff options
| author | John Conway <john.a.conway@gmail.com> | 2019-05-10 13:23:54 +0100 |
|---|---|---|
| committer | John Conway <john.a.conway@gmail.com> | 2019-05-10 13:23:54 +0100 |
| commit | fce7e6abd64b4b848cc0a30047774b44d31979dc (patch) | |
| tree | 0c361a003527b80b88f57c7b1254f48d6ea7c428 /tests | |
| parent | e4652b267a04401b528b4c19fa81da6dcbc32ff1 (diff) | |
| download | feed-nim-fce7e6abd64b4b848cc0a30047774b44d31979dc.tar.gz feed-nim-fce7e6abd64b4b848cc0a30047774b44d31979dc.zip | |
[JSONFeed] Wrote tests, some fixes
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_jsonfeed | bin | 0 -> 607872 bytes | |||
| -rw-r--r-- | tests/test_jsonfeed.json | 46 | ||||
| -rw-r--r-- | tests/test_jsonfeed.nim | 60 |
3 files changed, 106 insertions, 0 deletions
diff --git a/tests/test_jsonfeed b/tests/test_jsonfeed Binary files differnew file mode 100755 index 0000000..6779f58 --- /dev/null +++ b/tests/test_jsonfeed diff --git a/tests/test_jsonfeed.json b/tests/test_jsonfeed.json new file mode 100644 index 0000000..4eea2ac --- /dev/null +++ b/tests/test_jsonfeed.json @@ -0,0 +1,46 @@ +{ + "version": "https://jsonfeed.org/version/1", + "title": "Bloggs's Planes Trains and Automobiles", + "home_page_url": "http://joe.bloggs", + "feed_url": "http://joe.bloggs/feed.json", + "description": "About Trains, Planes, and Automobiles.", + "next_url": "http://joe.bloggs/feed.json/02", + "icon": "http://joe.bloggs/mug.jpg", + "favicon": "http://joe.bloggs/little_mug.jpg", + "author": { + "name": "Joe Bloggs", + "url": "http://joe.bloggs", + "avatar": "http://joe.bloggs/mug.jpg" + }, + "expired": false, + "items": [ + { + "title": "Aeroplanes not Airplanes", + "id": "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a", + "content_html": "<p><i>Aero</i>- not air-, fools!</p>", + "url": "http://joe.bloggs/01-item", + "summary": "Americans wrong!", + "external_url": "http://american-airplanes.awesome", + "attachments": [{ + "url": "http://learntowordgood.com/aeroplane", + "mime_type": "audio/mpeg", + "title": "Learn How to say Aeroplane", + "size_in_bytes": 6000, + "duration_in_seconds": 5 + }], + "date_published": "2010-02-07T14:04:00-04:00" + }, + { + "id": "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6d", + "author": { + "name": "Jane Bloggs" + }, + "image": "http://joe.bloggs/images/big-train.jpg", + "banner_image": "http://joe.bloggs/images/big-train-banner.jpg", + "content_text": "Trains!", + "url": "http://joe.bloggs/02-item", + "date_published": "2010-02-07T14:04:00-05:00", + "tags": ["trains", "photos"] + } + ] +}
\ No newline at end of file diff --git a/tests/test_jsonfeed.nim b/tests/test_jsonfeed.nim new file mode 100644 index 0000000..55757a0 --- /dev/null +++ b/tests/test_jsonfeed.nim @@ -0,0 +1,60 @@ +# 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/jsonfeed + +test "Read Valid JsonFeed": + let feed = "./tests/test_jsonfeed.json".loadJsonFeed() + + check feed.version == "https://jsonfeed.org/version/1" + check feed.title == "Bloggs's Planes Trains and Automobiles" + check feed.home_page_url == "http://joe.bloggs" + check feed.feed_url == "http://joe.bloggs/feed.json" + check feed.description == "About Trains, Planes, and Automobiles." + check feed.next_url == "http://joe.bloggs/feed.json/02" + check feed.icon == "http://joe.bloggs/mug.jpg" + check feed.favicon == "http://joe.bloggs/little_mug.jpg" + check feed.author.name == "Joe Bloggs" + check feed.author.url == "http://joe.bloggs" + check feed.author.avatar == "http://joe.bloggs/mug.jpg" + check feed.expired == false + + check feed.items[0].title == "Aeroplanes not Airplanes" + check feed.items[0].id == "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a" + check feed.items[0].content_html == "<p><i>Aero</i>- not air-, fools!</p>" + check feed.items[0].url == "http://joe.bloggs/01-item" + check feed.items[0].summary == "Americans wrong!" + check feed.items[0].external_url == "http://american-airplanes.awesome" + check feed.items[0].attachments[0].url == "http://learntowordgood.com/aeroplane" + check feed.items[0].attachments[0].mime_type == "audio/mpeg" + check feed.items[0].attachments[0].title == "Learn How to say Aeroplane" + check feed.items[0].attachments[0].size_in_bytes == 6000 + check feed.items[0].attachments[0].duration_in_seconds == 5 + check feed.items[0].date_published == "2010-02-07T14:04:00-04:00" + + check feed.items[1].id == "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6d" + check feed.items[1].author.name == "Jane Bloggs" + check feed.items[1].image == "http://joe.bloggs/images/big-train.jpg" + check feed.items[1].banner_image == "http://joe.bloggs/images/big-train-banner.jpg" + check feed.items[1].content_text == "Trains!" + check feed.items[1].url == "http://joe.bloggs/02-item" + check feed.items[1].date_published == "2010-02-07T14:04:00-05:00" + check feed.items[1].tags[0] == "trains" + check feed.items[1].tags[1] == "photos" + +test "Fetch JsonFeed from JsonFeed.org": + let feed = getJsonFeed("https://jsonfeed.org/feed.json") + check feed.title != "" + check feed.home_page_url == "https://jsonfeed.org/" + check feed.items[0].title == "Announcing JSON Feed" + check feed.items[0].date_published != "" + check feed.items[0].id != "" |
