the records and comments below */
if (rrA.qname == rrB.qname) {
if (rrA.qtype == rrB.qtype) {
- return rrB.content < rrA.content;
+ return rrB.content > rrA.content;
}
return rrB.qtype < rrA.qtype;
}
the records and comments below */
if (rrA.qname == rrB.qname) {
if (rrA.qtype == rrB.qtype) {
- return rrB.content < rrA.content;
+ return rrB.content > rrA.content;
}
return rrB.qtype < rrA.qtype;
}
assert data_got == data_expected, "%r != %r" % (data_got, data_expected)
-
def assert_eq_rrsets(rrsets, expected):
"""Assert rrsets sets are equal, ignoring sort order."""
key = lambda rrset: (rrset['name'], rrset['type'])
# check our record has appeared
self.assertEqual(get_rrset(data, name, 'A')['records'], rrset['records'])
+ def test_create_zone_with_records_ordered(self):
+ name = unique_zone_name()
+ rrset_a = {
+ "name": name,
+ "type": "A",
+ "ttl": 3600,
+ "records": [
+ # The contents are not lexographically ordered when creating
+ {
+ "content": "4.3.2.1",
+ "disabled": False,
+ },
+ {
+ "content": "127.0.0.1",
+ "disabled": False,
+ },
+ ],
+ }
+
+ rrset_ns = {
+ "name": "foo." + name,
+ "type": "NS",
+ "ttl": 3600,
+ "records": [
+ # The contents are not lexographically ordered when creating
+ {
+ "content": "ns2.example.com.",
+ "disabled": False,
+ },
+ {
+ "content": "ns1.example.net.",
+ "disabled": False,
+ }
+ ],
+ }
+
+ name, payload, data = self.create_zone(name=name, rrsets=[rrset_a, rrset_ns])
+ # check our record has appeared
+ self.assertEqual(get_rrset(data, name, 'A')['records'], [
+ # The content should be lexographically ordered when retrieving
+ {
+ "content": "127.0.0.1",
+ "disabled": False,
+ },
+ {
+ "content": "4.3.2.1",
+ "disabled": False,
+ },
+ ])
+
+ self.assertEqual(get_rrset(data, rrset_ns['name'], 'NS')['records'], [
+ {
+ "content": "ns1.example.net.",
+ "disabled": False,
+ },
+ {
+ "content": "ns2.example.com.",
+ "disabled": False,
+ }
+ ])
+
def test_create_zone_with_wildcard_records(self):
name = unique_zone_name()
rrset = {