|
|
@ -1809,81 +1809,6 @@ class TestRecord(TestCase): |
|
|
# __repr__ doesn't blow up |
|
|
# __repr__ doesn't blow up |
|
|
a.__repr__() |
|
|
a.__repr__() |
|
|
|
|
|
|
|
|
def test_urlfwd_value_rr_text(self): |
|
|
|
|
|
|
|
|
|
|
|
# empty string won't parse |
|
|
|
|
|
with self.assertRaises(RrParseError): |
|
|
|
|
|
UrlfwdValue.parse_rr_text('') |
|
|
|
|
|
|
|
|
|
|
|
# single word won't parse |
|
|
|
|
|
with self.assertRaises(RrParseError): |
|
|
|
|
|
UrlfwdValue.parse_rr_text('nope') |
|
|
|
|
|
|
|
|
|
|
|
# 2nd word won't parse |
|
|
|
|
|
with self.assertRaises(RrParseError): |
|
|
|
|
|
UrlfwdValue.parse_rr_text('one two') |
|
|
|
|
|
|
|
|
|
|
|
# 3rd word won't parse |
|
|
|
|
|
with self.assertRaises(RrParseError): |
|
|
|
|
|
UrlfwdValue.parse_rr_text('one two three') |
|
|
|
|
|
|
|
|
|
|
|
# 4th word won't parse |
|
|
|
|
|
with self.assertRaises(RrParseError): |
|
|
|
|
|
UrlfwdValue.parse_rr_text('one two three four') |
|
|
|
|
|
|
|
|
|
|
|
# 6th word won't parse |
|
|
|
|
|
with self.assertRaises(RrParseError): |
|
|
|
|
|
UrlfwdValue.parse_rr_text('one two three four five size') |
|
|
|
|
|
|
|
|
|
|
|
# non-ints |
|
|
|
|
|
self.assertEqual( |
|
|
|
|
|
{ |
|
|
|
|
|
'code': 'one', |
|
|
|
|
|
'masking': 'two', |
|
|
|
|
|
'query': 'three', |
|
|
|
|
|
'path': 'four', |
|
|
|
|
|
'target': 'five', |
|
|
|
|
|
}, |
|
|
|
|
|
UrlfwdValue.parse_rr_text('one two three four five'), |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# valid |
|
|
|
|
|
self.assertEqual( |
|
|
|
|
|
{ |
|
|
|
|
|
'code': 301, |
|
|
|
|
|
'masking': 0, |
|
|
|
|
|
'query': 1, |
|
|
|
|
|
'path': 'four', |
|
|
|
|
|
'target': 'five', |
|
|
|
|
|
}, |
|
|
|
|
|
UrlfwdValue.parse_rr_text('301 0 1 four five'), |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# make sure that validate is using parse_rr_text when passed string |
|
|
|
|
|
# value(s) |
|
|
|
|
|
reasons = UrlfwdRecord.validate( |
|
|
|
|
|
'urlfwd', 'urlfwd.unit.tests.', {'ttl': 32, 'value': ''} |
|
|
|
|
|
) |
|
|
|
|
|
self.assertEqual(['failed to parse string value as RR text'], reasons) |
|
|
|
|
|
reasons = UrlfwdRecord.validate( |
|
|
|
|
|
'urlfwd', |
|
|
|
|
|
'urlfwd.unit.tests.', |
|
|
|
|
|
{'ttl': 32, 'value': '301 0 1 four five'}, |
|
|
|
|
|
) |
|
|
|
|
|
self.assertFalse(reasons) |
|
|
|
|
|
|
|
|
|
|
|
# make sure that the cstor is using parse_rr_text |
|
|
|
|
|
zone = Zone('unit.tests.', []) |
|
|
|
|
|
a = UrlfwdRecord( |
|
|
|
|
|
zone, 'urlfwd', {'ttl': 32, 'value': '301 0 1 four five'} |
|
|
|
|
|
) |
|
|
|
|
|
self.assertEqual(301, a.values[0].code) |
|
|
|
|
|
self.assertEqual(0, a.values[0].masking) |
|
|
|
|
|
self.assertEqual(1, a.values[0].query) |
|
|
|
|
|
self.assertEqual('four', a.values[0].path) |
|
|
|
|
|
self.assertEqual('five', a.values[0].target) |
|
|
|
|
|
self.assertEqual('301 0 1 four five', a.values[0].rr_text) |
|
|
|
|
|
|
|
|
|
|
|
def test_record_new(self): |
|
|
def test_record_new(self): |
|
|
txt = Record.new( |
|
|
txt = Record.new( |
|
|
self.zone, 'txt', {'ttl': 44, 'type': 'TXT', 'value': 'some text'} |
|
|
self.zone, 'txt', {'ttl': 44, 'type': 'TXT', 'value': 'some text'} |
|
|
|