|
| 1 | +# Copyright 2013 OpenStack, LLC. |
| 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 | +# |
| 15 | + |
| 16 | +from openstackclient.network.v2_0.lb import pool |
| 17 | +from openstackclient.tests.network.v2_0 import common |
| 18 | + |
| 19 | + |
| 20 | +class TestCreateLbPool(common.TestNetworkBase): |
| 21 | + def test_get_parser_nothing(self): |
| 22 | + given = "--lb-method ROUND_ROBIN --protocol HTTP --subnet-id 34" + \ |
| 23 | + " pool1" + self.given_default_show_options() |
| 24 | + parsed = self.given_args(pool.CreatePool, given) |
| 25 | + self.assertEqual('pool1', parsed.name) |
| 26 | + self.assertEqual('ROUND_ROBIN', parsed.lb_method) |
| 27 | + self.assertEqual('HTTP', parsed.protocol) |
| 28 | + self.assertEqual('34', parsed.subnet_id) |
| 29 | + self.assertEqual(True, parsed.admin_state) |
| 30 | + self.assertEqual(None, parsed.description) |
| 31 | + self.assertEqual(None, parsed.provider) |
| 32 | + self.assertEqual(None, parsed.tenant_id) |
| 33 | + self.then_default_show_options(parsed) |
| 34 | + |
| 35 | + def test_get_parser_all(self): |
| 36 | + allargs = "--lb-method SOURCE_IP --protocol HTTPS --subnet-id 123" + \ |
| 37 | + " --admin-state-down --description foo --provider ride" + \ |
| 38 | + " pool2 --project sneed " |
| 39 | + allargs += self.given_all_show_options() |
| 40 | + parsed = self.given_args(pool.CreatePool, allargs) |
| 41 | + self.assertEqual('pool2', parsed.name) |
| 42 | + self.assertEqual('SOURCE_IP', parsed.lb_method) |
| 43 | + self.assertEqual('HTTPS', parsed.protocol) |
| 44 | + self.assertEqual('123', parsed.subnet_id) |
| 45 | + self.assertEqual(False, parsed.admin_state) |
| 46 | + self.assertEqual('foo', parsed.description) |
| 47 | + self.assertEqual('ride', parsed.provider) |
| 48 | + self.assertEqual('sneed', parsed.tenant_id) |
| 49 | + self.then_all_show_options(parsed) |
| 50 | + |
| 51 | + |
| 52 | +class TestDeleteLbPool(common.TestNetworkBase): |
| 53 | + def test_get_parser_nothing(self): |
| 54 | + parsed = self.given_args(pool.DeletePool, "noo") |
| 55 | + self.assertEqual('noo', parsed.pool) |
| 56 | + |
| 57 | + |
| 58 | +class TestListLbPool(common.TestNetworkBase): |
| 59 | + def test_get_parser_nothing(self): |
| 60 | + given = "" + self.given_default_list_options() |
| 61 | + parsed = self.given_args(pool.ListPool, given) |
| 62 | + self.assertEqual(False, parsed.show_details) |
| 63 | + self.then_default_list_options(parsed) |
| 64 | + |
| 65 | + def test_get_parser_all(self): |
| 66 | + allargs = "--long" + self.given_all_list_options() |
| 67 | + parsed = self.given_args(pool.ListPool, allargs) |
| 68 | + self.assertEqual(True, parsed.show_details) |
| 69 | + self.then_all_list_options(parsed) |
| 70 | + |
| 71 | + |
| 72 | +class TestSetLbPool(common.TestNetworkBase): |
| 73 | + def test_get_parser_nothing(self): |
| 74 | + parsed = self.given_args(pool.SetPool, "noo") |
| 75 | + self.assertEqual('noo', parsed.pool) |
| 76 | + |
| 77 | + |
| 78 | +class TestShowLbPool(common.TestNetworkBase): |
| 79 | + def test_get_parser_nothing(self): |
| 80 | + given = "noo" + self.given_default_show_options() |
| 81 | + parsed = self.given_args(pool.ShowPool, given) |
| 82 | + self.assertEqual('noo', parsed.pool) |
| 83 | + self.then_default_show_options(parsed) |
| 84 | + |
| 85 | + def test_get_parser_all(self): |
| 86 | + allargs = "too" + self.given_all_show_options() |
| 87 | + parsed = self.given_args(pool.ShowPool, allargs) |
| 88 | + self.assertEqual('too', parsed.pool) |
| 89 | + self.then_all_show_options(parsed) |
0 commit comments