Ticket #181: PythonTestReview.txt

File PythonTestReview.txt, 7.7 KB (added by stephen, 9 years ago)

Review of the Python Tests for Revision 2111

Line 
1Reviewing revision 2111 - Python Tests
2
3General
4===
5libdns_python_test.in seems redundant as the tests are run via "make check", and Makefile.am lists the python test files to run.  (If the file is used, then a number of test files are missing from it.)
6
7Most tests check the to_text method, but a number of them do not check the operation of the __str__ method which is also defined in the C++ code. (Also, those that do check __str__ call the method directly; isn't use of the str() function the more common way of calling it in Python?)
8
9The test_richcmp methods should check each comparison operator for both success and failure; it is conceivable that a programming error could cause an operator to always return true (or false) regardless of operands.
10
11
12experiments/python-binding/src/lib/dns/python/tests/message_python_test.py
13===
14First comment is incorrect - this is not a test of the rrtype part of libdns_python.
15
16MessageFlagTest:
17* test_init - OK
18* test_get_bit - OK
19
20OpcodeTest:
21* test_init - OK
22* test_get_code - OK
23* test_to_text - OK
24* test_richcmp - The comparison tests check that the exception raises is of the correct type.  However, this is no check to see if the comparision actually succeeded (which would be an error), e.g.
25
26        try:
27            o1 < o2
28            self.fail("o1 < o2 unexpectedly succeeded")
29        except Exception as err:
30            self.assertEqual(TypeError, type(err))
31
32
33RcodeTest:
34* test_init - no test that an object can be created with a valid argument.
35* test_get_code - No test for a BADVERS code.
36* test_to_text - No test for a BADVERS code.
37* test_richcmp - See comments for test_richcmp in OpcodeTest
38
39SectionTest:
40* test_init - OK
41* test_get_code - OK
42* test_richcmp - See comments for test_richcmp in OpcodeTest
43
44MessageTest
45* test_init - OK
46* test_get_header_flag - OK
47* test_set_header_flag - Perhaps renamed to test_set_clear_header_flag (as it tests both methods)?
48* test_set_DNSSEC_supported - needs a test to check that InvalidMessageOperation exception is raised if setDNSSECSupported is called on a Message object not in RENDER mode.
49* test_set_udp_size - Need to test that an exception is thrown if an invalid UDP size is set.
50* test_set_udp_size - Should check that an InvalidMessageOperation exception is thrown if the message is not in RENDER mode.
51* test_set_udp_size - Should check that a valid UDP size can be set.  (This will also need to test the get_udp_size method as well.)
52* test_set_qid - Similar comments as those for set_udp_size (i.e. need to excpetion thrown if the message is not in RENDER mode, need to check that the QID can be set).
53* test_set_rcode/test_set_opcode - Similar comments as those for set_udp_size.
54* test_get_section - need additional tests to check that the sections from the message can be returned.
55* test_get_rrcount - Need to test that a code of RR section can be returned.
56* test_add_question - Need to test that a question can be added.
57* test_add_rrset - Need to test that an RRset can be added.
58* test_clear - OK
59* test_to_wire/to_from_wire - need to check that the message can be successfully converted to wire format and back again.
60
61ConvertedUnitTests
62These unit tests are better combined with the unit tests of the appropriate class, e.g. ConvertedUnitTests.test_RcodeToText overlaps with RCodeTest.test_to_text.  (It is possible that some of the tests in this section address comments made above.)
63
64
65experiments/python-binding/src/lib/dns/python/tests/messagerenderer_python_test.py
66===
67* setUp - OK, although the commented out code hould be removed.
68* test_messagerenderer_get_data - the binary data expected from the message renderer has been checked and found to be OK:
69
70message1:
71qid = 123                       00 7B = 00 {
72QR = 0 (question)/Opcode = 0 (query)/Flags = 0 (none set)/RCODE = 0/
73rcode = 0 (question)            00 00
74QDCOUNT = 1                     00 01
75ANCOUNT = 0                     00 00
76NSCOUNT = 0                     00 00
77ARCOUNT = 0                     00 00
78QNAME = example.com             07 example 03 com 00
79QTYPE = A                       00 01
80CLASS = IN                      00 01
81
82=> data1 is OK
83
84message2:
85qid = 123                       00 7B = 00 {
86QR = 0 (question)/Opcode = 0 (query)/Flags = AA QR(none set)/
87RCODE = 0 (Noerror)/rcode = 0 (question)
88                                84 00
89QDCOUNT = 1                     00 01
90ANCOUNT = 0                     00 00
91NSCOUNT = 2                     00 02
92ARCOUNT = 0                     00 00
93QNAME = example.com             07 example 03 com 00
94QTYPE = A                       00 01
95CLASS = IN                      00 01
96
97Answer (none)
98
99Authority (pointer format):
100First RR: first two bits set + offset of 12 for name example.com
101                                C0 0C
102QTYPE = A                       00 01
103CLASS = IN                      00 01
104TTL = 3600                      00 00 0E 10
105RDLENGTH = 4 (IPV4 address)     00 04
106192.0.2.98                      0C 00 02 62 = 0C 00 02 b
107
108Second RR: first two bits set + offset of 12 for name example.com
109                                C0 0C
110QTYPE = A                       00 01
111CLASS = IN                      00 01
112TTL = 3600                      00 00 0E 10
113RDLENGTH = 4 (IPV4 address)     00 04
114192.0.2.98                      0C 00 02 63 = 0C 00 02 c
115Additional (None)
116
117=> data2 is OK
118
119* test_messagerenderer_get_length - OK
120* test_messagerenderer_get_is_truncated - OK
121* test_messagerenderer_get_length_limit - OK
122* test_messagerenderer_set_truncated - OK
123* test_messagerenderer_set_length_limit - OK
124
125
126experiments/python-binding/src/lib/dns/python/tests/name_python_test.py
127===
128
129NameComparisonTest
130--
131* test_init - OK
132* test_get_order - OK
133* test_get_common_labels - OK
134* test_get_relation - Need additional tests to check the relationships SUPERDOMAIN, SUBDOMAIN and EQUAL.
135
136NameTest
137--
138* test_init - OK.  The comment "no TooLong for from wire?" suggests that there could be a missing check/exception in the underlying class.  Is this being followed up?
139* test_at - OK
140* test_get_length - OK
141* test_get_labelcount - OK
142* test_to_wire - OK
143* test_equals - A bit puzzled by the commented-out assertion of equality between name1 and name2.
144* test_split - OK
145* test_reverse - OK
146* test_downcase - OK
147* test_is_wildcard - OK
148* test_richcmp - OK
149
150
151experiments/python-binding/src/lib/dns/python/tests/question_python_test.py
152===
153* test_init - OK
154* test_QuestionTest_fromWire - OK.  However, as there is no from_wire method in the Question class, and the tests for get_name, get_type and get_class methods are buried in this method, the name "test_QuestionTest_fromWire" is a bit misleading.
155* test_QuestionTest_to_text - OK
156* test_QuestionTest_to_wireBuffer - OK
157* test_QuestionTest_to_wireRenderer - OK
158
159
160experiments/python-binding/src/lib/dns/python/tests/rdata_python_test.py
161===
162* test_init - OK
163* test_rdata_to_wire - Needs a test added to check that the to_wire method can be called with a MessageRenderer object.
164* test_rdata_to_text - OK
165
166
167experiments/python-binding/src/lib/dns/python/tests/rrclass_python_test.py
168===
169* test_init - OK
170* test_rrclass_to_text - OK
171* test_rrclass_to_wire - OK
172* test_richcmp - Tests all operations except for "==".
173* test_statics - OK
174
175
176experiments/python-binding/src/lib/dns/python/tests/rrset_python_test.py
177===
178* test_init - OK
179* test_get_rdata_count - OK
180* test_get_name - OK
181* test_get_class - OK
182* test_get_type - OK
183* test_get_ttl - OK
184* test_set_ttl - OK
185* test_set_name - OK
186* test_add_rdata - OK.  Note that this test is still unfinished, awaiting the completion of an iterator.
187* test_to_text - OK.
188* test_to_wire_buffer - OK
189* test_to_wire_renderer - OK
190
191Does not appear to be a test for the get_rdata method.
192
193
194experiments/python-binding/src/lib/dns/python/tests/rrttl_python_test.py
195===
196The class is named RdataTest - shouldn't it be named RRTTLTest?.  Also the methods are named test_rdata_xxx - they should be named test_rrttl_xxx.
197
198* test_init - OK (tests the get_value method).
199* test_rdata_to_text - OK
200* test_rdata_to_wire - OK
201* test_rdata_richcmp - OK
202
203
204experiments/python-binding/src/lib/dns/python/tests/rrtype_python_test.py
205===
206* test_init - OK
207* test_from_text - OK (ideally should be called test_init_from_text?)
208* test_case_construct - OK
209* test_to_text - OK
210* test_to_wire_buffer - OK
211* test_to_wire_renderer - OK
212* test_to_wire_bad - OK
213* test_compare - OK
214* test_statics - OK
215
216