Browse Source

Detect changes to LOC record correctly

pull/635/head
Mark Tearle 5 years ago
parent
commit
5852ae7a2f
2 changed files with 34 additions and 1 deletions
  1. +17
    -1
      octodns/provider/cloudflare.py
  2. +17
    -0
      tests/test_octodns_provider_cloudflare.py

+ 17
- 1
octodns/provider/cloudflare.py View File

@ -505,7 +505,7 @@ class CloudflareProvider(BaseProvider):
# new records cleanly. In general when there are multiple records for a
# name & type each will have a distinct/consistent `content` that can
# serve as a unique identifier.
# BUT... there are exceptions. MX, CAA, and SRV don't have a simple
# BUT... there are exceptions. MX, CAA, LOC and SRV don't have a simple
# content as things are currently implemented so we need to handle
# those explicitly and create unique/hashable strings for them.
_type = data['type']
@ -517,6 +517,22 @@ class CloudflareProvider(BaseProvider):
elif _type == 'SRV':
data = data['data']
return '{port} {priority} {target} {weight}'.format(**data)
elif _type == 'LOC':
data = data['data']
loc = (
'{lat_degrees}',
'{lat_minutes}',
'{lat_seconds}',
'{lat_direction}',
'{long_degrees}',
'{long_minutes}',
'{long_seconds}',
'{long_direction}',
'{altitude}',
'{size}',
'{precision_horz}',
'{precision_vert}')
return ' '.join(loc).format(**data)
return data['content']
def _apply_Create(self, change):


+ 17
- 0
tests/test_octodns_provider_cloudflare.py View File

@ -747,6 +747,23 @@ class TestCloudflareProvider(TestCase):
},
'type': 'SRV',
}),
('31 58 52.1 S 115 49 11.7 E 20 10 10 2', {
'data': {
'lat_degrees': 31,
'lat_minutes': 58,
'lat_seconds': 52.1,
'lat_direction': 'S',
'long_degrees': 115,
'long_minutes': 49,
'long_seconds': 11.7,
'long_direction': 'E',
'altitude': 20,
'size': 10,
'precision_horz': 10,
'precision_vert': 2,
},
'type': 'LOC',
}),
):
self.assertEqual(expected, provider._gen_key(data))


Loading…
Cancel
Save