Merge "Adds test_show_XX_fields cases to show some fields"
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index aee2a44..e614ac1 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -118,6 +118,18 @@
         self.assertEqual(self.name, network['name'])
 
     @attr(type='smoke')
+    def test_show_network_fields(self):
+        # Verifies showing some fields of a network works
+        field_list = [('fields', 'id'), ('fields', 'name'), ]
+        resp, body = self.client.show_network(self.network['id'],
+                                              field_list=field_list)
+        self.assertEqual('200', resp['status'])
+        network = body['network']
+        self.assertEqual(len(network), 2)
+        self.assertEqual(self.network['id'], network['id'])
+        self.assertEqual(self.name, network['name'])
+
+    @attr(type='smoke')
     def test_list_networks(self):
         # Verify the network exists in the list of all networks
         resp, body = self.client.list_networks()
@@ -155,6 +167,18 @@
         self.assertEqual(self.cidr, subnet['cidr'])
 
     @attr(type='smoke')
+    def test_show_subnet_fields(self):
+        # Verifies showing some fields of a subnet works
+        field_list = [('fields', 'id'), ('fields', 'cidr'), ]
+        resp, body = self.client.show_subnet(self.subnet['id'],
+                                             field_list=field_list)
+        self.assertEqual('200', resp['status'])
+        subnet = body['subnet']
+        self.assertEqual(len(subnet), 2)
+        self.assertEqual(self.subnet['id'], subnet['id'])
+        self.assertEqual(self.cidr, subnet['cidr'])
+
+    @attr(type='smoke')
     def test_list_subnets(self):
         # Verify the subnet exists in the list of all subnets
         resp, body = self.client.list_subnets()
@@ -208,6 +232,17 @@
         self.assertEqual(self.port['id'], port['id'])
 
     @attr(type='smoke')
+    def test_show_port_fields(self):
+        # Verifies showing fields of a port works
+        field_list = [('fields', 'id'), ]
+        resp, body = self.client.show_port(self.port['id'],
+                                           field_list=field_list)
+        self.assertEqual('200', resp['status'])
+        port = body['port']
+        self.assertEqual(len(port), 1)
+        self.assertEqual(self.port['id'], port['id'])
+
+    @attr(type='smoke')
     def test_list_ports(self):
         # Verify the port exists in the list of all ports
         resp, body = self.client.list_ports()
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index 96b9b1d..07716fa 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -115,9 +115,14 @@
         return _delete
 
     def _shower(self, resource_name):
-        def _show(resource_id):
+        def _show(resource_id, field_list=[]):
+            # field_list is a sequence of two-element tuples, with the
+            # first element being 'fields'. An example:
+            # [('fields', 'id'), ('fields', 'name')]
             plural = self.pluralize(resource_name)
             uri = '%s/%s' % (self.get_uri(plural), resource_id)
+            if field_list:
+                uri += '?' + urllib.urlencode(field_list)
             resp, body = self.get(uri)
             body = self.deserialize_single(body)
             return resp, body