GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — develop ( 8ec028...a6b0a6 )
by Plexxi
19:39 queued 10:44
created

UnloadActionTestCase.setUp()   A

Complexity

Conditions 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 19
rs 9.4285
1
#!/usr/bin/env python
2
3
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
4
# contributor license agreements.  See the NOTICE file distributed with
5
# this work for additional information regarding copyright ownership.
6
# The ASF licenses this file to You under the Apache License, Version 2.0
7
# (the "License"); you may not use this file except in compliance with
8
# the License.  You may obtain a copy of the License at
9
#
10
#     http://www.apache.org/licenses/LICENSE-2.0
11
#
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
17
18
import os
19
20
from oslo_config import cfg
21
22
from st2common.content.bootstrap import register_content
23
from st2common.persistence.pack import Pack
24
from st2common.persistence.pack import Config
25
from st2common.persistence.pack import ConfigSchema
26
from st2common.persistence.actionalias import ActionAlias
27
from st2common.persistence.action import Action
28
from st2common.persistence.rule import Rule
29
from st2common.persistence.policy import Policy
30
from st2common.persistence.sensor import SensorType as Sensor
31
from st2common.persistence.trigger import TriggerType
32
33
from st2tests.base import BaseActionTestCase
34
from st2tests.base import CleanDbTestCase
35
from st2tests import fixturesloader
36
37
from pack_mgmt.unload import UnregisterPackAction
38
39
__all__ = [
40
    'UnloadActionTestCase'
41
]
42
43
PACK_PATH_1 = os.path.join(fixturesloader.get_fixtures_packs_base_path(), 'dummy_pack_1')
44
45
46
class UnloadActionTestCase(BaseActionTestCase, CleanDbTestCase):
47
    action_cls = UnregisterPackAction
48
49
    def setUp(self):
50
        super(UnloadActionTestCase, self).setUp()
51
52
        # Register mock pack
53
        # Verify DB is empty
54
        pack_dbs = Pack.get_all()
55
        config_schema_dbs = ConfigSchema.get_all()
56
        config_dbs = Config.get_all()
57
58
        self.assertEqual(len(pack_dbs), 0)
59
        self.assertEqual(len(config_schema_dbs), 0)
60
        self.assertEqual(len(config_dbs), 0)
61
62
        # Register the pack with all the content
63
        # TODO: Don't use pack cache
64
        cfg.CONF.set_override(name='all', override=True, group='register')
65
        cfg.CONF.set_override(name='pack', override=PACK_PATH_1, group='register')
66
        cfg.CONF.set_override(name='no_fail_on_failure', override=True, group='register')
67
        register_content()
68
69
    def test_run(self):
70
        pack = 'dummy_pack_1'
71
        # Verify all the resources are there
72
73
        pack_dbs = Pack.query(ref=pack)
74
        action_dbs = Action.query(pack=pack)
75
        alias_dbs = ActionAlias.query(pack=pack)
76
        rule_dbs = Rule.query(pack=pack)
77
        sensor_dbs = Sensor.query(pack=pack)
78
        trigger_type_dbs = TriggerType.query(pack=pack)
79
        policy_dbs = Policy.query(pack=pack)
80
81
        config_schema_dbs = ConfigSchema.query(pack=pack)
82
        config_dbs = Config.query(pack=pack)
83
84
        self.assertEqual(len(pack_dbs), 1)
85
        self.assertEqual(len(action_dbs), 1)
86
        self.assertEqual(len(alias_dbs), 2)
87
        self.assertEqual(len(rule_dbs), 1)
88
        self.assertEqual(len(sensor_dbs), 1)
89
        self.assertEqual(len(trigger_type_dbs), 3)
90
        self.assertEqual(len(policy_dbs), 2)
91
92
        self.assertEqual(len(config_schema_dbs), 1)
93
        self.assertEqual(len(config_dbs), 1)
94
95
        # Run action
96
        action = self.get_action_instance()
97
        action.run(packs=[pack])
98
99
        # Make sure all resources have been removed from the db
100
        pack_dbs = Pack.query(ref=pack)
101
        action_dbs = Action.query(pack=pack)
102
        alias_dbs = ActionAlias.query(pack=pack)
103
        rule_dbs = Rule.query(pack=pack)
104
        sensor_dbs = Sensor.query(pack=pack)
105
        trigger_type_dbs = TriggerType.query(pack=pack)
106
        policy_dbs = Policy.query(pack=pack)
107
108
        config_schema_dbs = ConfigSchema.query(pack=pack)
109
        config_dbs = Config.query(pack=pack)
110
111
        self.assertEqual(len(pack_dbs), 0)
112
        self.assertEqual(len(action_dbs), 0)
113
        self.assertEqual(len(alias_dbs), 0)
114
        self.assertEqual(len(rule_dbs), 0)
115
        self.assertEqual(len(sensor_dbs), 0)
116
        self.assertEqual(len(trigger_type_dbs), 0)
117
        self.assertEqual(len(policy_dbs), 0)
118
119
        self.assertEqual(len(config_schema_dbs), 0)
120
        self.assertEqual(len(config_dbs), 0)
121