2015-03-05 17:49:23 +00:00
|
|
|
"""
|
|
|
|
Copyright 2015 Rackspace
|
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
2015-03-13 15:19:00 +00:00
|
|
|
from functionaltests.api.v2.clients.zone_client import ZoneClient
|
|
|
|
from functionaltests.api.v2.clients.quotas_client import QuotasClient
|
|
|
|
from functionaltests.api.v2.models.quotas_model import QuotasModel
|
|
|
|
from functionaltests.common import datagen
|
|
|
|
from functionaltests.common.base import BaseDesignateTest
|
2015-03-05 17:49:23 +00:00
|
|
|
|
|
|
|
|
2015-03-13 15:19:00 +00:00
|
|
|
class ZoneTest(BaseDesignateTest):
|
2015-03-05 17:49:23 +00:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(ZoneTest, self).__init__(*args, **kwargs)
|
2015-03-13 15:19:00 +00:00
|
|
|
self.client = ZoneClient(self.base_client)
|
|
|
|
self.quotas_client = QuotasClient(self.base_client)
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(ZoneTest, self).setUp()
|
|
|
|
self.quotas_client.patch_quotas(
|
|
|
|
self.quotas_client.client.tenant_id,
|
|
|
|
QuotasModel.from_dict({
|
|
|
|
'quota': {
|
|
|
|
'zones': 9999999,
|
|
|
|
'recordset_records': 9999999,
|
|
|
|
'zone_records': 9999999,
|
|
|
|
'zone_recordsets': 9999999}}))
|
|
|
|
|
|
|
|
def wait_for_zone(self, zone_id):
|
|
|
|
self.wait_for_condition(lambda: self.is_zone_active(zone_id))
|
|
|
|
|
|
|
|
def wait_for_404(self, zone_id):
|
|
|
|
self.wait_for_condition(lambda: self.is_zone_404(zone_id))
|
|
|
|
|
|
|
|
def _create_zone(self, zone_model):
|
|
|
|
resp, model = self.client.post_zone(zone_model)
|
|
|
|
self.assertEqual(resp.status, 202)
|
2015-04-03 15:28:15 +00:00
|
|
|
self.wait_for_zone(model.id)
|
2015-03-13 15:19:00 +00:00
|
|
|
return resp, model
|
2015-03-05 17:49:23 +00:00
|
|
|
|
|
|
|
def test_list_zones(self):
|
2015-03-13 15:19:00 +00:00
|
|
|
self._create_zone(datagen.random_zone_data())
|
|
|
|
resp, model = self.client.list_zones()
|
2015-03-05 17:49:23 +00:00
|
|
|
self.assertEqual(resp.status, 200)
|
2015-03-13 15:19:00 +00:00
|
|
|
self.assertGreater(len(model.zones), 0)
|
|
|
|
|
|
|
|
def test_create_zone(self):
|
|
|
|
self._create_zone(datagen.random_zone_data())
|
|
|
|
|
|
|
|
def test_update_zone(self):
|
|
|
|
post_model = datagen.random_zone_data()
|
|
|
|
resp, old_model = self._create_zone(post_model)
|
|
|
|
|
|
|
|
patch_model = datagen.random_zone_data()
|
2015-04-03 15:28:15 +00:00
|
|
|
del patch_model.name # don't try to override the zone name
|
|
|
|
resp, new_model = self.client.patch_zone(old_model.id,
|
2015-03-13 15:19:00 +00:00
|
|
|
patch_model)
|
|
|
|
self.assertEqual(resp.status, 202)
|
2015-04-03 15:28:15 +00:00
|
|
|
self.wait_for_zone(new_model.id)
|
2015-03-13 15:19:00 +00:00
|
|
|
|
2015-04-03 15:28:15 +00:00
|
|
|
resp, model = self.client.get_zone(new_model.id)
|
2015-03-13 15:19:00 +00:00
|
|
|
self.assertEqual(resp.status, 200)
|
2015-04-03 15:28:15 +00:00
|
|
|
self.assertEqual(new_model.id, old_model.id)
|
|
|
|
self.assertEqual(new_model.name, old_model.name)
|
|
|
|
self.assertEqual(new_model.ttl, patch_model.ttl)
|
|
|
|
self.assertEqual(new_model.email, patch_model.email)
|
2015-03-13 15:19:00 +00:00
|
|
|
|
|
|
|
def test_delete_zone(self):
|
|
|
|
resp, model = self._create_zone(datagen.random_zone_data())
|
2015-04-03 15:28:15 +00:00
|
|
|
resp, model = self.client.delete_zone(model.id)
|
2015-03-13 15:19:00 +00:00
|
|
|
self.assertEqual(resp.status, 202)
|
2015-04-03 15:28:15 +00:00
|
|
|
self.wait_for_404(model.id)
|