Merge "Make test_detail_quota() test more generic"
diff --git a/neutron_tempest_plugin/api/test_dhcp_ipv6.py b/neutron_tempest_plugin/api/test_dhcp_ipv6.py
index 69b4ea0..0fab75c 100644
--- a/neutron_tempest_plugin/api/test_dhcp_ipv6.py
+++ b/neutron_tempest_plugin/api/test_dhcp_ipv6.py
@@ -58,8 +58,8 @@
         ports = body['ports']
         for port in ports:
             if (port['device_owner'].startswith(
-                    constants.DEVICE_OWNER_ROUTER_INTF)
-                and port['device_id'] in [r['id'] for r in self.routers]):
+                    constants.DEVICE_OWNER_ROUTER_INTF) and
+                port['device_id'] in [r['id'] for r in self.routers]):
                 self.client.remove_router_interface_with_port_id(
                     port['device_id'], port['id']
                 )
diff --git a/neutron_tempest_plugin/api/test_floating_ips.py b/neutron_tempest_plugin/api/test_floating_ips.py
index 19d8e2a..9f5778f 100644
--- a/neutron_tempest_plugin/api/test_floating_ips.py
+++ b/neutron_tempest_plugin/api/test_floating_ips.py
@@ -105,3 +105,38 @@
         body = self.client.update_floatingip(body['floatingip']['id'],
                                              port_id=None)
         self.assertIsNone(body['floatingip']['port_id'])
+
+    @decorators.idempotent_id('cecae820-ebaa-4f96-b386-6a9fbf25c552')
+    @utils.requires_ext(extension="standard-attr-description",
+                        service="network")
+    @utils.requires_ext(extension="fip-port-details", service="network")
+    def test_create_update_floatingip_port_details(self):
+
+        body = self.client.create_floatingip(
+            floating_network_id=self.ext_net_id,
+            port_id=self.ports[0]['id'],
+            description='d1'
+        )['floatingip']
+        self.floating_ips.append(body)
+        self._assert_port_details(self.ports[0], body)
+        body = self.client.show_floatingip(body['id'])['floatingip']
+        self._assert_port_details(self.ports[0], body)
+        body = self.client.update_floatingip(body['id'], description='d2')
+        self._assert_port_details(self.ports[0], body['floatingip'])
+        # disassociate
+        body = self.client.update_floatingip(body['floatingip']['id'],
+                                             port_id=None)
+        self.assertIn('port_details', body['floatingip'])
+        self.assertIsNone(body['floatingip']['port_details'])
+
+    def _assert_port_details(self, port, body):
+        self.assertIn('port_details', body)
+        port_details = body['port_details']
+        self.assertEqual(port['name'], port_details['name'])
+        self.assertEqual(port['network_id'], port_details['network_id'])
+        self.assertEqual(port['mac_address'], port_details['mac_address'])
+        self.assertEqual(port['admin_state_up'],
+                         port_details['admin_state_up'])
+        self.assertEqual(port['status'], port_details['status'])
+        self.assertEqual(port['device_id'], port_details['device_id'])
+        self.assertEqual(port['device_owner'], port_details['device_owner'])
diff --git a/neutron_tempest_plugin/api/test_network_ip_availability.py b/neutron_tempest_plugin/api/test_network_ip_availability.py
index ed56363..10aee2e 100644
--- a/neutron_tempest_plugin/api/test_network_ip_availability.py
+++ b/neutron_tempest_plugin/api/test_network_ip_availability.py
@@ -79,11 +79,11 @@
 def calc_total_ips(prefix, ip_version):
     # will calculate total ips after removing reserved.
     if ip_version == lib_constants.IP_VERSION_4:
-        total_ips = 2 ** (lib_constants.IPv4_BITS
-                          - prefix) - DEFAULT_IP4_RESERVED
+        total_ips = 2 ** (lib_constants.IPv4_BITS -
+                          prefix) - DEFAULT_IP4_RESERVED
     elif ip_version == lib_constants.IP_VERSION_6:
-        total_ips = 2 ** (lib_constants.IPv6_BITS
-                          - prefix) - DEFAULT_IP6_RESERVED
+        total_ips = 2 ** (lib_constants.IPv6_BITS -
+                          prefix) - DEFAULT_IP6_RESERVED
     return total_ips
 
 
diff --git a/neutron_tempest_plugin/api/test_routers.py b/neutron_tempest_plugin/api/test_routers.py
index bc657e0..d5d2e04 100644
--- a/neutron_tempest_plugin/api/test_routers.py
+++ b/neutron_tempest_plugin/api/test_routers.py
@@ -159,9 +159,12 @@
         # Add router interface with subnet id
         router = self._create_router(data_utils.rand_name('router'), True)
         intf = self.create_router_interface(router['id'], subnet['id'])
-        status_active = lambda: self.client.show_port(
-            intf['port_id'])['port']['status'] == 'ACTIVE'
-        utils.wait_until_true(status_active, exception=AssertionError)
+
+        def _status_active():
+            return self.client.show_port(
+                intf['port_id'])['port']['status'] == 'ACTIVE'
+
+        utils.wait_until_true(_status_active, exception=AssertionError)
 
     @decorators.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c')
     @tutils.requires_ext(extension='extraroute', service='network')
diff --git a/neutron_tempest_plugin/common/utils.py b/neutron_tempest_plugin/common/utils.py
index d6d0aee..c42d984 100644
--- a/neutron_tempest_plugin/common/utils.py
+++ b/neutron_tempest_plugin/common/utils.py
@@ -18,11 +18,12 @@
 
 """Utilities and helper functions."""
 
-import eventlet
 import functools
 import threading
 import time
 
+import eventlet
+
 
 class classproperty(object):
     def __init__(self, f):
diff --git a/neutron_tempest_plugin/scenario/test_floatingip.py b/neutron_tempest_plugin/scenario/test_floatingip.py
index 251f21c..8062a46 100644
--- a/neutron_tempest_plugin/scenario/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/test_floatingip.py
@@ -68,8 +68,8 @@
                 network_id=CONF.network.public_network_id)
 
             for subnet in subnets['subnets']:
-                if (subnet['gateway_ip']
-                    and subnet['ip_version'] == lib_constants.IP_VERSION_4):
+                if (subnet['gateway_ip'] and
+                    subnet['ip_version'] == lib_constants.IP_VERSION_4):
                     return subnet['gateway_ip']
 
     @classmethod
diff --git a/neutron_tempest_plugin/scenario/test_mtu.py b/neutron_tempest_plugin/scenario/test_mtu.py
index 8f1c9ed..b38d770 100644
--- a/neutron_tempest_plugin/scenario/test_mtu.py
+++ b/neutron_tempest_plugin/scenario/test_mtu.py
@@ -69,8 +69,8 @@
     def skip_checks(cls):
         super(NetworkMtuTest, cls).skip_checks()
         if ("vxlan" not in
-                config.CONF.neutron_plugin_options.available_type_drivers
-            or "gre" not in
+                config.CONF.neutron_plugin_options.available_type_drivers or
+            "gre" not in
                 config.CONF.neutron_plugin_options.available_type_drivers):
             raise cls.skipException("GRE or VXLAN type_driver is not enabled")
 
diff --git a/neutron_tempest_plugin/scenario/test_qos.py b/neutron_tempest_plugin/scenario/test_qos.py
index 58accb0..0611160 100644
--- a/neutron_tempest_plugin/scenario/test_qos.py
+++ b/neutron_tempest_plugin/scenario/test_qos.py
@@ -75,8 +75,8 @@
     BS = 512
     COUNT = BUFFER_SIZE / BS
     FILE_SIZE = BS * COUNT
-    LIMIT_BYTES_SEC = (constants.LIMIT_KILO_BITS_PER_SECOND * 1024
-                       * TOLERANCE_FACTOR / 8.0)
+    LIMIT_BYTES_SEC = (constants.LIMIT_KILO_BITS_PER_SECOND * 1024 *
+                       TOLERANCE_FACTOR / 8.0)
     FILE_PATH = "/tmp/img"
 
     NC_PORT = 1234
diff --git a/test-requirements.txt b/test-requirements.txt
index b8835e3..84f3c18 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -5,6 +5,7 @@
 hacking<0.13,>=0.12.0 # Apache-2.0
 
 coverage!=4.4,>=4.0 # Apache-2.0
+flake8-import-order==0.12 # LGPLv3
 python-subunit>=1.0.0 # Apache-2.0/BSD
 sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD
 oslotest>=3.2.0 # Apache-2.0
diff --git a/tox.ini b/tox.ini
index 06eda94..d966308 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 minversion = 2.0
-envlist = py34,py27,pypy,pep8
+envlist = pep8
 skipsdist = True
 
 [testenv]
@@ -15,7 +15,7 @@
 [testenv:pep8]
 commands =
   sh ./tools/misc-sanity-checks.sh
-  flake8 {posargs}
+  flake8
 whitelist_externals =
   sh