blob: 4c593838a29b978c15ab6f4ea7412968220b05e1 [file] [log] [blame]
Marc Koderer64a54082014-02-05 16:45:47 +01001# Copyright 2014 Deutsche Telekom AG
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import mock
17
18import tempest.test as test
19
20
21class TestNegativeAutoTest(test.BaseTestCase):
22 # Fake entries
23 _interface = 'json'
24 _service = 'compute'
25
26 fake_input_desc = {"name": "list-flavors-with-detail",
27 "http-method": "GET",
28 "url": "flavors/detail",
29 "json-schema": {"type": "object",
30 "properties":
31 {"minRam": {"type": "integer"},
32 "minDisk": {"type": "integer"}}
33 },
34 "resources": ["flavor", "volume", "image"]
35 }
36
37 def _check_prop_entries(self, result, entry):
38 entries = [a for a in result if entry in a[0]]
39 self.assertIsNotNone(entries)
40 self.assertIs(len(entries), 2)
41 for entry in entries:
42 self.assertIsNotNone(entry[1]['schema'])
43
44 def _check_resource_entries(self, result, entry):
45 entries = [a for a in result if entry in a[0]]
46 self.assertIsNotNone(entries)
47 self.assertIs(len(entries), 3)
48 for entry in entries:
49 self.assertIsNotNone(entry[1]['resource'])
50
51 @mock.patch('tempest.test.NegativeAutoTest.load_schema')
52 def test_generate_scenario(self, open_mock):
53 open_mock.return_value = self.fake_input_desc
54 scenarios = test.NegativeAutoTest.\
55 generate_scenario(None)
56
57 self.assertIsInstance(scenarios, list)
58 for scenario in scenarios:
59 self.assertIsInstance(scenario, tuple)
60 self.assertIsInstance(scenario[0], str)
61 self.assertIsInstance(scenario[1], dict)
62 self._check_prop_entries(scenarios, "prop_minRam")
63 self._check_prop_entries(scenarios, "prop_minDisk")
64 self._check_resource_entries(scenarios, "inv_res")