def test_list_recordsets(self): scenario = utils.DesignateScenario(context=self.context) return_recordsets_list = scenario._list_recordsets("123") self.assertEqual(self.client.recordsets.list.return_value, return_recordsets_list) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.list_recordsets")
def test_delete_domain(self): scenario = utils.DesignateScenario(context=self.context) domain = scenario._create_domain() scenario._delete_domain(domain["id"]) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.delete_domain")
def test_delete_zone(self): scenario = utils.DesignateScenario(context=self.context) zone = scenario._create_zone() scenario._delete_zone(zone["id"]) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.delete_zone")
def test_create_server(self): scenario = utils.DesignateScenario(context=self.context) random_name = "foo" scenario.generate_random_name = mock.Mock(return_value=random_name) explicit_name = "bar.io." self.admin_clients( "designate").servers.create.return_value = self.server # Check that the defaults / randoms are used if nothing is specified server = scenario._create_server() self.admin_clients("designate").servers.create.assert_called_once_with( {"name": "%s.name." % random_name}) self.assertEqual(self.server, server) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.create_server") self.admin_clients("designate").servers.create.reset_mock() # Check that when specifying server name defaults are not used... data = {"name": explicit_name} server = scenario._create_server(data) self.admin_clients("designate").servers.create.assert_called_once_with( data) self.assertEqual(self.server, server)
def test_list_domains(self): scenario = utils.DesignateScenario(context=self.context) return_domains_list = scenario._list_domains() self.assertEqual( self.clients("designate").domains.list.return_value, return_domains_list) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.list_domains")
def test_delete_server(self): scenario = utils.DesignateScenario(context=self.context) scenario._delete_server("foo_id") self.admin_clients("designate").servers.delete.assert_called_once_with( "foo_id") self._test_atomic_action_timer(scenario.atomic_actions(), "designate.delete_server")
def test_update_domain(self): scenario = utils.DesignateScenario(context=self.context) domain = scenario._create_domain() self.clients("designate").domains.update.return_value = self.domain updated_domain = scenario._update_domain(domain) self.clients("designate").domains.update.assert_called_once_with( domain) self.assertEqual(self.domain, updated_domain) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.update_domain")
def setup(self): for user, tenant_id in rutils.iterate_per_tenants( self.context["users"]): self.context["tenants"][tenant_id].setdefault("zones", []) designate_util = utils.DesignateScenario( {"user": user, "task": self.context["task"], "owner_id": self.context["owner_id"]}) for i in range(self.config["zones_per_tenant"]): zone = designate_util._create_zone() self.context["tenants"][tenant_id]["zones"].append(zone)
def test_create_recordset(self, recordset_data): scenario = utils.DesignateScenario() random_name = "foo" zone_name = "zone.name." random_recordset_name = "%s.%s" % (random_name, zone_name) scenario = utils.DesignateScenario(context=self.context) scenario.generate_random_name = mock.Mock(return_value=random_name) zone = {"name": zone_name, "id": "123"} # Create with randoms (name and type) scenario._create_recordset(zone) self.client.recordsets.create.assert_called_once_with( zone["id"], name=random_recordset_name, type_="A", records=["10.0.0.1"]) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.create_recordset") self.client.recordsets.create.reset_mock() # Specify name recordset = {"name": "www.zone.name.", "type_": "ASD"} scenario._create_recordset(zone, recordset) self.client.recordsets.create.assert_called_once_with( zone["id"], name="www.zone.name.", type_="ASD", records=["10.0.0.1"]) self.client.recordsets.create.reset_mock() # Specify type without underscore scenario._create_recordset(zone, {"type": "A"}) self.client.recordsets.create.assert_called_once_with( zone["id"], name="foo.zone.name.", type_="A", records=["10.0.0.1"])
def test_create_domain(self, domain_data): random_name = "foo" scenario = utils.DesignateScenario(context=self.context) scenario.generate_random_name = mock.Mock(return_value=random_name) self.clients("designate").domains.create.return_value = self.domain expected = {"email": "*****@*****.**"} expected.update(domain_data) expected["name"] = "%s.name." % random_name domain = scenario._create_domain(domain_data) self.clients("designate").domains.create.assert_called_once_with( expected) self.assertEqual(self.domain, domain) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.create_domain")
def test_delete_recordset(self): scenario = utils.DesignateScenario(context=self.context) zone_id = mock.Mock() recordset_id = mock.Mock() scenario._delete_recordset(zone_id, recordset_id) self.client.recordsets.delete.assert_called_once_with( zone_id, recordset_id) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.delete_recordset") self.client.recordsets.delete.reset_mock() scenario._delete_recordset(zone_id, recordset_id) self.client.recordsets.delete.assert_called_once_with( zone_id, recordset_id)
def test_create_zone(self, zone_data): scenario = utils.DesignateScenario() random_name = "foo" scenario = utils.DesignateScenario(context=self.context) scenario.generate_random_name = mock.Mock(return_value=random_name) self.client.zones.create.return_value = self.zone expected = { "email": "*****@*****.**", "name": "%s.name." % random_name, "type_": "PRIMARY" } expected.update(zone_data) # Check that the defaults / randoms are used if nothing is specified zone = scenario._create_zone(**zone_data) self.client.zones.create.assert_called_once_with(description=None, ttl=None, **expected) self.assertEqual(self.zone, zone) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.create_zone")
def test_delete_record(self): scenario = utils.DesignateScenario(context=self.context) domain_id = mock.Mock() record_id = mock.Mock() scenario._delete_record(domain_id, record_id) self.clients("designate").records.delete.assert_called_once_with( domain_id, record_id) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.delete_record") self.clients("designate").records.delete.reset_mock() scenario._delete_record(domain_id, record_id) self.clients("designate").records.delete.assert_called_once_with( domain_id, record_id)
def test_create_record(self, record_data): random_name = "foo" domain_name = "zone.name." domain = {"name": domain_name, "id": "123"} record_name = "%s.%s" % (random_name, domain_name) scenario = utils.DesignateScenario(context=self.context) scenario.generate_random_name = mock.Mock(return_value=random_name) expected = {"type": "A", "data": "10.0.0.1"} expected.update(record_data) expected["name"] = record_name scenario._create_record(domain, record=record_data) self.clients("designate").records.create.assert_called_once_with( domain["id"], expected) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.create_record")