Skip to content

Commit 0713c03

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add port functional tests"
2 parents 040d0c2 + 9fcbd0a commit 0713c03

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import uuid
14+
15+
from functional.common import test
16+
17+
18+
class PortTests(test.TestCase):
19+
"""Functional tests for port. """
20+
NAME = uuid.uuid4().hex
21+
NETWORK_NAME = uuid.uuid4().hex
22+
HEADERS = ['Name']
23+
FIELDS = ['name']
24+
25+
@classmethod
26+
def setUpClass(cls):
27+
# Create a network for the subnet.
28+
cls.openstack('network create ' + cls.NETWORK_NAME)
29+
opts = cls.get_show_opts(cls.FIELDS)
30+
raw_output = cls.openstack(
31+
'port create --network ' + cls.NETWORK_NAME + ' ' +
32+
cls.NAME + opts
33+
)
34+
expected = cls.NAME + '\n'
35+
cls.assertOutput(expected, raw_output)
36+
37+
@classmethod
38+
def tearDownClass(cls):
39+
raw_output = cls.openstack('port delete ' + cls.NAME)
40+
cls.assertOutput('', raw_output)
41+
raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
42+
cls.assertOutput('', raw_output)
43+
44+
def test_port_list(self):
45+
opts = self.get_list_opts(self.HEADERS)
46+
raw_output = self.openstack('port list' + opts)
47+
self.assertIn(self.NAME, raw_output)
48+
49+
def test_port_set(self):
50+
self.openstack('port set --disable ' + self.NAME)
51+
opts = self.get_show_opts(['name', 'admin_state_up'])
52+
raw_output = self.openstack('port show ' + self.NAME + opts)
53+
self.assertEqual("DOWN\n" + self.NAME + "\n", raw_output)
54+
55+
def test_port_show(self):
56+
opts = self.get_show_opts(self.FIELDS)
57+
raw_output = self.openstack('port show ' + self.NAME + opts)
58+
self.assertEqual(self.NAME + "\n", raw_output)

0 commit comments

Comments
 (0)