Sfoglia il codice sorgente

Add tests for floating IP

Enis Afgan 9 anni fa
parent
commit
3f885bce78
1 ha cambiato i file con 27 aggiunte e 2 eliminazioni
  1. 27 2
      test/test_network_service.py

+ 27 - 2
test/test_network_service.py

@@ -1,7 +1,6 @@
+import test.helpers as helpers
 import uuid
 import uuid
-
 from test.helpers import ProviderTestBase
 from test.helpers import ProviderTestBase
-import test.helpers as helpers
 
 
 
 
 class CloudNetworkServiceTestCase(ProviderTestBase):
 class CloudNetworkServiceTestCase(ProviderTestBase):
@@ -55,6 +54,32 @@ class CloudNetworkServiceTestCase(ProviderTestBase):
                 "Subnet {0} should have been deleted but still exists."
                 "Subnet {0} should have been deleted but still exists."
                 .format(subnet_name))
                 .format(subnet_name))
 
 
+            # Check floating IP address
+            ip = self.provider.network.create_floating_ip()
+            ip_id = ip.id
+            with helpers.cleanup_action(lambda: ip.delete()):
+                ipl = self.provider.network.floating_ips()
+                self.assertTrue(
+                    ip in ipl,
+                    "Floating IP address {0} should exist in the list {1}"
+                    .format(ip.id, ipl))
+                self.assertIn(
+                    ip.public_ip, repr(ip),
+                    "repr(obj) should contain the address public IP value.")
+                self.assertFalse(
+                    ip.private_ip,
+                    "Floating IP should not have a private IP value ({0})."
+                    .format(ip.private_ip))
+                self.assertFalse(
+                    ip.in_use(),
+                    "Newly created floating IP address should not be in use.")
+            ipl = self.provider.network.floating_ips()
+            found_ip = [a for a in ipl if a.id == ip_id]
+            self.assertTrue(
+                len(found_ip) == 0,
+                "Floating IP {0} should have been deleted but still exists."
+                .format(ip_id))
+
         netl = self.provider.network.list()
         netl = self.provider.network.list()
         found_net = [n for n in netl if n.name == name]
         found_net = [n for n in netl if n.name == name]
         self.assertEqual(
         self.assertEqual(