|
|
|
@ -683,6 +683,57 @@ class TestRecordValidation(TestCase): |
|
|
|
lenient=True, |
|
|
|
) |
|
|
|
|
|
|
|
def test_values_and_value(self): |
|
|
|
# value w/one |
|
|
|
r = Record.new( |
|
|
|
self.zone, 'thing', {'type': 'TXT', 'ttl': 42, 'value': 'just one'} |
|
|
|
) |
|
|
|
self.assertEqual(['just one'], r.values) |
|
|
|
|
|
|
|
# value w/multiple |
|
|
|
r = Record.new( |
|
|
|
self.zone, |
|
|
|
'thing', |
|
|
|
{'type': 'TXT', 'ttl': 42, 'value': ['the first', 'the second']}, |
|
|
|
) |
|
|
|
self.assertEqual(['the first', 'the second'], r.values) |
|
|
|
|
|
|
|
# values w/one |
|
|
|
r = Record.new( |
|
|
|
self.zone, 'thing', {'type': 'TXT', 'ttl': 42, 'values': 'just one'} |
|
|
|
) |
|
|
|
self.assertEqual(['just one'], r.values) |
|
|
|
|
|
|
|
# values w/multiple |
|
|
|
r = Record.new( |
|
|
|
self.zone, |
|
|
|
'thing', |
|
|
|
{'type': 'TXT', 'ttl': 42, 'values': ['the first', 'the second']}, |
|
|
|
) |
|
|
|
self.assertEqual(['the first', 'the second'], r.values) |
|
|
|
|
|
|
|
# tuples work too |
|
|
|
r = Record.new( |
|
|
|
self.zone, |
|
|
|
'thing', |
|
|
|
{'type': 'TXT', 'ttl': 42, 'values': ('the first', 'the second')}, |
|
|
|
) |
|
|
|
self.assertEqual(['the first', 'the second'], r.values) |
|
|
|
|
|
|
|
# values is preferred over value |
|
|
|
# values w/multiple |
|
|
|
r = Record.new( |
|
|
|
self.zone, |
|
|
|
'thing', |
|
|
|
{ |
|
|
|
'type': 'TXT', |
|
|
|
'ttl': 42, |
|
|
|
'values': ['the first', 'the second'], |
|
|
|
'value': ['not used', 'not used'], |
|
|
|
}, |
|
|
|
) |
|
|
|
self.assertEqual(['the first', 'the second'], r.values) |
|
|
|
|
|
|
|
def test_validation_context(self): |
|
|
|
# fails validation, no context |
|
|
|
with self.assertRaises(ValidationError) as ctx: |
|
|
|
|