Completed
Pull Request — master (#523)
by
unknown
02:56
created

DuoBaseActionTestCase.setUp()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
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
18
from st2tests.base import BaseActionTestCase
19
20
21
class DuoBaseActionTestCase(BaseActionTestCase):
22
    __test__ = False
23
24
    def setUp(self):
25
        super(DuoBaseActionTestCase, self).setUp()
26
27
        self._blank_config = self.load_yaml('blank.yaml')
28
        self._full_config = self.load_yaml('full.yaml')
29
30
    def load_yaml(self, filename):
31
        return yaml.safe_load(self.get_fixture_content(filename))
32
33
    def load_json(self, filename):
34
        return json.loads(self.get_fixture_content(filename))
35
36
    @property
37
    def blank_config(self):
38
        return self._blank_config
39
40
    @property
41
    def full_config(self):
42
        return self._full_config
43
44
    def test_run_no_config(self):
45
        self.assertRaises(ValueError,
46
                          self.action_cls,
47
                          self.blank_config)
48
49
    def test_run_is_instance(self):
50
        action = self.get_action_instance(self.full_config)
51
        self.assertIsInstance(action, self.action_cls)
52
        self.assertEqual(action.host, "api-hostname")
53
        self.assertEqual(action.ikey, "auth-api-integration-key")
54
        self.assertEqual(action.skey, "auth-api-secret-key")
55