Completed
Push — master ( f1a13c...e53aa3 )
by Tomaz
20s
created

NodeUnmanageTestCase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 49
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A test_run_unmanaged() 0 3 1
A test_run_connect_fail() 0 7 1
A test_run_invoke_returns_text() 0 17 1
A test_run_unmanage_too_long() 0 7 1
A test_run_node_not_found() 0 7 1
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
from mock import MagicMock
16
17
from orion_base_action_test_case import OrionBaseActionTestCase
18
19
from node_unmanage import NodeUnmanage
20
21
__all__ = [
22
    'NodeUnmanageTestCase'
23
]
24
25
26
class NodeUnmanageTestCase(OrionBaseActionTestCase):
27
    __test__ = True
28
    action_cls = NodeUnmanage
29
30
    def test_run_connect_fail(self):
31
        action = self.setup_connect_fail()
32
        self.assertRaises(ValueError,
33
                          action.run,
34
                          "orion",
35
                          "router1",
36
                          30)
37
38
    def test_run_node_not_found(self):
39
        action = self.setup_query_blank_results()
40
        self.assertRaises(ValueError,
41
                          action.run,
42
                          "orion",
43
                          "router1",
44
                          30)
45
46
    def test_run_unmanaged(self):
47
        action = self.setup_node_exists()
48
        self.assertTrue(action.run("router1", "orion", 30))
49
50
    def test_run_invoke_returns_text(self):
51
        expected = "fake"
52
53
        query_data = []
54
        query_data.append(self.query_npm_node)
55
        query_data.append(self.query_ncm_node)
56
57
        action = self.get_action_instance(config=self.full_config)
58
59
        action.connect = MagicMock(return_value=True)
60
        action.query = MagicMock(side_effect=query_data)
61
        action.invoke = MagicMock(return_value="fake")
62
63
        result = action.run("router1",
64
                            "orion",
65
                            30)
66
        self.assertEqual(result, expected)
67
68
    def test_run_unmanage_too_long(self):
69
        action = self.setup_node_exists()
70
        self.assertRaises(ValueError,
71
                          action.run,
72
                          "orion",
73
                          "router1",
74
                          90)
75