Software /
code /
prosody
Annotate
tests/test_util_stanza.lua @ 7482:88a92ba697bf
util.openssl: remove unused one-letter loop variable [luacheck]
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 09 Jul 2016 13:52:04 +0800 |
parent | 7254:8aaae816cc7e |
child | 7503:1810f1a4ff05 |
rev | line source |
---|---|
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
682
diff
changeset
|
1 -- Prosody IM |
2923
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
3639
diff
changeset
|
4 -- |
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
682
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
682
diff
changeset
|
6 -- COPYING file in the source package for more information. |
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
682
diff
changeset
|
7 -- |
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
682
diff
changeset
|
8 |
682
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
9 |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
10 function preserialize(preserialize, st) |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
11 local stanza = st.stanza("message", { a = "a" }); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
12 local stanza2 = preserialize(stanza); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
13 assert_is(stanza2 and stanza.name, "preserialize returns a stanza"); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
14 assert_is_not(stanza2.tags, "Preserialized stanza has no tag list"); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
15 assert_is_not(stanza2.last_add, "Preserialized stanza has no last_add marker"); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
16 assert_is_not(getmetatable(stanza2), "Preserialized stanza has no metatable"); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
17 end |
681 | 18 |
19 function deserialize(deserialize, st) | |
20 local stanza = st.stanza("message", { a = "a" }); | |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
3639
diff
changeset
|
21 |
681 | 22 local stanza2 = deserialize(st.preserialize(stanza)); |
682
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
23 assert_is(stanza2 and stanza.name, "deserialize returns a stanza"); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
24 assert_table(stanza2.attr, "Deserialized stanza has attributes"); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
25 assert_equal(stanza2.attr.a, "a", "Deserialized stanza retains attributes"); |
dedd19e9d4b3
Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents:
681
diff
changeset
|
26 assert_table(getmetatable(stanza2), "Deserialized stanza has metatable"); |
681 | 27 end |
7254
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
28 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
29 function stanza(stanza) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
30 local s = stanza("foo", { xmlns = "myxmlns", a = "attr-a" }); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
31 assert_equal(s.name, "foo"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
32 assert_equal(s.attr.xmlns, "myxmlns"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
33 assert_equal(s.attr.a, "attr-a"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
34 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
35 local s1 = stanza("s1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
36 assert_equal(s1.name, "s1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
37 assert_equal(s1.attr.xmlns, nil); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
38 assert_equal(#s1, 0); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
39 assert_equal(#s1.tags, 0); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
40 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
41 s1:tag("child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
42 assert_equal(#s1.tags, 1); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
43 assert_equal(s1.tags[1].name, "child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
44 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
45 s1:tag("grandchild1"):up(); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
46 assert_equal(#s1.tags, 1); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
47 assert_equal(s1.tags[1].name, "child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
48 assert_equal(#s1.tags[1], 1); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
49 assert_equal(s1.tags[1][1].name, "grandchild1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
50 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
51 s1:up():tag("child2"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
52 assert_equal(#s1.tags, 2, tostring(s1)); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
53 assert_equal(s1.tags[1].name, "child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
54 assert_equal(s1.tags[2].name, "child2"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
55 assert_equal(#s1.tags[1], 1); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
56 assert_equal(s1.tags[1][1].name, "grandchild1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
57 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
58 s1:up():text("Hello world"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
59 assert_equal(#s1.tags, 2); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
60 assert_equal(#s1, 3); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
61 assert_equal(s1.tags[1].name, "child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
62 assert_equal(s1.tags[2].name, "child2"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
63 assert_equal(#s1.tags[1], 1); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
64 assert_equal(s1.tags[1][1].name, "grandchild1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
65 end |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
66 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
67 function message(message) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
68 local m = message(); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
69 assert_equal(m.name, "message"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
70 end |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
71 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
72 function iq(iq) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
73 local i = iq(); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
74 assert_equal(i.name, "iq"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
75 end |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
76 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
77 function presence(presence) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
78 local p = presence(); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
79 assert_equal(p.name, "presence"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
80 end |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
81 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
82 function reply(reply, _M) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
83 -- Test stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
84 local s = _M.stanza("s", { to = "touser", from = "fromuser", id = "123" }) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
85 :tag("child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
86 -- Make reply stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
87 local r = reply(s); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
88 assert_equal(r.name, s.name); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
89 assert_equal(r.id, s.id); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
90 assert_equal(r.attr.to, s.attr.from); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
91 assert_equal(r.attr.from, s.attr.to); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
92 assert_equal(#r.tags, 0, "A reply should not include children of the original stanza"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
93 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
94 -- Test stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
95 local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" }) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
96 :tag("child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
97 -- Make reply stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
98 local r = reply(s); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
99 assert_equal(r.name, s.name); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
100 assert_equal(r.id, s.id); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
101 assert_equal(r.attr.to, s.attr.from); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
102 assert_equal(r.attr.from, s.attr.to); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
103 assert_equal(r.attr.type, "result"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
104 assert_equal(#r.tags, 0, "A reply should not include children of the original stanza"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
105 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
106 -- Test stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
107 local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "set" }) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
108 :tag("child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
109 -- Make reply stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
110 local r = reply(s); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
111 assert_equal(r.name, s.name); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
112 assert_equal(r.id, s.id); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
113 assert_equal(r.attr.to, s.attr.from); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
114 assert_equal(r.attr.from, s.attr.to); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
115 assert_equal(r.attr.type, "result"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
116 assert_equal(#r.tags, 0, "A reply should not include children of the original stanza"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
117 end |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
118 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
119 function error_reply(error_reply, _M) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
120 -- Test stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
121 local s = _M.stanza("s", { to = "touser", from = "fromuser", id = "123" }) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
122 :tag("child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
123 -- Make reply stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
124 local r = error_reply(s); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
125 assert_equal(r.name, s.name); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
126 assert_equal(r.id, s.id); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
127 assert_equal(r.attr.to, s.attr.from); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
128 assert_equal(r.attr.from, s.attr.to); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
129 assert_equal(#r.tags, 1); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
130 |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
131 -- Test stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
132 local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" }) |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
133 :tag("child1"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
134 -- Make reply stanza |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
135 local r = error_reply(s); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
136 assert_equal(r.name, s.name); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
137 assert_equal(r.id, s.id); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
138 assert_equal(r.attr.to, s.attr.from); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
139 assert_equal(r.attr.from, s.attr.to); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
140 assert_equal(r.attr.type, "error"); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
141 assert_equal(#r.tags, 1); |
8aaae816cc7e
tests: Expand util.stanza tests
Matthew Wild <mwild1@gmail.com>
parents:
5776
diff
changeset
|
142 end |