summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/v2/test_floating_ip_dns.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/tests/unit/v2/test_floating_ip_dns.py')
-rw-r--r--novaclient/tests/unit/v2/test_floating_ip_dns.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_floating_ip_dns.py b/novaclient/tests/unit/v2/test_floating_ip_dns.py
new file mode 100644
index 0000000..ec20e56
--- /dev/null
+++ b/novaclient/tests/unit/v2/test_floating_ip_dns.py
@@ -0,0 +1,91 @@
1#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14from novaclient.tests.unit.fixture_data import client
15from novaclient.tests.unit.fixture_data import floatingips as data
16from novaclient.tests.unit import utils
17from novaclient.v2 import floating_ip_dns
18
19
20class FloatingIPDNSDomainTest(utils.FixturedTestCase):
21
22 testdomain = "testdomain"
23 client_fixture_class = client.V1
24 data_fixture_class = data.DNSFixture
25
26 def test_dns_domains(self):
27 domainlist = self.cs.dns_domains.domains()
28 self.assertEqual(2, len(domainlist))
29
30 for entry in domainlist:
31 self.assertIsInstance(entry,
32 floating_ip_dns.FloatingIPDNSDomain)
33
34 self.assertEqual('example.com', domainlist[1].domain)
35
36 def test_create_private_domain(self):
37 self.cs.dns_domains.create_private(self.testdomain, 'test_avzone')
38 self.assert_called('PUT', '/os-floating-ip-dns/%s' %
39 self.testdomain)
40
41 def test_create_public_domain(self):
42 self.cs.dns_domains.create_public(self.testdomain, 'test_project')
43 self.assert_called('PUT', '/os-floating-ip-dns/%s' %
44 self.testdomain)
45
46 def test_delete_domain(self):
47 self.cs.dns_domains.delete(self.testdomain)
48 self.assert_called('DELETE', '/os-floating-ip-dns/%s' %
49 self.testdomain)
50
51
52class FloatingIPDNSEntryTest(utils.FixturedTestCase):
53
54 testname = "testname"
55 testip = "1.2.3.4"
56 testdomain = "testdomain"
57 testtype = "A"
58 client_fixture_class = client.V1
59 data_fixture_class = data.DNSFixture
60
61 def test_get_dns_entries_by_ip(self):
62 entries = self.cs.dns_entries.get_for_ip(self.testdomain,
63 ip=self.testip)
64 self.assertEqual(2, len(entries))
65
66 for entry in entries:
67 self.assertIsInstance(entry,
68 floating_ip_dns.FloatingIPDNSEntry)
69
70 self.assertEqual('host2', entries[1].dns_entry['name'])
71 self.assertEqual(entries[1].dns_entry['ip'], self.testip)
72
73 def test_get_dns_entry_by_name(self):
74 entry = self.cs.dns_entries.get(self.testdomain,
75 self.testname)
76 self.assertIsInstance(entry, floating_ip_dns.FloatingIPDNSEntry)
77 self.assertEqual(entry.name, self.testname)
78
79 def test_create_entry(self):
80 self.cs.dns_entries.create(self.testdomain,
81 self.testname,
82 self.testip,
83 self.testtype)
84
85 self.assert_called('PUT', '/os-floating-ip-dns/%s/entries/%s' %
86 (self.testdomain, self.testname))
87
88 def test_delete_entry(self):
89 self.cs.dns_entries.delete(self.testdomain, self.testname)
90 self.assert_called('DELETE', '/os-floating-ip-dns/%s/entries/%s' %
91 (self.testdomain, self.testname))