summaryrefslogtreecommitdiff
path: root/designateclient/functionaltests/v2
diff options
context:
space:
mode:
authorRahman Syed <rahman.syed@gmail.com>2016-03-22 17:08:18 -0500
committerRahman Syed <rahman.syed@gmail.com>2016-03-23 20:34:14 -0500
commitce50ad944490e6238597a72106f5be705db3aae8 (patch)
treeb004924adfdbe4e511354d665f6f5c16c8a5ef62 /designateclient/functionaltests/v2
parent575917105b51ab5ce37c61d1afee6301e3cdd9de (diff)
downloadpython-designateclient-ce50ad944490e6238597a72106f5be705db3aae8.tar.gz
Implement zone export
Zone export commands (create, list, show, delete, showfile) are missing from the python-designateclient. This change includes implementation, as well as unit tests and functionaltests. Change-Id: I957946d739bceea1074e2fda2ce7f841143b0611 Partial-Bug: #1550532
Diffstat (limited to 'designateclient/functionaltests/v2')
-rw-r--r--designateclient/functionaltests/v2/fixtures.py25
-rw-r--r--designateclient/functionaltests/v2/test_zone_export.py94
2 files changed, 119 insertions, 0 deletions
diff --git a/designateclient/functionaltests/v2/fixtures.py b/designateclient/functionaltests/v2/fixtures.py
index 54c3daa..2e61148 100644
--- a/designateclient/functionaltests/v2/fixtures.py
+++ b/designateclient/functionaltests/v2/fixtures.py
@@ -98,6 +98,31 @@ class TransferRequestFixture(BaseFixture):
pass
+class ExportFixture(BaseFixture):
+ """See DesignateCLI.zone_export_create for __init__ args"""
+
+ def __init__(self, zone, user='default', *args, **kwargs):
+ super(ExportFixture, self).__init__(user, *args, **kwargs)
+ self.zone = zone
+
+ def _setUp(self):
+ super(ExportFixture, self)._setUp()
+ self.zone_export = self.client.zone_export_create(
+ zone_id=self.zone.id,
+ *self.args, **self.kwargs
+ )
+ self.addCleanup(self.cleanup_zone_export, self.client,
+ self.zone_export.id)
+ self.addCleanup(ZoneFixture.cleanup_zone, self.client, self.zone.id)
+
+ @classmethod
+ def cleanup_zone_export(cls, client, zone_export_id):
+ try:
+ client.zone_export_delete(zone_export_id)
+ except CommandFailed:
+ pass
+
+
class RecordsetFixture(BaseFixture):
"""See DesignateCLI.recordset_create for __init__ args"""
diff --git a/designateclient/functionaltests/v2/test_zone_export.py b/designateclient/functionaltests/v2/test_zone_export.py
new file mode 100644
index 0000000..fc10f85
--- /dev/null
+++ b/designateclient/functionaltests/v2/test_zone_export.py
@@ -0,0 +1,94 @@
+"""
+Copyright 2016 Rackspace
+
+Author: Rahman Syed <rahman.syed@gmail.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+from designateclient.functionaltests.base import BaseDesignateTest
+from designateclient.functionaltests.datagen import random_zone_name
+from designateclient.functionaltests.v2.fixtures import ExportFixture
+from designateclient.functionaltests.v2.fixtures import ZoneFixture
+
+
+class TestZoneExport(BaseDesignateTest):
+
+ def setUp(self):
+ super(TestZoneExport, self).setUp()
+ self.ensure_tld_exists('com')
+ fixture = self.useFixture(ZoneFixture(
+ name=random_zone_name(),
+ email='test@example.com',
+ ))
+ self.zone = fixture.zone
+
+ def test_list_zone_exports(self):
+ zone_export = self.useFixture(ExportFixture(
+ zone=self.zone
+ )).zone_export
+
+ zone_exports = self.clients.zone_export_list()
+ self.assertGreater(len(zone_exports), 0)
+ self.assertTrue(self._is_export_in_list(zone_export, zone_exports))
+
+ def test_create_and_show_zone_export(self):
+ zone_export = self.useFixture(ExportFixture(
+ zone=self.zone
+ )).zone_export
+
+ fetched_export = self.clients.zone_export_show(zone_export.id)
+
+ self.assertEqual(zone_export.created_at, fetched_export.created_at)
+ self.assertEqual(zone_export.id, fetched_export.id)
+ self.assertEqual(zone_export.message, fetched_export.message)
+ self.assertEqual(zone_export.project_id, fetched_export.project_id)
+ self.assertEqual(zone_export.zone_id, fetched_export.zone_id)
+
+ def test_delete_zone_export(self):
+ zone_export = self.useFixture(ExportFixture(
+ zone=self.zone
+ )).zone_export
+
+ zone_exports = self.clients.zone_export_list()
+ self.assertTrue(self._is_export_in_list(zone_export, zone_exports))
+
+ self.clients.zone_export_delete(zone_export.id)
+
+ zone_exports = self.clients.zone_export_list()
+ self.assertFalse(self._is_export_in_list(zone_export, zone_exports))
+
+ def test_show_export_file(self):
+ zone_export = self.useFixture(ExportFixture(
+ zone=self.zone
+ )).zone_export
+
+ fetched_export = self.clients.zone_export_showfile(zone_export.id)
+
+ self.assertIn('$ORIGIN', fetched_export.data)
+ self.assertIn('$TTL', fetched_export.data)
+ self.assertIn('SOA', fetched_export.data)
+ self.assertIn('NS', fetched_export.data)
+ self.assertIn(self.zone.name, fetched_export.data)
+
+ def _is_export_in_list(self, zone_export, zone_export_list):
+ """Determines if the given export exists in the given export list.
+
+ Uses the zone export id for comparison.
+
+ Because the zone export list command displays fewer fields than
+ the show command, an __eq__ method on the FieldValueModel class
+ is insufficient.
+
+ """
+ return any([export_record.id == zone_export.id
+ for export_record in zone_export_list])