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 — kale/submit-debug-info ( 1f660b )
by
unknown
05:52
created

test_run_st2contrib_auto_deloy()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 1
1
import yaml
2
3
from st2tests.base import BaseActionTestCase
4
5
from check_auto_deploy_repo import CheckAutoDeployRepo
6
7
__all__ = [
8
    'CheckAutoDeployRepoActionTestCase'
9
]
10
11
MOCK_DATA_1 = { "deployment_branch": "master", "notify_channel": "community" }
12
13
MOCK_CONFIG_BLANK = ""
14
15
MOCK_CONFIG_BLANK_REPOSITORIES = "repositories:"
16
17
MOCK_CONFIG_FULL= """
18
repositories:
19
  st2contrib:
20
    repo: "https://github.com/StackStorm/st2contrib.git"
21
    subtree: true
22
    auto_deployment:
23
      branch: "master"
24
      notify_channel: "community"
25
26
  st2incubator:
27
    repo: "https://github.com/StackStorm/st2incubator.git"
28
    subtree: true
29
    auto_deployment:
30
      branch: "master"
31
      notify_channel: "community"
32
"""
33
34
class CheckAutoDeployRepoActionTestCase(BaseActionTestCase):
35
    def test_run_config_blank(self):
36
        config = yaml.safe_load(MOCK_CONFIG_BLANK)
37
        action = CheckAutoDeployRepo(config)
38
39
        self.assertRaises(Exception, action.run,
40
                          branch="refs/heads/master", repo_name="st2contrib")
41
42
    def test_run_repositories_blank(self):
43
        config = yaml.safe_load(MOCK_CONFIG_BLANK_REPOSITORIES)
44
        action = CheckAutoDeployRepo(config)
45
46
        self.assertRaises(Exception, action.run,
47
                          branch="refs/heads/master", repo_name="st2contrib")
48
49
    def test_run_st2contrib_no_auto_deloy(self):
50
        config = yaml.safe_load(MOCK_CONFIG_FULL)
51
        action = CheckAutoDeployRepo(config)
52
53
        self.assertRaises(Exception, action.run,
54
                          branch="refs/heads/dev", repo_name="st2contrib")
55
56
    def test_run_st2contrib_auto_deloy(self):
57
        config = yaml.safe_load(MOCK_CONFIG_FULL)
58
        action = CheckAutoDeployRepo(config)
59
60
        expected = {'deployment_branch': 'master', 'notify_channel': 'community'}
61
62
        result = action.run(branch="refs/heads/master", repo_name="st2contrib")
63
        self.assertEqual(result, expected)
64
65
66
    def test_run_st2incubator_no_auto_deloy(self):
67
        config = yaml.safe_load(MOCK_CONFIG_FULL)
68
        action = CheckAutoDeployRepo(config)
69
70
        self.assertRaises(Exception, action.run,
71
                          branch="refs/heads/dev", repo_name="st2incubator")
72
73
    def test_run_st2incubator_auto_deloy(self):
74
        config = yaml.safe_load(MOCK_CONFIG_FULL)
75
        action = CheckAutoDeployRepo(config)
76
77
        expected = {'deployment_branch': 'master', 'notify_channel': 'community'}
78
79
        result = action.run(branch="refs/heads/master", repo_name="st2incubator")
80
        self.assertEqual(result, expected)
81