|
1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
|
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
|
3
|
|
|
# this work for additional information regarding copyright ownership. |
|
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
|
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
|
6
|
|
|
# the License. You may obtain 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, |
|
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13
|
|
|
# See the License for the specific language governing permissions and |
|
14
|
|
|
|
|
15
|
|
|
import yaml |
|
16
|
|
|
import json |
|
17
|
|
|
# from mock import MagicMock |
|
18
|
|
|
|
|
19
|
|
|
from st2tests.base import BaseActionTestCase |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class VsphereBaseActionTestCase(BaseActionTestCase): |
|
23
|
|
|
__test__ = False |
|
24
|
|
|
|
|
25
|
|
|
def setUp(self): |
|
26
|
|
|
super(VsphereBaseActionTestCase, self).setUp() |
|
27
|
|
|
|
|
28
|
|
|
self._blank_config = self.load_yaml('cfg_blank.yaml') |
|
29
|
|
|
self._old_config = self.load_yaml('cfg_old.yaml') |
|
30
|
|
|
self._new_config = self.load_yaml('cfg_new.yaml') |
|
31
|
|
|
|
|
32
|
|
|
def load_yaml(self, filename): |
|
33
|
|
|
return yaml.safe_load(self.get_fixture_content(filename)) |
|
34
|
|
|
|
|
35
|
|
|
def load_json(self, filename): |
|
36
|
|
|
return json.loads(self.get_fixture_content(filename)) |
|
37
|
|
|
|
|
38
|
|
|
@property |
|
39
|
|
|
def blank_config(self): |
|
40
|
|
|
return self._blank_config |
|
41
|
|
|
|
|
42
|
|
|
@property |
|
43
|
|
|
def old_config(self): |
|
44
|
|
|
return self._old_config |
|
45
|
|
|
|
|
46
|
|
|
@property |
|
47
|
|
|
def new_config(self): |
|
48
|
|
|
return self._new_config |
|
49
|
|
|
|
|
50
|
|
|
def test_run_config_blank(self): |
|
51
|
|
|
self.assertRaises(ValueError, self.action_cls, self.blank_config) |
|
52
|
|
|
|
|
53
|
|
|
def test_run_config_old(self): |
|
54
|
|
|
action = self.get_action_instance(self.old_config) |
|
55
|
|
|
self.assertIsInstance(action, self.action_cls) |
|
56
|
|
|
|
|
57
|
|
|
def test_run_config_new(self): |
|
58
|
|
|
action = self.get_action_instance(self.new_config) |
|
59
|
|
|
self.assertIsInstance(action, self.action_cls) |
|
60
|
|
|
|