mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge branch 'master' into record-copy-octodns
This commit is contained in:
@@ -7,7 +7,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
|
||||
from os import environ
|
||||
from os.path import dirname, join
|
||||
from six import text_type
|
||||
|
||||
from octodns.manager import _AggregateTarget, MainThreadExecutor, Manager, \
|
||||
ManagerException
|
||||
@@ -34,79 +33,79 @@ class TestManager(TestCase):
|
||||
def test_missing_provider_class(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('missing-provider-class.yaml')).sync()
|
||||
self.assertTrue('missing class' in text_type(ctx.exception))
|
||||
self.assertTrue('missing class' in str(ctx.exception))
|
||||
|
||||
def test_bad_provider_class(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('bad-provider-class.yaml')).sync()
|
||||
self.assertTrue('Unknown provider class' in text_type(ctx.exception))
|
||||
self.assertTrue('Unknown provider class' in str(ctx.exception))
|
||||
|
||||
def test_bad_provider_class_module(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('bad-provider-class-module.yaml')) \
|
||||
.sync()
|
||||
self.assertTrue('Unknown provider class' in text_type(ctx.exception))
|
||||
self.assertTrue('Unknown provider class' in str(ctx.exception))
|
||||
|
||||
def test_bad_provider_class_no_module(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('bad-provider-class-no-module.yaml')) \
|
||||
.sync()
|
||||
self.assertTrue('Unknown provider class' in text_type(ctx.exception))
|
||||
self.assertTrue('Unknown provider class' in str(ctx.exception))
|
||||
|
||||
def test_missing_provider_config(self):
|
||||
# Missing provider config
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('missing-provider-config.yaml')).sync()
|
||||
self.assertTrue('provider config' in text_type(ctx.exception))
|
||||
self.assertTrue('provider config' in str(ctx.exception))
|
||||
|
||||
def test_missing_env_config(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('missing-provider-env.yaml')).sync()
|
||||
self.assertTrue('missing env var' in text_type(ctx.exception))
|
||||
self.assertTrue('missing env var' in str(ctx.exception))
|
||||
|
||||
def test_missing_source(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('provider-problems.yaml')) \
|
||||
.sync(['missing.sources.'])
|
||||
self.assertTrue('missing sources' in text_type(ctx.exception))
|
||||
self.assertTrue('missing sources' in str(ctx.exception))
|
||||
|
||||
def test_missing_targets(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('provider-problems.yaml')) \
|
||||
.sync(['missing.targets.'])
|
||||
self.assertTrue('missing targets' in text_type(ctx.exception))
|
||||
self.assertTrue('missing targets' in str(ctx.exception))
|
||||
|
||||
def test_unknown_source(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('provider-problems.yaml')) \
|
||||
.sync(['unknown.source.'])
|
||||
self.assertTrue('unknown source' in text_type(ctx.exception))
|
||||
self.assertTrue('unknown source' in str(ctx.exception))
|
||||
|
||||
def test_unknown_target(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('provider-problems.yaml')) \
|
||||
.sync(['unknown.target.'])
|
||||
self.assertTrue('unknown target' in text_type(ctx.exception))
|
||||
self.assertTrue('unknown target' in str(ctx.exception))
|
||||
|
||||
def test_bad_plan_output_class(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
name = 'bad-plan-output-missing-class.yaml'
|
||||
Manager(get_config_filename(name)).sync()
|
||||
self.assertEquals('plan_output bad is missing class',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
def test_bad_plan_output_config(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('bad-plan-output-config.yaml')).sync()
|
||||
self.assertEqual('Incorrect plan_output config for bad',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
def test_source_only_as_a_target(self):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('provider-problems.yaml')) \
|
||||
.sync(['not.targetable.'])
|
||||
self.assertTrue('does not support targeting' in
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
def test_always_dry_run(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
@@ -184,7 +183,7 @@ class TestManager(TestCase):
|
||||
.sync()
|
||||
self.assertEquals('Invalid alias zone alias.tests.: source zone '
|
||||
'does-not-exists.tests. does not exist',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
# Alias zone that points to another alias zone.
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
@@ -192,7 +191,7 @@ class TestManager(TestCase):
|
||||
.sync()
|
||||
self.assertEquals('Invalid alias zone alias-loop.tests.: source '
|
||||
'zone alias.tests. is an alias zone',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
# Sync an alias without the zone it refers to
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
@@ -200,7 +199,7 @@ class TestManager(TestCase):
|
||||
.sync(eligible_zones=["alias.tests."])
|
||||
self.assertEquals('Zone alias.tests. cannot be sync without zone '
|
||||
'unit.tests. sinced it is aliased',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
def test_compare(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
@@ -228,7 +227,7 @@ class TestManager(TestCase):
|
||||
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
manager.compare(['nope'], ['dump'], 'unit.tests.')
|
||||
self.assertEquals('Unknown source: nope', text_type(ctx.exception))
|
||||
self.assertEquals('Unknown source: nope', str(ctx.exception))
|
||||
|
||||
def test_aggregate_target(self):
|
||||
simple = SimpleProvider()
|
||||
@@ -269,7 +268,7 @@ class TestManager(TestCase):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
manager.dump('unit.tests.', tmpdir.dirname, False, False,
|
||||
'nope')
|
||||
self.assertEquals('Unknown source: nope', text_type(ctx.exception))
|
||||
self.assertEquals('Unknown source: nope', str(ctx.exception))
|
||||
|
||||
manager.dump('unit.tests.', tmpdir.dirname, False, False, 'in')
|
||||
|
||||
@@ -298,7 +297,7 @@ class TestManager(TestCase):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
manager.dump('unit.tests.', tmpdir.dirname, False, True,
|
||||
'nope')
|
||||
self.assertEquals('Unknown source: nope', text_type(ctx.exception))
|
||||
self.assertEquals('Unknown source: nope', str(ctx.exception))
|
||||
|
||||
manager.dump('unit.tests.', tmpdir.dirname, False, True, 'in')
|
||||
|
||||
@@ -314,26 +313,24 @@ class TestManager(TestCase):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('missing-sources.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('missing sources' in text_type(ctx.exception))
|
||||
self.assertTrue('missing sources' in str(ctx.exception))
|
||||
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('unknown-provider.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('unknown source' in text_type(ctx.exception))
|
||||
self.assertTrue('unknown source' in str(ctx.exception))
|
||||
|
||||
# Alias zone using an invalid source zone.
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('unknown-source-zone.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('does not exist' in
|
||||
text_type(ctx.exception))
|
||||
self.assertTrue('does not exist' in str(ctx.exception))
|
||||
|
||||
# Alias zone that points to another alias zone.
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('alias-zone-loop.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('is an alias zone' in
|
||||
text_type(ctx.exception))
|
||||
self.assertTrue('is an alias zone' in str(ctx.exception))
|
||||
|
||||
# Valid config file using an alias zone.
|
||||
Manager(get_config_filename('simple-alias-zone.yaml')) \
|
||||
@@ -342,19 +339,19 @@ class TestManager(TestCase):
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('unknown-processor.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('unknown processor' in text_type(ctx.exception))
|
||||
self.assertTrue('unknown processor' in str(ctx.exception))
|
||||
|
||||
def test_get_zone(self):
|
||||
Manager(get_config_filename('simple.yaml')).get_zone('unit.tests.')
|
||||
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('simple.yaml')).get_zone('unit.tests')
|
||||
self.assertTrue('missing ending dot' in text_type(ctx.exception))
|
||||
self.assertTrue('missing ending dot' in str(ctx.exception))
|
||||
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('simple.yaml')) \
|
||||
.get_zone('unknown-zone.tests.')
|
||||
self.assertTrue('Unknown zone name' in text_type(ctx.exception))
|
||||
self.assertTrue('Unknown zone name' in str(ctx.exception))
|
||||
|
||||
def test_populate_lenient_fallback(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
@@ -379,7 +376,7 @@ class TestManager(TestCase):
|
||||
with self.assertRaises(TypeError) as ctx:
|
||||
manager._populate_and_plan('unit.tests.', [], [OtherType()],
|
||||
[])
|
||||
self.assertEquals('something else', text_type(ctx.exception))
|
||||
self.assertEquals('something else', str(ctx.exception))
|
||||
|
||||
def test_plan_processors_fallback(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
@@ -405,7 +402,7 @@ class TestManager(TestCase):
|
||||
with self.assertRaises(TypeError) as ctx:
|
||||
manager._populate_and_plan('unit.tests.', [], [],
|
||||
[OtherType()])
|
||||
self.assertEquals('something else', text_type(ctx.exception))
|
||||
self.assertEquals('something else', str(ctx.exception))
|
||||
|
||||
@patch('octodns.manager.Manager._get_named_class')
|
||||
def test_sync_passes_file_handle(self, mock):
|
||||
@@ -436,17 +433,17 @@ class TestManager(TestCase):
|
||||
# This zone specifies a non-existant processor
|
||||
manager.sync(['bad.unit.tests.'])
|
||||
self.assertTrue('Zone bad.unit.tests., unknown processor: '
|
||||
'doesnt-exist' in text_type(ctx.exception))
|
||||
'doesnt-exist' in str(ctx.exception))
|
||||
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('processors-missing-class.yaml'))
|
||||
self.assertTrue('Processor no-class is missing class' in
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('processors-wants-config.yaml'))
|
||||
self.assertTrue('Incorrect processor config for wants-config' in
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
def test_processors(self):
|
||||
manager = Manager(get_config_filename('simple.yaml'))
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from io import StringIO
|
||||
from logging import getLogger
|
||||
from six import StringIO, text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.provider.plan import Plan, PlanHtml, PlanLogger, PlanMarkdown
|
||||
@@ -58,8 +58,7 @@ class TestPlanLogger(TestCase):
|
||||
def test_invalid_level(self):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
PlanLogger('invalid', 'not-a-level')
|
||||
self.assertEquals('Unsupported level: not-a-level',
|
||||
text_type(ctx.exception))
|
||||
self.assertEquals('Unsupported level: not-a-level', str(ctx.exception))
|
||||
|
||||
def test_create(self):
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ from azure.mgmt.trafficmanager.models import Profile, DnsConfig, \
|
||||
MonitorConfig, Endpoint, MonitorConfigCustomHeadersItem
|
||||
from msrestazure.azure_exceptions import CloudError
|
||||
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
from mock import Mock, patch, call
|
||||
|
||||
@@ -992,9 +991,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
changes = [Create(unsupported_dynamic)]
|
||||
with self.assertRaises(AzureException) as ctx:
|
||||
provider._extra_changes(existing, desired, changes)
|
||||
self.assertTrue(text_type(ctx).endswith(
|
||||
'must be of type CNAME'
|
||||
))
|
||||
self.assertTrue(str(ctx).endswith('must be of type CNAME'))
|
||||
desired._remove_record(unsupported_dynamic)
|
||||
|
||||
# test colliding ATM names throws exception
|
||||
@@ -1015,9 +1012,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
changes = [Create(record1), Create(record2)]
|
||||
with self.assertRaises(AzureException) as ctx:
|
||||
provider._extra_changes(existing, desired, changes)
|
||||
self.assertTrue(text_type(ctx).startswith(
|
||||
'Collision in Traffic Manager'
|
||||
))
|
||||
self.assertTrue(str(ctx)
|
||||
.startswith('Collision in Traffic Manager'))
|
||||
|
||||
@patch(
|
||||
'octodns.provider.azuredns.AzureProvider._generate_traffic_managers')
|
||||
@@ -1062,7 +1058,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
)]
|
||||
with self.assertRaises(AzureException) as ctx:
|
||||
provider._extra_changes(zone, desired, changes)
|
||||
self.assertTrue('duplicate endpoint' in text_type(ctx))
|
||||
self.assertTrue('duplicate endpoint' in str(ctx))
|
||||
|
||||
def test_extra_changes_A_multi_defaults(self):
|
||||
provider = self._get_provider()
|
||||
@@ -1088,7 +1084,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
desired.add_record(record)
|
||||
with self.assertRaises(AzureException) as ctx:
|
||||
provider._extra_changes(zone, desired, [])
|
||||
self.assertEqual('single value' in text_type(ctx))
|
||||
self.assertEqual('single value' in str(ctx))
|
||||
|
||||
def test_generate_tm_profile(self):
|
||||
provider, zone, record = self._get_dynamic_package()
|
||||
@@ -1194,7 +1190,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
with self.assertRaises(AzureException) as ctx:
|
||||
provider._populate_record(zone, azrecord)
|
||||
self.assertTrue(text_type(ctx).startswith(
|
||||
self.assertTrue(str(ctx).startswith(
|
||||
'Middle East (GEO-ME) is not supported'
|
||||
))
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
|
||||
from logging import getLogger
|
||||
from mock import MagicMock, call
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.processor.base import BaseProcessor
|
||||
@@ -79,7 +78,7 @@ class TestBaseProvider(TestCase):
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
BaseProvider('base')
|
||||
self.assertEquals('Abstract base class, log property missing',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
class HasLog(BaseProvider):
|
||||
log = getLogger('HasLog')
|
||||
@@ -87,7 +86,7 @@ class TestBaseProvider(TestCase):
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
HasLog('haslog')
|
||||
self.assertEquals('Abstract base class, SUPPORTS_GEO property missing',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
class HasSupportsGeo(HasLog):
|
||||
SUPPORTS_GEO = False
|
||||
@@ -96,14 +95,14 @@ class TestBaseProvider(TestCase):
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
HasSupportsGeo('hassupportsgeo').populate(zone)
|
||||
self.assertEquals('Abstract base class, SUPPORTS property missing',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
class HasSupports(HasSupportsGeo):
|
||||
SUPPORTS = set(('A',))
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
HasSupports('hassupports').populate(zone)
|
||||
self.assertEquals('Abstract base class, populate method missing',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
# SUPPORTS_DYNAMIC has a default/fallback
|
||||
self.assertFalse(HasSupports('hassupports').SUPPORTS_DYNAMIC)
|
||||
@@ -149,7 +148,7 @@ class TestBaseProvider(TestCase):
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
HasPopulate('haspopulate').apply(plan)
|
||||
self.assertEquals('Abstract base class, _apply method missing',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
def test_plan(self):
|
||||
ignored = Zone('unit.tests.', [])
|
||||
@@ -321,7 +320,7 @@ class TestBaseProvider(TestCase):
|
||||
})
|
||||
|
||||
for i in range(int(Plan.MIN_EXISTING_RECORDS)):
|
||||
zone.add_record(Record.new(zone, text_type(i), {
|
||||
zone.add_record(Record.new(zone, str(i), {
|
||||
'ttl': 60,
|
||||
'type': 'A',
|
||||
'value': '2.3.4.5'
|
||||
@@ -353,7 +352,7 @@ class TestBaseProvider(TestCase):
|
||||
})
|
||||
|
||||
for i in range(int(Plan.MIN_EXISTING_RECORDS)):
|
||||
zone.add_record(Record.new(zone, text_type(i), {
|
||||
zone.add_record(Record.new(zone, str(i), {
|
||||
'ttl': 60,
|
||||
'type': 'A',
|
||||
'value': '2.3.4.5'
|
||||
@@ -366,7 +365,7 @@ class TestBaseProvider(TestCase):
|
||||
with self.assertRaises(UnsafePlan) as ctx:
|
||||
Plan(zone, zone, changes, True).raise_if_unsafe()
|
||||
|
||||
self.assertTrue('Too many updates' in text_type(ctx.exception))
|
||||
self.assertTrue('Too many updates' in str(ctx.exception))
|
||||
|
||||
def test_safe_updates_min_existing_pcent(self):
|
||||
# MAX_SAFE_UPDATE_PCENT is safe when more
|
||||
@@ -379,7 +378,7 @@ class TestBaseProvider(TestCase):
|
||||
})
|
||||
|
||||
for i in range(int(Plan.MIN_EXISTING_RECORDS)):
|
||||
zone.add_record(Record.new(zone, text_type(i), {
|
||||
zone.add_record(Record.new(zone, str(i), {
|
||||
'ttl': 60,
|
||||
'type': 'A',
|
||||
'value': '2.3.4.5'
|
||||
@@ -401,7 +400,7 @@ class TestBaseProvider(TestCase):
|
||||
})
|
||||
|
||||
for i in range(int(Plan.MIN_EXISTING_RECORDS)):
|
||||
zone.add_record(Record.new(zone, text_type(i), {
|
||||
zone.add_record(Record.new(zone, str(i), {
|
||||
'ttl': 60,
|
||||
'type': 'A',
|
||||
'value': '2.3.4.5'
|
||||
@@ -414,7 +413,7 @@ class TestBaseProvider(TestCase):
|
||||
with self.assertRaises(UnsafePlan) as ctx:
|
||||
Plan(zone, zone, changes, True).raise_if_unsafe()
|
||||
|
||||
self.assertTrue('Too many deletes' in text_type(ctx.exception))
|
||||
self.assertTrue('Too many deletes' in str(ctx.exception))
|
||||
|
||||
def test_safe_deletes_min_existing_pcent(self):
|
||||
# MAX_SAFE_DELETE_PCENT is safe when more
|
||||
@@ -427,7 +426,7 @@ class TestBaseProvider(TestCase):
|
||||
})
|
||||
|
||||
for i in range(int(Plan.MIN_EXISTING_RECORDS)):
|
||||
zone.add_record(Record.new(zone, text_type(i), {
|
||||
zone.add_record(Record.new(zone, str(i), {
|
||||
'ttl': 60,
|
||||
'type': 'A',
|
||||
'value': '2.3.4.5'
|
||||
@@ -450,7 +449,7 @@ class TestBaseProvider(TestCase):
|
||||
})
|
||||
|
||||
for i in range(int(Plan.MIN_EXISTING_RECORDS)):
|
||||
zone.add_record(Record.new(zone, text_type(i), {
|
||||
zone.add_record(Record.new(zone, str(i), {
|
||||
'ttl': 60,
|
||||
'type': 'A',
|
||||
'value': '2.3.4.5'
|
||||
@@ -464,7 +463,7 @@ class TestBaseProvider(TestCase):
|
||||
Plan(zone, zone, changes, True,
|
||||
update_pcent_threshold=safe_pcent).raise_if_unsafe()
|
||||
|
||||
self.assertTrue('Too many updates' in text_type(ctx.exception))
|
||||
self.assertTrue('Too many updates' in str(ctx.exception))
|
||||
|
||||
def test_safe_deletes_min_existing_override(self):
|
||||
safe_pcent = .4
|
||||
@@ -478,7 +477,7 @@ class TestBaseProvider(TestCase):
|
||||
})
|
||||
|
||||
for i in range(int(Plan.MIN_EXISTING_RECORDS)):
|
||||
zone.add_record(Record.new(zone, text_type(i), {
|
||||
zone.add_record(Record.new(zone, str(i), {
|
||||
'ttl': 60,
|
||||
'type': 'A',
|
||||
'value': '2.3.4.5'
|
||||
@@ -492,7 +491,7 @@ class TestBaseProvider(TestCase):
|
||||
Plan(zone, zone, changes, True,
|
||||
delete_pcent_threshold=safe_pcent).raise_if_unsafe()
|
||||
|
||||
self.assertTrue('Too many deletes' in text_type(ctx.exception))
|
||||
self.assertTrue('Too many deletes' in str(ctx.exception))
|
||||
|
||||
def test_supports_warn_or_except(self):
|
||||
class MinimalProvider(BaseProvider):
|
||||
@@ -515,5 +514,5 @@ class TestBaseProvider(TestCase):
|
||||
# Should log and not expect
|
||||
with self.assertRaises(SupportsException) as ctx:
|
||||
strict.supports_warn_or_except('Hello World!', 'Will not see')
|
||||
self.assertEquals('minimal: Hello World!', text_type(ctx.exception))
|
||||
self.assertEquals('minimal: Hello World!', str(ctx.exception))
|
||||
strict.log.warning.assert_not_called()
|
||||
|
||||
@@ -9,7 +9,6 @@ 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, Update
|
||||
@@ -67,7 +66,7 @@ class TestCloudflareProvider(TestCase):
|
||||
provider.populate(zone)
|
||||
|
||||
self.assertEquals('CloudflareError', type(ctx.exception).__name__)
|
||||
self.assertEquals('request was invalid', text_type(ctx.exception))
|
||||
self.assertEquals('request was invalid', str(ctx.exception))
|
||||
|
||||
# Bad auth
|
||||
with requests_mock() as mock:
|
||||
@@ -82,7 +81,7 @@ class TestCloudflareProvider(TestCase):
|
||||
self.assertEquals('CloudflareAuthenticationError',
|
||||
type(ctx.exception).__name__)
|
||||
self.assertEquals('Unknown X-Auth-Key or X-Auth-Email',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
# Bad auth, unknown resp
|
||||
with requests_mock() as mock:
|
||||
@@ -93,7 +92,7 @@ class TestCloudflareProvider(TestCase):
|
||||
provider.populate(zone)
|
||||
self.assertEquals('CloudflareAuthenticationError',
|
||||
type(ctx.exception).__name__)
|
||||
self.assertEquals('Cloudflare error', text_type(ctx.exception))
|
||||
self.assertEquals('Cloudflare error', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
@@ -120,7 +119,7 @@ class TestCloudflareProvider(TestCase):
|
||||
type(ctx.exception).__name__)
|
||||
self.assertEquals('More than 1200 requests per 300 seconds '
|
||||
'reached. Please wait and consider throttling '
|
||||
'your request speed', text_type(ctx.exception))
|
||||
'your request speed', str(ctx.exception))
|
||||
|
||||
# Rate Limit error, unknown resp
|
||||
with requests_mock() as mock:
|
||||
@@ -132,7 +131,7 @@ class TestCloudflareProvider(TestCase):
|
||||
|
||||
self.assertEquals('CloudflareRateLimitError',
|
||||
type(ctx.exception).__name__)
|
||||
self.assertEquals('Cloudflare error', text_type(ctx.exception))
|
||||
self.assertEquals('Cloudflare error', str(ctx.exception))
|
||||
|
||||
# Non-existent zone doesn't populate anything
|
||||
with requests_mock() as mock:
|
||||
@@ -1625,7 +1624,7 @@ class TestCloudflareProvider(TestCase):
|
||||
]
|
||||
with self.assertRaises(CloudflareRateLimitError) as ctx:
|
||||
provider.zone_records(zone)
|
||||
self.assertEquals('last', text_type(ctx.exception))
|
||||
self.assertEquals('last', str(ctx.exception))
|
||||
|
||||
def test_ttl_mapping(self):
|
||||
provider = CloudflareProvider('test', 'email', 'token')
|
||||
|
||||
@@ -10,7 +10,6 @@ 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
|
||||
@@ -156,7 +155,7 @@ class TestConstellixProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# Bad request
|
||||
with requests_mock() as mock:
|
||||
@@ -168,7 +167,7 @@ class TestConstellixProvider(TestCase):
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('\n - "unittests" is not a valid domain name',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -10,7 +10,6 @@ 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
|
||||
@@ -51,7 +50,7 @@ class TestDigitalOceanProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -9,7 +9,6 @@ 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
|
||||
@@ -54,7 +53,7 @@ class TestDnsimpleProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -10,7 +10,6 @@ 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
|
||||
@@ -60,7 +59,7 @@ class TestDnsMadeEasyProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# Bad request
|
||||
with requests_mock() as mock:
|
||||
@@ -70,8 +69,7 @@ class TestDnsMadeEasyProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('\n - Rate limit exceeded',
|
||||
text_type(ctx.exception))
|
||||
self.assertEquals('\n - Rate limit exceeded', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -10,7 +10,6 @@ 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
|
||||
@@ -37,7 +36,7 @@ class TestEasyDNSProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# Bad request
|
||||
with requests_mock() as mock:
|
||||
@@ -48,7 +47,7 @@ class TestEasyDNSProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Bad request', text_type(ctx.exception))
|
||||
self.assertEquals('Bad request', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
@@ -102,7 +101,7 @@ class TestEasyDNSProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
provider._client.domain('unit.tests')
|
||||
|
||||
self.assertEquals('Not Found', text_type(ctx.exception))
|
||||
self.assertEquals('Not Found', str(ctx.exception))
|
||||
|
||||
def test_apply_not_found(self):
|
||||
provider = EasyDNSProvider('test', 'token', 'apikey',
|
||||
@@ -137,7 +136,7 @@ class TestEasyDNSProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
provider.apply(plan)
|
||||
|
||||
self.assertEquals('Not Found', text_type(ctx.exception))
|
||||
self.assertEquals('Not Found', str(ctx.exception))
|
||||
|
||||
def test_domain_create(self):
|
||||
provider = EasyDNSProvider('test', 'token', 'apikey',
|
||||
|
||||
@@ -9,7 +9,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
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
|
||||
@@ -149,7 +148,7 @@ class TestEdgeDnsProvider(TestCase):
|
||||
changes = provider.apply(plan)
|
||||
except NameError as e:
|
||||
expected = "contractId not specified to create zone"
|
||||
self.assertEquals(text_type(e), expected)
|
||||
self.assertEquals(str(e), expected)
|
||||
|
||||
|
||||
class TestDeprecatedAkamaiProvider(TestCase):
|
||||
|
||||
@@ -9,7 +9,6 @@ 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
|
||||
@@ -58,7 +57,7 @@ class TestGandiProvider(TestCase):
|
||||
with self.assertRaises(GandiClientBadRequest) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertIn('"status": "error"', text_type(ctx.exception))
|
||||
self.assertIn('"status": "error"', str(ctx.exception))
|
||||
|
||||
# 401 - Unauthorized.
|
||||
with requests_mock() as mock:
|
||||
@@ -73,7 +72,7 @@ class TestGandiProvider(TestCase):
|
||||
with self.assertRaises(GandiClientUnauthorized) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertIn('"cause":"Unauthorized"', text_type(ctx.exception))
|
||||
self.assertIn('"cause":"Unauthorized"', str(ctx.exception))
|
||||
|
||||
# 403 - Forbidden.
|
||||
with requests_mock() as mock:
|
||||
@@ -85,7 +84,7 @@ class TestGandiProvider(TestCase):
|
||||
with self.assertRaises(GandiClientForbidden) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertIn('"cause":"Forbidden"', text_type(ctx.exception))
|
||||
self.assertIn('"cause":"Forbidden"', str(ctx.exception))
|
||||
|
||||
# 404 - Not Found.
|
||||
with requests_mock() as mock:
|
||||
@@ -97,7 +96,7 @@ class TestGandiProvider(TestCase):
|
||||
with self.assertRaises(GandiClientNotFound) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider._client.zone(zone)
|
||||
self.assertIn('"cause": "Not Found"', text_type(ctx.exception))
|
||||
self.assertIn('"cause": "Not Found"', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
@@ -175,7 +174,7 @@ class TestGandiProvider(TestCase):
|
||||
plan = provider.plan(self.expected)
|
||||
provider.apply(plan)
|
||||
self.assertIn('This domain is not registered at Gandi.',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
resp = Mock()
|
||||
resp.json = Mock()
|
||||
|
||||
@@ -12,7 +12,6 @@ from __future__ import (
|
||||
from mock import Mock, call
|
||||
from os.path import dirname, join
|
||||
from requests_mock import ANY, mock as requests_mock
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.record import Record, Update, Delete, Create
|
||||
@@ -52,7 +51,7 @@ class TestGCoreProvider(TestCase):
|
||||
with self.assertRaises(GCoreClientBadRequest) as ctx:
|
||||
zone = Zone("unit.tests.", [])
|
||||
provider.populate(zone)
|
||||
self.assertIn('"error":"bad body"', text_type(ctx.exception))
|
||||
self.assertIn('"error":"bad body"', str(ctx.exception))
|
||||
|
||||
# TC: 404 - Not Found.
|
||||
with requests_mock() as mock:
|
||||
@@ -64,7 +63,7 @@ class TestGCoreProvider(TestCase):
|
||||
zone = Zone("unit.tests.", [])
|
||||
provider._client.zone(zone.name)
|
||||
self.assertIn(
|
||||
'"error":"zone is not found"', text_type(ctx.exception)
|
||||
'"error":"zone is not found"', str(ctx.exception)
|
||||
)
|
||||
|
||||
# TC: General error
|
||||
@@ -74,7 +73,7 @@ class TestGCoreProvider(TestCase):
|
||||
with self.assertRaises(GCoreClientException) as ctx:
|
||||
zone = Zone("unit.tests.", [])
|
||||
provider.populate(zone)
|
||||
self.assertEqual("Things caught fire", text_type(ctx.exception))
|
||||
self.assertEqual("Things caught fire", str(ctx.exception))
|
||||
|
||||
# TC: No credentials or token error
|
||||
with requests_mock() as mock:
|
||||
@@ -82,7 +81,7 @@ class TestGCoreProvider(TestCase):
|
||||
GCoreProvider("test_id")
|
||||
self.assertEqual(
|
||||
"either token or login & password must be set",
|
||||
text_type(ctx.exception),
|
||||
str(ctx.exception),
|
||||
)
|
||||
|
||||
# TC: Auth with login password
|
||||
@@ -230,7 +229,7 @@ class TestGCoreProvider(TestCase):
|
||||
provider.apply(plan)
|
||||
self.assertIn(
|
||||
"parent zone is already occupied by another client",
|
||||
text_type(ctx.exception),
|
||||
str(ctx.exception),
|
||||
)
|
||||
|
||||
resp = Mock()
|
||||
|
||||
@@ -10,7 +10,6 @@ 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
|
||||
@@ -36,7 +35,7 @@ class TestHetznerProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -8,7 +8,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
from os.path import dirname, join
|
||||
|
||||
from requests_mock import ANY, mock as requests_mock
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.provider.mythicbeasts import MythicBeastsProvider, \
|
||||
@@ -32,12 +31,12 @@ class TestMythicBeastsProvider(TestCase):
|
||||
with self.assertRaises(AssertionError) as err:
|
||||
add_trailing_dot('unit.tests.')
|
||||
self.assertEquals('Value already has trailing dot',
|
||||
text_type(err.exception))
|
||||
str(err.exception))
|
||||
|
||||
with self.assertRaises(AssertionError) as err:
|
||||
remove_trailing_dot('unit.tests')
|
||||
self.assertEquals('Value already missing trailing dot',
|
||||
text_type(err.exception))
|
||||
str(err.exception))
|
||||
|
||||
self.assertEquals(add_trailing_dot('unit.tests'), 'unit.tests.')
|
||||
self.assertEquals(remove_trailing_dot('unit.tests.'), 'unit.tests')
|
||||
@@ -91,8 +90,7 @@ class TestMythicBeastsProvider(TestCase):
|
||||
'',
|
||||
{'raw_values': [{'value': '', 'ttl': 0}]}
|
||||
)
|
||||
self.assertEquals('Unable to parse MX data',
|
||||
text_type(err.exception))
|
||||
self.assertEquals('Unable to parse MX data', str(err.exception))
|
||||
|
||||
def test_data_for_CNAME(self):
|
||||
test_data = {
|
||||
@@ -129,8 +127,7 @@ class TestMythicBeastsProvider(TestCase):
|
||||
'',
|
||||
{'raw_values': [{'value': '', 'ttl': 0}]}
|
||||
)
|
||||
self.assertEquals('Unable to parse SRV data',
|
||||
text_type(err.exception))
|
||||
self.assertEquals('Unable to parse SRV data', str(err.exception))
|
||||
|
||||
def test_data_for_SSHFP(self):
|
||||
test_data = {
|
||||
@@ -149,8 +146,7 @@ class TestMythicBeastsProvider(TestCase):
|
||||
'',
|
||||
{'raw_values': [{'value': '', 'ttl': 0}]}
|
||||
)
|
||||
self.assertEquals('Unable to parse SSHFP data',
|
||||
text_type(err.exception))
|
||||
self.assertEquals('Unable to parse SSHFP data', str(err.exception))
|
||||
|
||||
def test_data_for_CAA(self):
|
||||
test_data = {
|
||||
@@ -166,8 +162,7 @@ class TestMythicBeastsProvider(TestCase):
|
||||
'',
|
||||
{'raw_values': [{'value': '', 'ttl': 0}]}
|
||||
)
|
||||
self.assertEquals('Unable to parse CAA data',
|
||||
text_type(err.exception))
|
||||
self.assertEquals('Unable to parse CAA data', str(err.exception))
|
||||
|
||||
def test_command_generation(self):
|
||||
zone = Zone('unit.tests.', [])
|
||||
@@ -312,8 +307,7 @@ class TestMythicBeastsProvider(TestCase):
|
||||
# Null passwords dict
|
||||
with self.assertRaises(AssertionError) as err:
|
||||
provider = MythicBeastsProvider('test', None)
|
||||
self.assertEquals('Passwords must be a dictionary',
|
||||
text_type(err.exception))
|
||||
self.assertEquals('Passwords must be a dictionary', str(err.exception))
|
||||
|
||||
# Missing password
|
||||
with requests_mock() as mock:
|
||||
@@ -323,9 +317,8 @@ class TestMythicBeastsProvider(TestCase):
|
||||
provider = MythicBeastsProvider('test', dict())
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(
|
||||
'Missing password for domain: unit.tests',
|
||||
text_type(err.exception))
|
||||
self.assertEquals('Missing password for domain: unit.tests',
|
||||
str(err.exception))
|
||||
|
||||
# Failed authentication
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -9,7 +9,6 @@ from collections import defaultdict
|
||||
from mock import call, patch
|
||||
from ns1.rest.errors import AuthException, RateLimitException, \
|
||||
ResourceException
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.record import Delete, Record, Update
|
||||
@@ -1584,8 +1583,7 @@ class TestNs1ProviderDynamic(TestCase):
|
||||
}
|
||||
with self.assertRaises(Ns1Exception) as ctx:
|
||||
provider._data_for_dynamic('A', ns1_record)
|
||||
self.assertEquals('Unrecognized advanced record',
|
||||
text_type(ctx.exception))
|
||||
self.assertEquals('Unrecognized advanced record', str(ctx.exception))
|
||||
|
||||
# empty record turns into empty data
|
||||
ns1_record = {
|
||||
@@ -2150,8 +2148,7 @@ class TestNs1ProviderDynamic(TestCase):
|
||||
records_retrieve_mock.side_effect = ns1_zone['records']
|
||||
with self.assertRaises(Ns1Exception) as ctx:
|
||||
extra = provider._extra_changes(desired, [])
|
||||
self.assertTrue('Mixed disabled flag in filters' in
|
||||
text_type(ctx.exception))
|
||||
self.assertTrue('Mixed disabled flag in filters' in str(ctx.exception))
|
||||
|
||||
DESIRED = Zone('unit.tests.', [])
|
||||
|
||||
@@ -2231,14 +2228,14 @@ class TestNs1ProviderDynamic(TestCase):
|
||||
apply_update_mock.reset_mock()
|
||||
with self.assertRaises(Ns1Exception) as ctx:
|
||||
provider._apply(dynamic_plan)
|
||||
self.assertTrue('monitor_regions not set' in text_type(ctx.exception))
|
||||
self.assertTrue('monitor_regions not set' in str(ctx.exception))
|
||||
apply_update_mock.assert_not_called()
|
||||
|
||||
# Blows up and apply not called even though there's a simple
|
||||
apply_update_mock.reset_mock()
|
||||
with self.assertRaises(Ns1Exception) as ctx:
|
||||
provider._apply(both_plan)
|
||||
self.assertTrue('monitor_regions not set' in text_type(ctx.exception))
|
||||
self.assertTrue('monitor_regions not set' in str(ctx.exception))
|
||||
apply_update_mock.assert_not_called()
|
||||
|
||||
# with monitor_regions set
|
||||
@@ -2296,7 +2293,7 @@ class TestNs1Client(TestCase):
|
||||
]
|
||||
with self.assertRaises(RateLimitException) as ctx:
|
||||
client.zones_retrieve('unit.tests')
|
||||
self.assertEquals('last', text_type(ctx.exception))
|
||||
self.assertEquals('last', str(ctx.exception))
|
||||
|
||||
def test_client_config(self):
|
||||
with self.assertRaises(TypeError):
|
||||
|
||||
@@ -9,7 +9,6 @@ from json import loads, dumps
|
||||
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
|
||||
@@ -51,7 +50,7 @@ class TestPowerDnsProvider(TestCase):
|
||||
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
provider.powerdns_version
|
||||
self.assertTrue('unauthorized' in text_type(ctx.exception))
|
||||
self.assertTrue('unauthorized' in str(ctx.exception))
|
||||
|
||||
# Api not found
|
||||
with requests_mock() as mock:
|
||||
@@ -59,7 +58,7 @@ class TestPowerDnsProvider(TestCase):
|
||||
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
provider.powerdns_version
|
||||
self.assertTrue('404' in text_type(ctx.exception))
|
||||
self.assertTrue('404' in str(ctx.exception))
|
||||
|
||||
# Test version detection
|
||||
with requests_mock() as mock:
|
||||
@@ -150,7 +149,7 @@ class TestPowerDnsProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertTrue('unauthorized' in text_type(ctx.exception))
|
||||
self.assertTrue('unauthorized' in str(ctx.exception))
|
||||
|
||||
# General error
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -7,8 +7,7 @@ from __future__ import absolute_import, division, print_function, \
|
||||
|
||||
import json
|
||||
import re
|
||||
from six import text_type
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from urllib.parse import urlparse
|
||||
from unittest import TestCase
|
||||
|
||||
from requests import HTTPError
|
||||
@@ -53,7 +52,7 @@ class TestRackspaceProvider(TestCase):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
zone = Zone('unit.tests.', [])
|
||||
self.provider.populate(zone)
|
||||
self.assertTrue('unauthorized' in text_type(ctx.exception))
|
||||
self.assertTrue('unauthorized' in str(ctx.exception))
|
||||
self.assertTrue(mock.called_once)
|
||||
|
||||
def test_server_error(self):
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from botocore.stub import ANY, Stubber
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
from mock import patch
|
||||
|
||||
@@ -2400,7 +2399,7 @@ class TestRoute53Provider(TestCase):
|
||||
provider, plan = self._get_test_plan(1)
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
provider.apply(plan)
|
||||
self.assertTrue('modifications' in text_type(ctx.exception))
|
||||
self.assertTrue('modifications' in str(ctx.exception))
|
||||
|
||||
def test_semicolon_fixup(self):
|
||||
provider = Route53Provider('test', 'abc', '123')
|
||||
|
||||
@@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from unittest import TestCase
|
||||
from six import text_type
|
||||
|
||||
import requests_mock
|
||||
|
||||
@@ -288,7 +287,7 @@ class TestSelectelProvider(TestCase):
|
||||
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
SelectelProvider(123, 'fail_token')
|
||||
self.assertEquals(text_type(ctx.exception),
|
||||
self.assertEquals(str(ctx.exception),
|
||||
'Authorization failed. Invalid or empty token.')
|
||||
|
||||
@requests_mock.Mocker()
|
||||
|
||||
@@ -4,8 +4,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 six.moves.urllib import parse
|
||||
from urllib.parse import parse_qs
|
||||
from unittest import TestCase
|
||||
from json import load as json_load
|
||||
|
||||
@@ -45,7 +44,7 @@ class TestUltraProvider(TestCase):
|
||||
text='{"errorCode": 60001}')
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
UltraProvider('test', 'account', 'user', 'wrongpass')
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# Good Auth
|
||||
with requests_mock() as mock:
|
||||
@@ -58,8 +57,8 @@ class TestUltraProvider(TestCase):
|
||||
self.assertEquals(1, mock.call_count)
|
||||
expected_payload = "grant_type=password&username=user&"\
|
||||
"password=rightpass"
|
||||
self.assertEquals(parse.parse_qs(mock.last_request.text),
|
||||
parse.parse_qs(expected_payload))
|
||||
self.assertEquals(parse_qs(mock.last_request.text),
|
||||
parse_qs(expected_payload))
|
||||
|
||||
def test_get_zones(self):
|
||||
provider = _get_provider()
|
||||
@@ -145,7 +144,7 @@ class TestUltraProvider(TestCase):
|
||||
headers={'Authorization': 'Bearer 123'}, json={})
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
provider._get(path)
|
||||
self.assertEquals('Unauthorized', text_type(ctx.exception))
|
||||
self.assertEquals('Unauthorized', str(ctx.exception))
|
||||
|
||||
# Test all GET patterns
|
||||
with requests_mock() as mock:
|
||||
|
||||
@@ -8,7 +8,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
from os import makedirs
|
||||
from os.path import basename, dirname, isdir, isfile, join
|
||||
from unittest import TestCase
|
||||
from six import text_type
|
||||
from yaml import safe_load
|
||||
from yaml.constructor import ConstructorError
|
||||
|
||||
@@ -187,7 +186,7 @@ class TestYamlProvider(TestCase):
|
||||
with self.assertRaises(SubzoneRecordException) as ctx:
|
||||
source.populate(zone)
|
||||
self.assertEquals('Record www.sub.unit.tests. is under a managed '
|
||||
'subzone', text_type(ctx.exception))
|
||||
'subzone', str(ctx.exception))
|
||||
|
||||
|
||||
class TestSplitYamlProvider(TestCase):
|
||||
@@ -385,7 +384,7 @@ class TestSplitYamlProvider(TestCase):
|
||||
with self.assertRaises(SubzoneRecordException) as ctx:
|
||||
source.populate(zone)
|
||||
self.assertEquals('Record www.sub.unit.tests. is under a managed '
|
||||
'subzone', text_type(ctx.exception))
|
||||
'subzone', str(ctx.exception))
|
||||
|
||||
|
||||
class TestOverridingYamlProvider(TestCase):
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.record import ARecord, AaaaRecord, AliasRecord, CaaRecord, \
|
||||
@@ -1013,14 +1012,14 @@ class TestRecord(TestCase):
|
||||
# Missing type
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
Record.new(self.zone, 'unknown', {})
|
||||
self.assertTrue('missing type' in text_type(ctx.exception))
|
||||
self.assertTrue('missing type' in str(ctx.exception))
|
||||
|
||||
# Unknown type
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
Record.new(self.zone, 'unknown', {
|
||||
'type': 'XXX',
|
||||
})
|
||||
self.assertTrue('Unknown record type' in text_type(ctx.exception))
|
||||
self.assertTrue('Unknown record type' in str(ctx.exception))
|
||||
|
||||
def test_record_copy(self):
|
||||
a = Record.new(self.zone, 'a', {
|
||||
|
||||
@@ -11,7 +11,6 @@ from dns.exception import DNSException
|
||||
from mock import patch
|
||||
from os.path import exists
|
||||
from shutil import copyfile
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.source.axfr import AxfrSource, AxfrSourceZoneTransferFailed, \
|
||||
@@ -42,7 +41,7 @@ class TestAxfrSource(TestCase):
|
||||
zone = Zone('unit.tests.', [])
|
||||
self.source.populate(zone)
|
||||
self.assertEquals('Unable to Perform Zone Transfer',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
|
||||
class TestZoneFileSource(TestCase):
|
||||
@@ -99,7 +98,7 @@ class TestZoneFileSource(TestCase):
|
||||
zone = Zone('invalid.zone.', [])
|
||||
self.source.populate(zone)
|
||||
self.assertEquals('The DNS zone has no NS RRset at its origin.',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
# Records are not to RFC (lenient=False)
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
@@ -107,7 +106,7 @@ class TestZoneFileSource(TestCase):
|
||||
self.source.populate(zone)
|
||||
self.assertEquals('Invalid record _invalid.invalid.records.\n'
|
||||
' - invalid name for SRV record',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
|
||||
# Records are not to RFC, but load anyhow (lenient=True)
|
||||
invalid = Zone('invalid.records.', [])
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from mock import patch
|
||||
from six import text_type
|
||||
from unittest import TestCase
|
||||
|
||||
from octodns.source.envvar import EnvVarSource
|
||||
@@ -15,7 +14,7 @@ class TestEnvVarSource(TestCase):
|
||||
with self.assertRaises(EnvironmentVariableNotFoundException) as ctx:
|
||||
source._read_variable()
|
||||
msg = f'Unknown environment variable {envvar}'
|
||||
self.assertEquals(msg, text_type(ctx.exception))
|
||||
self.assertEquals(msg, str(ctx.exception))
|
||||
|
||||
with patch.dict('os.environ', {envvar: 'testvalue'}):
|
||||
value = source._read_variable()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from six import StringIO
|
||||
from io import StringIO
|
||||
from unittest import TestCase
|
||||
from yaml.constructor import ConstructorError
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from unittest import TestCase
|
||||
from six import text_type
|
||||
|
||||
from octodns.record import ARecord, AaaaRecord, Create, Delete, Record, Update
|
||||
from octodns.zone import DuplicateRecordException, InvalidNodeException, \
|
||||
@@ -48,7 +47,7 @@ class TestZone(TestCase):
|
||||
with self.assertRaises(DuplicateRecordException) as ctx:
|
||||
zone.add_record(a)
|
||||
self.assertEquals('Duplicate record a.unit.tests., type A',
|
||||
text_type(ctx.exception))
|
||||
str(ctx.exception))
|
||||
self.assertEquals(zone.records, set([a]))
|
||||
|
||||
# can add duplicate with replace=True
|
||||
@@ -138,7 +137,7 @@ class TestZone(TestCase):
|
||||
def test_missing_dot(self):
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
Zone('not.allowed', [])
|
||||
self.assertTrue('missing ending dot' in text_type(ctx.exception))
|
||||
self.assertTrue('missing ending dot' in str(ctx.exception))
|
||||
|
||||
def test_sub_zones(self):
|
||||
|
||||
@@ -161,7 +160,7 @@ class TestZone(TestCase):
|
||||
})
|
||||
with self.assertRaises(SubzoneRecordException) as ctx:
|
||||
zone.add_record(record)
|
||||
self.assertTrue('not of type NS', text_type(ctx.exception))
|
||||
self.assertTrue('not of type NS', str(ctx.exception))
|
||||
# Can add it w/lenient
|
||||
zone.add_record(record, lenient=True)
|
||||
self.assertEquals(set([record]), zone.records)
|
||||
@@ -175,7 +174,7 @@ class TestZone(TestCase):
|
||||
})
|
||||
with self.assertRaises(SubzoneRecordException) as ctx:
|
||||
zone.add_record(record)
|
||||
self.assertTrue('under a managed sub-zone', text_type(ctx.exception))
|
||||
self.assertTrue('under a managed sub-zone', str(ctx.exception))
|
||||
# Can add it w/lenient
|
||||
zone.add_record(record, lenient=True)
|
||||
self.assertEquals(set([record]), zone.records)
|
||||
@@ -189,7 +188,7 @@ class TestZone(TestCase):
|
||||
})
|
||||
with self.assertRaises(SubzoneRecordException) as ctx:
|
||||
zone.add_record(record)
|
||||
self.assertTrue('under a managed sub-zone', text_type(ctx.exception))
|
||||
self.assertTrue('under a managed sub-zone', str(ctx.exception))
|
||||
# Can add it w/lenient
|
||||
zone.add_record(record, lenient=True)
|
||||
self.assertEquals(set([record]), zone.records)
|
||||
|
||||
Reference in New Issue
Block a user