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

test_run_is_instance()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
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
# from mock import Mock, MagicMock
17
18
from st2tests.base import BaseActionTestCase
19
20
from get_discovery_progress import GetDiscoveryProgress
21
from lib.utils import discovery_status_to_text
22
23
24
__all__ = [
25
    'GetDiscoveryProgressTestCase'
26
]
27
28
29
class GetDiscoveryProgressTestCase(BaseActionTestCase):
30
    action_cls = GetDiscoveryProgress
31
32
    def test_run_no_config(self):
33
        self.assertRaises(ValueError,
34
                          GetDiscoveryProgress,
35
                          yaml.safe_load(
36
                              self.get_fixture_content('blank.yaml')))
37
38
    def test_run_is_instance(self):
39
        action = self.get_action_instance(yaml.safe_load(
40
            self.get_fixture_content('full.yaml')))
41
42
        self.assertIsInstance(action, GetDiscoveryProgress)
43
44
    def test_run_discovery_status_to_text(self):
45
        status = discovery_status_to_text("0")
46
        self.assertEqual(status, "Unknown")
47
48
        status = discovery_status_to_text("1")
49
        self.assertEqual(status, "InProgress")
50
51
        status = discovery_status_to_text("2")
52
        self.assertEqual(status, "Finished")
53
54
        status = discovery_status_to_text("3")
55
        self.assertEqual(status, "Error")
56
57
        status = discovery_status_to_text("4")
58
        self.assertEqual(status, "NotScheduled")
59
60
        status = discovery_status_to_text("5")
61
        self.assertEqual(status, "Scheduled")
62
63
        status = discovery_status_to_text("6")
64
        self.assertEqual(status, "NotCompleted")
65
66
        status = discovery_status_to_text("7")
67
        self.assertEqual(status, "Canceling")
68
69
        status = discovery_status_to_text("8")
70
        self.assertEqual(status, "ReadyForImport")
71
72
    # FIXME This needs more tests....
73
    # def test_run_response_processed(self):
74
    #    pass
75