Skip to content

Commit c786845

Browse files
committed
Add functional tests for server CRUD
Change-Id: I77f292d47a9bea6a5b486ce513c0c19ec8c845dd
1 parent aac0d58 commit c786845

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 ServerTests(test.TestCase):
19+
"""Functional tests for server. """
20+
21+
NAME = uuid.uuid4().hex
22+
HEADERS = ['"Name"']
23+
FIELDS = ['name']
24+
25+
@classmethod
26+
def setUpClass(cls):
27+
opts = cls.get_show_opts(cls.FIELDS)
28+
# TODO(thowe): pull these values from clouds.yaml
29+
flavor = '4'
30+
image = 'cirros-0.3.4-x86_64-uec'
31+
netid = ''
32+
if netid:
33+
nicargs = ' --nic net-id=' + netid
34+
else:
35+
nicargs = ''
36+
raw_output = cls.openstack('server create --flavor ' + flavor +
37+
' --image ' + image + nicargs + ' ' +
38+
cls.NAME + opts)
39+
expected = cls.NAME + '\n'
40+
cls.assertOutput(expected, raw_output)
41+
42+
@classmethod
43+
def tearDownClass(cls):
44+
raw_output = cls.openstack('server delete ' + cls.NAME)
45+
cls.assertOutput('', raw_output)
46+
47+
def test_server_list(self):
48+
opts = self.get_list_opts(self.HEADERS)
49+
raw_output = self.openstack('server list' + opts)
50+
self.assertIn(self.NAME, raw_output)
51+
52+
def test_server_show(self):
53+
opts = self.get_show_opts(self.FIELDS)
54+
raw_output = self.openstack('server show ' + self.NAME + opts)
55+
self.assertEqual(self.NAME + "\n", raw_output)

0 commit comments

Comments
 (0)