@@ -0,0 +1,3188 @@
+#    Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A#    not use this file except in compliance with the License. You may obtain%0A#    a copy of the License at%0A#%0A#         http://www.apache.org/licenses/LICENSE-2.0%0A#%0A#    Unless required by applicable law or agreed to in writing, software%0A#    distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A#    License for the specific language governing permissions and limitations%0A#    under the License.%0A%0Aimport os%0Aimport uuid%0A%0Afrom keystoneclient.auth.identity import v2 as v2_auth%0Afrom keystoneclient import discover%0Afrom keystoneclient import session%0Afrom tempest_lib import base%0Aimport testtools%0A%0Afrom neutronclient.common import exceptions%0Afrom neutronclient.v2_0 import client as v2_client%0A%0A# This module tests client library functionalities with%0A# Keystone client. Neutron client supports two types of%0A# HTTP clients (HTTPClient and SessionClient),%0A# so it is better to test both clients.%0A%0A%0Aclass LibraryTestBase(base.BaseTestCase):%0A%0A    def setUp(self):%0A        super(LibraryTestBase, self).setUp()%0A        self.client = self._get_client()%0A%0A%0Aclass Libv2HTTPClientTestBase(LibraryTestBase):%0A%0A    def _get_client(self):%0A        return v2_client.Client(username=os.environ.get('OS_USERNAME'),%0A                                password=os.environ.get('OS_PASSWORD'),%0A                                tenant_name=os.environ.get('OS_TENANT_NAME'),%0A                                auth_url=os.environ.get('OS_AUTH_URL'))%0A%0A%0Aclass Libv2SessionClientTestBase(LibraryTestBase):%0A%0A    def _get_client(self):%0A        session_params = %7B%7D%0A        ks_session = session.Session.construct(session_params)%0A        ks_discover = discover.Discover(session=ks_session,%0A                                        auth_url=os.environ.get('OS_AUTH_URL'))%0A        # At the moment, we use keystone v2 API%0A        v2_auth_url = ks_discover.url_for('2.0')%0A        ks_session.auth = v2_auth.Password(%0A            v2_auth_url,%0A            username=os.environ.get('OS_USERNAME'),%0A            password=os.environ.get('OS_PASSWORD'),%0A            tenant_name=os.environ.get('OS_TENANT_NAME'))%0A        return v2_client.Client(session=ks_session)%0A%0A%0Aclass LibraryTestCase(object):%0A%0A    def test_list_network(self):%0A        nets = self.client.list_networks()%0A        self.assertIsInstance(nets%5B'networks'%5D, list)%0A%0A    def test_post_put_delele_network(self):%0A        name = str(uuid.uuid4())%0A        net = self.client.create_network(%7B'network': %7B'name': name%7D%7D)%0A        net_id = net%5B'network'%5D%5B'id'%5D%0A        self.assertEqual(name, net%5B'network'%5D%5B'name'%5D)%0A        name2 = str(uuid.uuid4())%0A        net = self.client.update_network(net_id, %7B'network': %7B'name': name2%7D%7D)%0A        self.assertEqual(name2, net%5B'network'%5D%5B'name'%5D)%0A        self.client.delete_network(net_id)%0A        with testtools.ExpectedException(exceptions.NetworkNotFoundClient):%0A            self.client.show_network(net_id)%0A%0A%0Aclass LibraryHTTPClientTest(LibraryTestCase, Libv2HTTPClientTestBase):%0A    pass%0A%0A%0Aclass LibrarySessionClientTest(LibraryTestCase, Libv2SessionClientTestBase):%0A    pass%0A

Add basic functional tests for client library