blob: 4690af1e0395a03e64ff370dd5429889064c3cdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# 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/atom
test "Read Valid Atom Feed":
let feed = "./tests/test_atom.xml".loadAtom()
check feed.id == "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
check feed.title == "Bloggs's Planes Trains and Automobiles"
check feed.updated == "2003-12-13T18:30:02Z"
check feed.author.name == "Joe Bloggs"
check feed.author.uri == "http://joe.bloggs"
check feed.author.email == "mail@joe.bloggs"
check feed.contributors[0].name == "Jane Bloggs"
check feed.categories[0].term == "planes"
check feed.categories[0].label == "Planes"
check feed.categories[0].scheme == "http://awesomecategories.org"
check feed.categories[1].term == "trains"
check feed.categories[1].label == "Trains"
check feed.categories[2].term == "automobiles"
check feed.categories[2].label == "Automobiles"
let feed_generator_uri = feed.generator.uri
check feed_generator_uri == "https://github.com/dom96/jester"
let feed_generator_text:string = feed.generator
check feed.generator == "Jester"
check feed.icon == "http://joe.bloggs/mug,jpg"
check feed.link.href == "http://joe.bloggs/atom"
check feed.link.rel == "self"
check feed.link.linktype == "application/xml+atom"
check feed.link.hreflang == "en-GB"
check feed.link.title == "Bloggs's Planes Trains and Automobiles"
check feed.link.length == 1000000
check feed.logo == "http://joe.bloggs/logo.jpeg"
check feed.rights == "Copyright Joe and Jane Bloggs"
check feed.subtitle == "About Trains, Planes, and Automobiles."
check feed.entries[0].id == "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"
check feed.entries[0].title == "Aeroplanes not Airplanes"
check feed.entries[0].updated == "2003-12-13T18:30:02Z"
check feed.entries[0].author.name == "Joe Bloggs"
check feed.entries[0].author.uri == "http://joe.bloggs"
check feed.entries[0].author.email == "mail@joe.bloggs"
check feed.entries[0].categories[0].term == "words"
check feed.entries[0].categories[0].label == "Words"
check feed.entries[0].categories[0].scheme == "http://awesomecategories.org"
var feed_0_content_textType = feed.entries[0].content.textType
check feed_0_content_textType == "xhtml"
var feed_0_content_text: string = feed.entries[0].content
check feed_0_content_text == """<div xmlns="http://www.w3.org/1999/xhtml"><p><i>Aero</i>- not air-, fools!</p></div>"""
check feed.entries[0].published == "2003-12-13T18:30:02Z"
check feed.entries[0].rights == "Copyright Joe Bloggs"
check feed.entries[0].source.id == "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6d"
check feed.entries[0].source.title == "Aeroplane"
check feed.entries[0].source.subtitle == "Aeroplanes"
check feed.entries[0].source.updated == "1755-04-15T18:30:00Z"
check feed.entries[0].source.author.name == "Samuel Johnson"
check feed.entries[0].source.author.uri == "http://dictionary.com"
check feed.entries[0].source.author.email == "sjohnson@dictionary.com"
check feed.entries[0].source.categories[0].term == "planes"
check feed.entries[0].source.categories[0].label == "Planes"
check feed.entries[0].source.categories[0].scheme == "http://awesomecategories.org"
check feed.entries[0].source.rights == "Copyright Samual Johnson"
check feed.entries[1].id == "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"
check feed.entries[1].title == "Trains Are Good"
check feed.entries[1].updated == "2003-12-13T18:30:02Z"
check feed.entries[1].author.name == "Jane Bloggs"
check feed.entries[1].categories[0].term == "trains"
check feed.entries[1].categories[0].label == "Trains"
check feed.entries[1].content.src == "http://trains.com"
check feed.entries[1].link.href == "http://joe.bloggs/trains-full"
check feed.entries[1].link.rel == "alternate"
check feed.entries[1].link.linktype == "text/html"
check feed.entries[1].link.hreflang == "en-GB"
check feed.entries[1].link.title == "Trains!"
check feed.entries[1].link.length == 1000000
check feed.entries[1].published == "2003-12-13T18:20:02Z"
check feed.entries[1].rights == "Copyright Jane Bloggs"
check feed.entries[1].summary == "Trains!"
test "Fetch Atom Feed from W3C":
let feed = getAtom("https://www.w3.org/blog/news/feed/atom")
check feed.title != ""
check feed.id != ""
check feed.link.href != ""
check feed.entries.len() > 0
check feed.entries[0].title != ""
check feed.entries[0].updated != ""
check feed.entries[0].id != ""
|