|
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
|
|
|
|
|
22
|
|
|
__all__ = [ |
|
23
|
|
|
'GetDiscoveryProgressTestCase' |
|
24
|
|
|
] |
|
25
|
|
|
|
|
26
|
|
|
MOCK_CONFIG_BLANK = yaml.safe_load(open( |
|
27
|
|
|
'packs/orion/tests/fixture/blank.yaml').read()) |
|
28
|
|
|
MOCK_CONFIG_FULL = yaml.safe_load(open( |
|
29
|
|
|
'packs/orion/tests/fixture/full.yaml').read()) |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
class GetDiscoveryProgressTestCase(BaseActionTestCase): |
|
33
|
|
|
action_cls = GetDiscoveryProgress |
|
34
|
|
|
|
|
35
|
|
|
def test_run_no_config(self): |
|
36
|
|
|
self.assertRaises(ValueError, GetDiscoveryProgress, MOCK_CONFIG_BLANK) |
|
37
|
|
|
|
|
38
|
|
|
def test_run_is_instance(self): |
|
39
|
|
|
action = self.get_action_instance(MOCK_CONFIG_FULL) |
|
40
|
|
|
|
|
41
|
|
|
self.assertIsInstance(action, GetDiscoveryProgress) |
|
42
|
|
|
|
|
43
|
|
|
def test_run_discovery_status_to_text(self): |
|
44
|
|
|
action = self.get_action_instance(MOCK_CONFIG_FULL) |
|
45
|
|
|
|
|
46
|
|
|
status = action._disc_status_to_text("0") |
|
47
|
|
|
self.assertEqual(status, "Unknown") |
|
48
|
|
|
|
|
49
|
|
|
status = action._disc_status_to_text("1") |
|
50
|
|
|
self.assertEqual(status, "InProgress") |
|
51
|
|
|
|
|
52
|
|
|
status = action._disc_status_to_text("2") |
|
53
|
|
|
self.assertEqual(status, "Finished") |
|
54
|
|
|
|
|
55
|
|
|
status = action._disc_status_to_text("3") |
|
56
|
|
|
self.assertEqual(status, "Error") |
|
57
|
|
|
|
|
58
|
|
|
status = action._disc_status_to_text("4") |
|
59
|
|
|
self.assertEqual(status, "NotScheduled") |
|
60
|
|
|
|
|
61
|
|
|
status = action._disc_status_to_text("5") |
|
62
|
|
|
self.assertEqual(status, "Scheduled") |
|
63
|
|
|
|
|
64
|
|
|
status = action._disc_status_to_text("6") |
|
65
|
|
|
self.assertEqual(status, "NotCompleted") |
|
66
|
|
|
|
|
67
|
|
|
status = action._disc_status_to_text("7") |
|
68
|
|
|
self.assertEqual(status, "Canceling") |
|
69
|
|
|
|
|
70
|
|
|
status = action._disc_status_to_text("8") |
|
71
|
|
|
self.assertEqual(status, "ReadyForImport") |
|
72
|
|
|
|
|
73
|
|
|
# FIXME This needs more tests.... |
|
74
|
|
|
# def test_run_response_processed(self): |
|
75
|
|
|
# pass |
|
76
|
|
|
|