# Copyright 2015 NEC Corporation.  All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from tempest_lib.tests import fake_auth_provider

from tempest.services.compute.json import availability_zone_client
from tempest.tests.services.compute import base


class TestAvailabilityZoneClient(base.BaseComputeServiceTest):

    FAKE_AVAILABIRITY_ZONE_INFO = {
        "availabilityZoneInfo":
        [
            {
                "zoneState": {
                    "available": True
                },
                "hosts": None,
                "zoneName": u'\xf4'
            }
        ]
    }

    def setUp(self):
        super(TestAvailabilityZoneClient, self).setUp()
        fake_auth = fake_auth_provider.FakeAuthProvider()
        self.client = availability_zone_client.AvailabilityZoneClient(
            fake_auth, 'compute', 'regionOne')

    def test_list_availability_zones_with_str_body(self):
        self.check_service_client_function(
            self.client.list_availability_zones,
            'tempest.common.service_client.ServiceClient.get',
            self.FAKE_AVAILABIRITY_ZONE_INFO)

    def test_list_availability_zones_with_bytes_body(self):
        self.check_service_client_function(
            self.client.list_availability_zones,
            'tempest.common.service_client.ServiceClient.get',
            self.FAKE_AVAILABIRITY_ZONE_INFO, to_utf=True)

@@ -624,16 +624,29 @@
 cense.%0A%0A
+import copy%0A%0A
 from tem
@@ -878,32 +878,17 @@
   FAKE_A
-VAILABIRITY_ZONE
+Z
 _INFO = 
@@ -1131,16 +1131,249 @@
 %0A    %7D%0A%0A
+    FAKE_AZ_DETAILS = %7B%0A        %22testhost%22: %7B%0A            %22nova-compute%22: %7B%0A                %22available%22: True,%0A                %22active%22: True,%0A                %22updated_at%22: %222015-09-10T07:16:46.000000%22%0A            %7D%0A        %7D%0A    %7D%0A%0A
     def 
@@ -1622,34 +1622,30 @@
 ')%0A%0A    def 
+_
 test_
-list_
 availability
@@ -1654,27 +1654,27 @@
 ones
-_with_str_body(self
+(self, to_utf=False
 ):%0A 
@@ -1851,37 +1851,42 @@
 f.FAKE_A
-VAILABIRITY_ZONE_INFO
+Z_INFO,%0A            to_utf
 )%0A%0A    d
@@ -1892,18 +1892,14 @@
 def 
+_
 test_
-list_
 avai
@@ -1922,235 +1922,875 @@
 ith_
-bytes_body(self):%0A        self.check_service_client_function(%0A            self.client.list_availability_zones,%0A            'tempest.common.service_client.ServiceClient.get',%0A            self.FAKE_AVAILABIRITY_ZONE_INFO, to_utf=
+details(self, to_utf=False):%0A        fake_az_details = copy.deepcopy(self.FAKE_AZ_INFO)%0A        fake_az_details%5B'availabilityZoneInfo'%5D%5B0%5D%5B'hosts'%5D = %5C%0A            self.FAKE_AZ_DETAILS%0A        self.check_service_client_function(%0A            self.client.list_availability_zones,%0A            'tempest.common.service_client.ServiceClient.get',%0A            fake_az_details,%0A            to_utf,%0A            detail=True)%0A%0A    def test_list_availability_zones_with_str_body(self):%0A        self._test_availability_zones()%0A%0A    def test_list_availability_zones_with_bytes_body(self):%0A        self._test_availability_zones(True)%0A%0A    def test_list_availability_zones_with_str_body_and_details(self):%0A        self._test_availability_zones_with_details()%0A%0A    def test_list_availability_zones_with_bytes_body_and_details(self):%0A        self._test_availability_zones_with_details(
 True

Enhance unit test coverage: availability_zone_client