Completed
Pull Request — master (#466)
by
unknown
02:27
created

NcmConfigDownloadActionAliasTestCase   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %
Metric Value
dl 0
loc 14
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_ncm_config_download_alias() 0 11 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 st2tests.base import BaseActionAliasTestCase
16
17
18
class NcmConfigDownloadActionAliasTestCase(BaseActionAliasTestCase):
19
    action_alias_name = 'ncm_config_download'
20
21
    def test_ncm_config_download_alias(self):
22
        format_string = self.action_alias_db.formats[0]['representation'][0]
23
24
        command = "orion ncm config-download orion router1"
25
        expected_parameters = {
26
            'platform': 'orion',
27
            'node': 'router1'
28
        }
29
        self.assertExtractedParametersMatch(format_string=format_string,
30
                                            command=command,
31
                                            parameters=expected_parameters)
32
33
34
class NodeStatusActionAliasTestCase(BaseActionAliasTestCase):
35
    action_alias_name = 'node_status'
36
37
    def test_node_status_alias(self):
38
        format_string = self.action_alias_db.formats[0]['representation'][0]
39
        format_strings = self.action_alias_db.formats[0]['representation']
40
41
        command = "orion node status orion router1"
42
        expected_parameters = {
43
            'platform': 'orion',
44
            'node': 'router1'
45
        }
46
        self.assertExtractedParametersMatch(format_string=format_string,
47
                                            command=command,
48
                                            parameters=expected_parameters)
49
50
        self.assertCommandMatchesExactlyOneFormatString(
51
            format_strings=format_strings,
52
            command=command)
53
54
55
class NodeCreateActionAliasTestCase(BaseActionAliasTestCase):
56
    action_alias_name = 'node_create'
57
58
    def test_node_create_alias(self):
59
        format_strings = self.action_alias_db.formats[1]['representation']
60
        format_string = self.action_alias_db.formats[1]['representation'][3]
61
62
        command = "create orion node router1 at 192.168.0.1"
63
        expected_parameters = {
64
            'ip_address': "192.168.0.1",
65
            'node': 'router1'
66
        }
67
        self.assertExtractedParametersMatch(format_string=format_string,
68
                                            command=command,
69
                                            parameters=expected_parameters)
70
71
        self.assertCommandMatchesExactlyOneFormatString(
72
            format_strings=format_strings,
73
            command=command)
74