| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 |
# not use this file except in compliance with the License. You may obtain |
| 5 |
# a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 |
# License for the specific language governing permissions and limitations |
| 13 |
# under the License. |
| 14 |
import uuid |
| 15 |
|
| 16 |
from seamicroclient.tests import utils |
| 17 |
from seamicroclient.v2 import Client |
| 18 |
|
| 19 |
|
| 20 |
cs = Client("admin", "seamicro", "http://chassis/v2.0") |
| 21 |
|
| 22 |
|
| 23 |
class PoolsTest(utils.TestCase): |
| 24 |
|
| 25 |
def test_list_pool(self): |
| 26 |
pool_list = cs.pools.list() |
| 27 |
self.assertTrue(len(pool_list) > 0) |
| 28 |
|
| 29 |
def test_list_pool_with_filter(self): |
| 30 |
filters = {'id': 'p6-'} |
| 31 |
for pool in cs.pools.list(filters): |
| 32 |
for k, v in filters.iteritems(): |
| 33 |
self.assertIn(v, getattr(pool, k)) |
| 34 |
|
| 35 |
def test_list_pool_with_filter_no_match(self): |
| 36 |
filters = {'id': str(uuid.uuid4())} |
| 37 |
for pool in cs.pools.list(filters): |
| 38 |
for k, v in filters.iteritems(): |
| 39 |
self.assertNotIn(getattr(pool, k), v) |
| 40 |
|
| 41 |
def test_get_pool(self): |
| 42 |
pool_id = cs.pools.list()[0].id |
| 43 |
pool = cs.pools.get(pool_id) |
| 44 |
self.assertEqual(pool.id, pool_id) |