Browse Source

python 3 support for constellix provider

pull/384/head
Ross McFarland 6 years ago
parent
commit
470dd82202
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
2 changed files with 10 additions and 3 deletions
  1. +2
    -1
      octodns/provider/constellix.py
  2. +8
    -2
      tests/test_octodns_provider_constellix.py

+ 2
- 1
octodns/provider/constellix.py View File

@ -9,6 +9,7 @@ from collections import defaultdict
from requests import Session
from base64 import b64encode
from ipaddress import ip_address
from six import string_types
import hashlib
import hmac
import logging
@ -122,7 +123,7 @@ class ConstellixClient(object):
# change relative values to absolute
value = record['value']
if record['type'] in ['ALIAS', 'CNAME', 'MX', 'NS', 'SRV']:
if isinstance(value, unicode):
if isinstance(value, string_types):
record['value'] = self._absolutize_value(value,
zone_name)
if isinstance(value, list):


+ 8
- 2
tests/test_octodns_provider_constellix.py View File

@ -10,6 +10,7 @@ from mock import Mock, call
from os.path import dirname, join
from requests import HTTPError
from requests_mock import ANY, mock as requests_mock
from six import text_type
from unittest import TestCase
from octodns.record import Record
@ -65,7 +66,7 @@ class TestConstellixProvider(TestCase):
with self.assertRaises(Exception) as ctx:
zone = Zone('unit.tests.', [])
provider.populate(zone)
self.assertEquals('Unauthorized', ctx.exception.message)
self.assertEquals('Unauthorized', text_type(ctx.exception))
# Bad request
with requests_mock() as mock:
@ -77,7 +78,7 @@ class TestConstellixProvider(TestCase):
zone = Zone('unit.tests.', [])
provider.populate(zone)
self.assertEquals('\n - "unittests" is not a valid domain name',
ctx.exception.message)
text_type(ctx.exception))
# General error
with requests_mock() as mock:
@ -148,6 +149,11 @@ class TestConstellixProvider(TestCase):
call('POST', '/', data={'names': ['unit.tests']}),
# get all domains to build the cache
call('GET', '/'),
])
# These two checks are broken up so that ordering doesn't break things.
# Python3 doesn't make the calls in a consistent order so different
# things follow the GET / on different runs
provider._client._request.assert_has_calls([
call('POST', '/123123/records/SRV', data={
'roundRobin': [{
'priority': 10,


Loading…
Cancel
Save